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.
This commit is contained in:
ParthSareen 2026-01-04 23:48:46 -08:00
parent 90cf232df2
commit 5ba2092f0a
1 changed files with 4 additions and 4 deletions

View File

@ -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"`
}