Skip to content

fix: preserve unrecognized content block types in message parser#651

Open
Bortlesboat wants to merge 1 commit intoanthropics:mainfrom
Bortlesboat:fix-unrecognized-content-blocks
Open

fix: preserve unrecognized content block types in message parser#651
Bortlesboat wants to merge 1 commit intoanthropics:mainfrom
Bortlesboat:fix-unrecognized-content-blocks

Conversation

@Bortlesboat
Copy link
Contributor

Summary

  • Assistant and user message parsers silently drop content blocks with unrecognized type values
  • When the CLI emits new block types (e.g. server_tool_use, code_execution_result, citations), older SDK versions lose the data entirely
  • Add RawContentBlock fallback type and case _: branches to both parsers so unrecognized blocks are preserved as raw dicts

This follows the same forward-compatibility pattern as #598 (unknown message types) and #574 (unknown MCP content blocks).

Test plan

  • New tests for unknown blocks in both assistant and user messages
  • All 257 existing tests pass
  • Lint clean

The assistant and user message parsers silently dropped content blocks
with unrecognized types. Add a RawContentBlock fallback so newer CLI
versions don't lose data when the SDK hasn't been updated yet.
@Bortlesboat
Copy link
Contributor Author

Quick follow-up from my side: I’m treating review-required PRs as top priority this week. If you want any specific changes, rebase, or split, I can turn them around quickly.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant