From 0670f581dabada8c334130e3c9505533383cd369 Mon Sep 17 00:00:00 2001 From: Bryan Frimin Date: Fri, 13 Mar 2026 18:19:57 +0100 Subject: [PATCH] Skip empty text block in Anthropic tool-only assistant turns Signed-off-by: Bryan Frimin --- pkg/llm/anthropic/provider.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/pkg/llm/anthropic/provider.go b/pkg/llm/anthropic/provider.go index 529f321a3..7ae9b11dc 100644 --- a/pkg/llm/anthropic/provider.go +++ b/pkg/llm/anthropic/provider.go @@ -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