Skip empty text block in Anthropic tool-only assistant turns

Signed-off-by: Bryan Frimin <bryan@getprobo.com>
This commit is contained in:
Bryan Frimin
2026-03-13 18:19:57 +01:00
parent a710a7472d
commit 0670f581da

View File

@@ -189,8 +189,9 @@ func buildMessages(messages []llm.Message) []anthropic.MessageParam {
}
out = append(out, anthropic.NewUserMessage(blocks...))
case llm.RoleAssistant:
blocks := []anthropic.ContentBlockParamUnion{
anthropic.NewTextBlock(msg.Text()),
var blocks []anthropic.ContentBlockParamUnion
if text := msg.Text(); text != "" {
blocks = append(blocks, anthropic.NewTextBlock(text))
}
for _, tc := range msg.ToolCalls {
var input any