Skip to content

fix: preserve unknown CLI wire fields on ResultMessage and AssistantMessage#1043

Open
ashishpatel26 wants to merge 1 commit into
anthropics:mainfrom
ashishpatel26:fix/issue-1026-raw-field-passthrough
Open

fix: preserve unknown CLI wire fields on ResultMessage and AssistantMessage#1043
ashishpatel26 wants to merge 1 commit into
anthropics:mainfrom
ashishpatel26:fix/issue-1026-raw-field-passthrough

Conversation

@ashishpatel26

Copy link
Copy Markdown

Summary

Resolves #1026

parse_message was silently discarding CLI wire fields not yet modeled in the SDK (e.g. ttft_ms, terminal_reason, stop_details). Users on newer CLI versions had no way to access these fields.

This PR adds a raw: dict[str, Any] passthrough field to ResultMessage and AssistantMessage that stores the original wire dict, giving callers an escape hatch for unmodeled fields.

Changes Made

  • src/claude_agent_sdk/types.py: add raw: dict[str, Any] = field(default_factory=dict) to ResultMessage and AssistantMessage
  • src/claude_agent_sdk/_internal/message_parser.py: pass raw=data when constructing those messages
  • tests/test_message_parser.py: 5 regression tests covering unknown-field passthrough for both message types

Testing

  • Tests added for raw field passthrough (TestRawFieldPassthrough, 5 tests)
  • All 126 message parser + types tests pass

Related Issue

Closes #1026

…essage (anthropics#1026)

parse_message was silently dropping fields not explicitly modeled
(e.g. ttft_ms, terminal_reason, stop_details). Add a raw passthrough
field on ResultMessage and AssistantMessage so callers on newer CLI
versions can access fields that haven't been promoted yet.
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.

parse_message silently drops newer CLI wire fields (ttft_ms, terminal_reason, stop_details, …) with no escape hatch

1 participant