fix: Tag-Feld für Sub-Agent-Messages – verhindert API 400 bei tool_use ohne tool_result

- MessageRecord: neues Tag-Feld (null=normal, preparer/review/finalizer=Sub-Agent)
- DatabaseService: Migration tag-Spalte, INSERT-Statements erweitert
- AnthropicService: RunAgentChat setzt Tag=agentType bei allen 4 SaveMessage-Aufrufen
- ChatService: BuildHistoryFromDb filtert getaggte Messages aus API-History

Sub-Agent-Messages bleiben in der DB (Frontend-Anzeige), werden aber
nie an die Claude API geschickt – löst das Problem für Preparer,
Review und Finalizer gleichermaßen.
This commit is contained in:
Meleki committed 2026-03-07 15:37:28 +01:00
1 parent 494f431963
commit 43d3e9dc26
4 files changed
+17 -9

No files matched your search

+8 -4
View File
@@ -691,7 +691,8 @@ public class AnthropicService
Iteration = baseIterations + iterations,
Role = "assistant",
Type = "text",
Content = $"[{tag}: {agentName}] {text}"
Content = $"[{tag}: {agentName}] {text}",
Tag = agentType
});
}
else if (blockType == "tool_use")
@@ -718,7 +719,8 @@ public class AnthropicService
Type = "tool_use",
Content = toolInput.GetRawText(),
ToolName = toolName,
ToolCallId = toolId
ToolCallId = toolId,
Tag = agentType
});
string toolResult;
@@ -748,7 +750,8 @@ public class AnthropicService
Content = toolResult,
ToolName = toolName,
ToolCallId = toolId,
IsError = isError
IsError = isError,
Tag = agentType
});
}
else if (blockType == "web_search_tool_result")
@@ -779,7 +782,8 @@ public class AnthropicService
Iteration = baseIterations + iterations,
Role = "assistant",
Type = "web_search_result",
Content = JsonSerializer.Serialize(sources)
Content = JsonSerializer.Serialize(sources),
Tag = agentType
});
}
}