Tool-Nutzung: tool_choice pro Agent konfigurierbar (default: any), wiederholte Instruktionen im System-Prompt, MaxIterations in appsettings

This commit is contained in:
Meleki committed 2026-02-28 19:33:41 +01:00
1 parent 8c9f54da79
commit ff67542ba6
10 files changed
+59 -9

No files matched your search

+3 -1
View File
@@ -49,7 +49,8 @@ public static class AgentEndpoint
Description = body.TryGetProperty("description", out var d) ? d.GetString() : null,
Model = body.TryGetProperty("model", out var m) ? m.GetString() ?? "sonnet" : "sonnet",
Persona = body.TryGetProperty("persona", out var p) ? p.GetString() : null,
Instructions = body.TryGetProperty("instructions", out var i) ? i.GetString() : null
Instructions = body.TryGetProperty("instructions", out var i) ? i.GetString() : null,
ToolChoice = body.TryGetProperty("toolChoice", out var tc) ? tc.GetString() ?? "any" : "any"
};
agent = await db.CreateAgent(agent);
@@ -72,6 +73,7 @@ public static class AgentEndpoint
if (body.TryGetProperty("model", out var m)) agent.Model = m.GetString();
if (body.TryGetProperty("persona", out var p)) agent.Persona = p.GetString();
if (body.TryGetProperty("instructions", out var i)) agent.Instructions = i.GetString();
if (body.TryGetProperty("toolChoice", out var tc)) agent.ToolChoice = tc.GetString();
await db.UpdateAgent(agent);
agent = await db.GetAgent(agentId);
+4 -1
View File
@@ -151,11 +151,14 @@ public static class ChatEndpoint
if (!string.IsNullOrEmpty(workspace))
Directory.CreateDirectory(workspace);
var maxIterations = config.GetValue<int>("MaxIterations", 100);
var toolChoice = agent.ToolChoice ?? "any";
var anthropic = new AnthropicService(httpFactory, token, toolService, db);
streamingTracker.Start(sessionId, chainId);
try
{
await anthropic.StreamChat(res, modelId, systemPrompt, messages, chainId, workspace, sessionId, cancellationToken: cancellationToken);
await anthropic.StreamChat(res, modelId, systemPrompt, messages, chainId, workspace, sessionId, maxIterations: maxIterations, toolChoice: toolChoice, cancellationToken: cancellationToken);
}
finally
{