diff --git a/Services/AnthropicService.cs b/Services/AnthropicService.cs
index 6a6a021..748f33c 100644
--- a/Services/AnthropicService.cs
+++ b/Services/AnthropicService.cs
@@ -896,7 +896,7 @@ public class AnthropicService
string toolResult;
bool isError = false;
- try { toolResult = await _toolService.ExecuteTool(toolName, toolInput, agentWorkspace, _memoryService, agentId, workCt, vectorSearch: _vectorSearch, embeddingBg: _embeddingBg); }
+ try { toolResult = await _toolService.ExecuteTool(toolName, toolInput, agentWorkspace, _memoryService, agentId, workCt, vectorSearch: _vectorSearch, embeddingBg: _embeddingBg, db: _db, chatService: _chatService, anthropicService: this, telegramService: _telegramService); }
catch (OperationCanceledException) { throw; }
catch (Exception ex) { toolResult = $"Fehler: {ex.Message}"; isError = true; }
@@ -1102,7 +1102,7 @@ public class AnthropicService
string toolResult;
bool isError = false;
- try { toolResult = await _toolService.ExecuteTool(toolName, toolInput, ctx.Workspace, _memoryService, ctx.AgentId, vectorSearch: _vectorSearch, embeddingBg: _embeddingBg); }
+ try { toolResult = await _toolService.ExecuteTool(toolName, toolInput, ctx.Workspace, _memoryService, ctx.AgentId, vectorSearch: _vectorSearch, embeddingBg: _embeddingBg, db: _db, chatService: _chatService, anthropicService: this, userId: ctx.Session?.UserId, telegramService: _telegramService); }
catch (OperationCanceledException) { throw; }
catch (Exception ex) { toolResult = $"Fehler: {ex.Message}"; isError = true; }
diff --git a/Services/ChatService.cs b/Services/ChatService.cs
index 4ea0b8c..f5da266 100644
--- a/Services/ChatService.cs
+++ b/Services/ChatService.cs
@@ -593,8 +593,8 @@ Für welche Plattform soll die App entwickelt werden? Web, Mobile oder Desktop?
}
}
- // Post-Processing: Offener ask_user_choice tool_use ohne tool_result → synthetisches tool_result einfügen
- FixOrphanedAskUserChoice(history);
+ // Post-Processing: Offene tool_use-Blöcke ohne tool_result → synthetische tool_results einfügen
+ FixOrphanedToolUse(history);
// Post-Processing: Orphaned web_search server_tool_use entfernen
// Bei alten DB-Einträgen wurde web_search_tool_result nur als Sources-Array gespeichert,
@@ -681,49 +681,91 @@ Für welche Plattform soll die App entwickelt werden? Web, Mobile oder Desktop?
}
///
- /// Prüft ob die History mit einem offenen ask_user_choice tool_use endet (kein passendes tool_result).
- /// Falls ja, wird ein synthetisches tool_result eingefügt – verhindert Anthropic API 400.
- /// Passiert wenn der User einfach Text schreibt statt eine Choice zu wählen.
+ /// Prüft die gesamte History auf tool_use-Blöcke ohne passendes tool_result in der nächsten user-Message.
+ /// Falls gefunden, werden synthetische tool_results eingefügt – verhindert Anthropic API 400.
+ /// Betrifft alle Tools, nicht nur ask_user_choice (z.B. wenn eine Chain abbricht ohne tool_result zu speichern).
///
- private static void FixOrphanedAskUserChoice(List