From 5ba2092f0ae038ce3a7480d3dfaed1fc5f780e95 Mon Sep 17 00:00:00 2001 From: ParthSareen Date: Sun, 4 Jan 2026 23:48:46 -0800 Subject: [PATCH] anthropic: fix streaming with SDK by including empty fields Remove omitempty from Text and Thinking fields in ContentBlock struct. The Anthropic SDK requires these fields to be present (even if empty) in content_block_start events to properly accumulate streaming deltas. --- anthropic/anthropic.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/anthropic/anthropic.go b/anthropic/anthropic.go index 28112ac0f..3a1d28099 100644 --- a/anthropic/anthropic.go +++ b/anthropic/anthropic.go @@ -82,8 +82,8 @@ type MessageParam struct { type ContentBlock struct { Type string `json:"type"` // text, image, tool_use, tool_result, thinking - // For text blocks - Text string `json:"text,omitempty"` + // For text blocks (no omitempty - SDK requires field to be present for accumulation) + Text string `json:"text"` // For image blocks Source *ImageSource `json:"source,omitempty"` @@ -98,8 +98,8 @@ type ContentBlock struct { Content any `json:"content,omitempty"` // string or []ContentBlock IsError bool `json:"is_error,omitempty"` - // For thinking blocks - Thinking string `json:"thinking,omitempty"` + // For thinking blocks (no omitempty - SDK requires field to be present for accumulation) + Thinking string `json:"thinking"` Signature string `json:"signature,omitempty"` }