Skip to content

fix(anthropic): suppress Pydantic serialization warnings from ParsedTextBlock#1874

Closed
fahe1em1 wants to merge 1 commit into
strands-agents:mainfrom
fahe1em1:fix/anthropic-pydantic-serialization-warnings
Closed

fix(anthropic): suppress Pydantic serialization warnings from ParsedTextBlock#1874
fahe1em1 wants to merge 1 commit into
strands-agents:mainfrom
fahe1em1:fix/anthropic-pydantic-serialization-warnings

Conversation

@fahe1em1

Copy link
Copy Markdown

Summary

  • Passes warnings=False to model_dump() calls in AnthropicModel.stream() to suppress PydanticSerializationUnexpectedValue warnings
  • Anthropic SDK >= 0.84.0 returns ParsedTextBlock objects that don't match Pydantic's expected union discriminator, producing 6+ warning lines per agent invocation on stderr
  • The serialization still works correctly — this only suppresses the noisy warnings

Fixes #1865

Test plan

  • Run agent with AnthropicModel using anthropic>=0.84.0 and verify no PydanticSerializationUnexpectedValue warnings on stderr
  • Verify agent tool calls and responses still work correctly
  • Run existing test suite

https://claude.ai/code/session_011TWMvnjeLgAJg9XtxoLfZT

…extBlock

Anthropic SDK >= 0.84.0 returns ParsedTextBlock objects in message
content that don't match the expected union discriminator, causing
noisy PydanticSerializationUnexpectedValue warnings on stderr during
model_dump(). Pass warnings=False to suppress these harmless warnings.

Fixes strands-agents#1865

https://claude.ai/code/session_011TWMvnjeLgAJg9XtxoLfZT
@yonib05 yonib05 added area-model Related to models or model providers python Pull requests that update python code bug Something isn't working labels May 27, 2026
@chaynabors

Copy link
Copy Markdown
Member

Closed in favor of #2953

@chaynabors chaynabors closed this Jun 26, 2026
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

4 participants