feat: ToolChoice + ToolNames pro Chain in DB speichern

- ChainRecord: neue Felder ToolChoice (auto/any) und ToolNames (JSON-Array)
- DatabaseService: Migration tool_choice + tool_names Spalten, INSERT erweitert
- ChatEndpoint: berechnet Tools vor Chain-Erstellung, speichert Werte mit
- ToolService: execute-Timeout Beschreibung korrigiert (30s → 180s)
This commit is contained in:
Meleki committed 2026-03-02 10:42:54 +01:00
1 parent b24a000784
commit a1c54bf376
4 files changed
+26 -6

No files matched your search

+19 -3
View File
@@ -85,13 +85,31 @@ public static class ChatEndpoint
var chainId = Guid.NewGuid().ToString("N");
var workspace = session.Workspace;
var toolChoice = agent.ToolChoice ?? "any";
var hasWorkspace = !string.IsNullOrEmpty(workspace);
var includeMemory = agent.UseMemory && !string.IsNullOrEmpty(agent.AgentId);
var toolDefs = (hasWorkspace || includeMemory)
? toolService.GetToolDefinitions(includeFileTools: hasWorkspace, includeMemory: includeMemory)
: Array.Empty<object>();
var toolNames = toolDefs.Length > 0
? JsonSerializer.Serialize(toolDefs.Select(td =>
{
var json = JsonSerializer.Serialize(td);
var el = JsonSerializer.Deserialize<JsonElement>(json);
return el.GetProperty("name").GetString();
}).ToArray())
: null;
await db.CreateChain(new ChainRecord
{
ChainId = chainId,
SessionId = sessionId,
AgentId = agent.AgentId,
Model = modelId,
SystemPrompt = systemPromptText
SystemPrompt = systemPromptText,
ToolChoice = (hasWorkspace || includeMemory) ? toolChoice : null,
ToolNames = toolNames
});
// Session-Timestamp aktualisieren
@@ -150,12 +168,10 @@ public static class ChatEndpoint
? new List<object>()
: new List<object> { new { type = "text", text = systemPromptText } };
var workspace = session.Workspace;
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, memoryService);
streamingTracker.Start(sessionId, chainId);