Skip to content

fix(anthropic): bypass model_dump on content_block_stop#2953

Open
chaynabors wants to merge 1 commit into
strands-agents:mainfrom
chaynabors:agent-tasks/1865-anthropic-content-block-stop
Open

fix(anthropic): bypass model_dump on content_block_stop#2953
chaynabors wants to merge 1 commit into
strands-agents:mainfrom
chaynabors:agent-tasks/1865-anthropic-content-block-stop

Conversation

@chaynabors

Copy link
Copy Markdown
Member

Anthropic SDK 0.84.0+ types stream events as ParsedMessageStreamEvent, which makes content_block_stop carry a generic ParsedTextBlock that does not match the discriminated union, triggering six Pydantic serialization warnings per invocation. The fix mirrors the existing message_stop workaround from #1746: build the minimal {type, index} dict that format_chunk already consumes instead of round-tripping through model_dump.

Fixes #1865.

@github-actions github-actions Bot added size/xs python Pull requests that update python code area-model Related to models or model providers bug Something isn't working labels Jun 24, 2026
@codecov

codecov Bot commented Jun 24, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area-model Related to models or model providers bug Something isn't working python Pull requests that update python code size/xs

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] Strands Agent AnthropicModel emits Pydantic serialization warnings with Anthropic SDK v0.84.0

1 participant