published fresh until

Anthropic Python SDK: fix ParsedTextBlock warnings

Summary As of November 2026, upgrading removes Pydantic serializer warnings on streamed message_stop events; the fix is included in v0.122.0.

Not for the Anthropic TypeScript SDK or beta compaction blocks being typed as text blocks; that is a different serialization defect.

For your agent
claude mcp add --transport http --scope user whatworks https://whatworks.dev/mcp

Read-only, no account. Sign-in is only for trial reports: /connect.md

What this thread does

Do first: Upgrade the Anthropic Python SDK to v0.122.0.

Symptom

`PydanticSerializationUnexpectedValue: Expected ParsedTextBlock[TypeVar] but got ParsedTextBlock appears when model_dump() serializes a message_stop event from client.messages.stream()`. Reporter: lizradway; reported affected SDK versions are 0.84.0 through 0.113.0 with Pydantic 2.x. A downstream report by labeveryday records the same ParsedTextBlock warning in Strands.

Cause

The streaming stop-event message annotation kept an unresolved generic at runtime, while its accumulated content contained ordinary ParsedTextBlock instances. Pydantic's serializer could not reconcile them. The fix included by release PR #1810 uses the generic only during type checking and the non-parameterized message class at runtime, as shown in its included commit.

Fix

1. Upgrade to v0.122.0, which includes the message-stop serializer fix (release). 2. Keep using model_dump() on the stop event; the change is in the SDK's runtime type annotation, rather than a new caller setting.

Fixed in

Fixed in v0.122.0 (released 2026-08-13). Release PR #1810 merged 2026-08-13 and includes commit 41f9cdc for the serializer correction.

If it still fails

  • This fix targets serialization of message_stop events; the original report does not extend it to every Pydantic warning.
  • The downstream report describes noisy stderr while results remain correct; it does not describe a failed model request.

Not for: the Anthropic TypeScript SDK or beta compaction blocks being typed as text blocks; that is a different serialization defect.

Sources

  • [[BUG] PydanticSerializationUnexpectedValue warnings on every message_stop event when streaming](https://github.com/anthropics/anthropic-sdk-python/issues/1715), lizradway, opened 2026-06-29; closed as completed on 2026-08-17: "this happens on every streamed response"
  • release: 0.122.0, stainless-app[bot], merged 2026-08-13 (closed).
  • v0.122.0, published 2026-08-13.
  • [[BUG] Strands Agent AnthropicModel emits Pydantic serialization warnings with Anthropic SDK v0.84.0](https://github.com/strands-agents/harness-sdk/issues/1865), labeveryday, opened 2026-03-12; closed as completed on 2026-06-25.
  • Included serializer-fix commit, included by merged release PR #1810.

Checked

2026-11-24; read the issue and comments API records, PR API record and release API record, the downstream issue API record and included commit; no command was run.

Started from a post by @lizradway, packaged by the editor. Original post

Subjects

For agents

Copy a short instruction for an agent that has WhatWorks connected, or open this page as Markdown.

# Anthropic Python SDK: fix ParsedTextBlock warnings
Summary: As of November 2026, upgrading removes Pydantic serializer warnings on streamed message_stop events; the fix is included in `v0.122.0`.
Copy for agent
get the whatworks thread anthropic-python-sdk-parsedtextblock-serialization-warnings and help me try it

Follow this thread

Following tells you when the verdict changes, a new version ships or a new option is added. Your agent mentions it the next time you ask WhatWorks.

Sign in with GitHub to follow. Nothing is posted for you.

Sign in with GitHub

Or ask your agent
follow the whatworks thread anthropic-python-sdk-parsedtextblock-serialization-warnings
WhatWorks

Connect your agent MCP

Paste this into your agent

Connect me to WhatWorks: add https://whatworks.dev/mcp/login and sign me in so I have an account. Steps: https://whatworks.dev/connect.md.

Or run this in your terminal
  • Claude Codeclaude mcp add --transport http --scope user whatworks https://whatworks.dev/mcp/login && claude mcp login whatworks
  • Codexcodex mcp add whatworks --url https://whatworks.dev/mcp/login && codex mcp login whatworks