fix: tool_end SSE-Event nicht mehr auf 500 Zeichen kürzen + tool_result History-Truncation

- tool_end SSE-Event: 500-Zeichen-Limit entfernt (2 Stellen), damit
  todo_write und andere Tools beim Streaming vollständig angezeigt werden
- BuildHistoryFromDb: TruncateToolResult (20k) auf tool_result-Messages
  angewendet, um Token-Overflow bei History-Rebuild zu verhindern
  (609k Tokens > 200k Limit nach awaiting_user_choice)
- TruncateToolResult/MaxToolResultChars auf internal geändert
- TODO.md: todo_write-Bug als erledigt markiert
This commit is contained in:
Meleki committed 2026-03-09 09:40:30 +01:00
1 parent dcedbaa074
commit cdad7faad4
3 files changed
+7 -7

No files matched your search

+4 -4
View File
@@ -741,7 +741,7 @@ public class AnthropicService
toolName,
toolId,
input = toolInput.ToString(),
result = toolResult.Length > 500 ? toolResult[..500] + "..." : toolResult,
result = toolResult,
isError,
agentName
}, cancellationToken);
@@ -1195,7 +1195,7 @@ public class AnthropicService
{
name = currentToolName,
input = currentToolInputJson.ToString(),
result = toolResult.Length > 500 ? toolResult[..500] + "..." : toolResult,
result = toolResult,
isError
}, cancellationToken);
}
@@ -1293,9 +1293,9 @@ public class AnthropicService
// ── Shared Helpers ──
private const int MaxToolResultChars = 20_000;
internal const int MaxToolResultChars = 20_000;
private static string TruncateToolResult(string result)
internal static string TruncateToolResult(string result)
{
return result.Length > MaxToolResultChars
? result[..MaxToolResultChars] + $"\n\n[... gekürzt, {result.Length - MaxToolResultChars} weitere Zeichen ...]"
+2 -2
View File
@@ -370,7 +370,7 @@ Für welche Plattform soll die App entwickelt werden? Web, Mobile oder Desktop?
dict.TryGetValue("role", out var role) && role.ToString() == "user" &&
dict.TryGetValue("content", out var existingContent) && existingContent is List<object> contentList)
{
contentList.Add(new { type = "tool_result", tool_use_id = msg.ToolCallId, content = msg.Content ?? "", is_error = msg.IsError });
contentList.Add(new { type = "tool_result", tool_use_id = msg.ToolCallId, content = AnthropicService.TruncateToolResult(msg.Content ?? ""), is_error = msg.IsError });
}
else
{
@@ -379,7 +379,7 @@ Für welche Plattform soll die App entwickelt werden? Web, Mobile oder Desktop?
["role"] = "user",
["content"] = new List<object>
{
new { type = "tool_result", tool_use_id = msg.ToolCallId, content = msg.Content ?? "", is_error = msg.IsError }
new { type = "tool_result", tool_use_id = msg.ToolCallId, content = AnthropicService.TruncateToolResult(msg.Content ?? ""), is_error = msg.IsError }
}
});
}