Skip to content

fix(streaming): safely handle dicts in accumulate_event#1153

Open
Ashutosh0x wants to merge 1 commit intoanthropics:mainfrom
Ashutosh0x:fix/streaming-attribute-error
Open

fix(streaming): safely handle dicts in accumulate_event#1153
Ashutosh0x wants to merge 1 commit intoanthropics:mainfrom
Ashutosh0x:fix/streaming-attribute-error

Conversation

@Ashutosh0x
Copy link

Fixes #1088. Intermittently, 'event.message' or 'event.content_block' may already be dictionaries during response accumulation. This change adds a safety check to ensure '.to_dict()' or '.model_dump()' are only called if the objects are actual model instances, preventing AttributeError.

@Ashutosh0x Ashutosh0x requested a review from a team as a code owner January 26, 2026 15:53
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.

Intermittent AttributeError in beta.messages.stream() with effort parameter: 'dict' object has no attribute 'to_dict'

1 participant