Skip to content

fix(streaming): handle raw dicts in accumulate_event to prevent AttributeError#1146

Draft
Ashutosh0x wants to merge 5 commits intoanthropics:mainfrom
Ashutosh0x:fix/dict-to-dict-error
Draft

fix(streaming): handle raw dicts in accumulate_event to prevent AttributeError#1146
Ashutosh0x wants to merge 5 commits intoanthropics:mainfrom
Ashutosh0x:fix/dict-to-dict-error

Conversation

@Ashutosh0x
Copy link

@Ashutosh0x Ashutosh0x commented Jan 22, 2026

Fixes #1088.

This PR ensures that accumulate_event correctly handles cases where event.message or event.content_block are already dictionaries, preventing AttributeError: 'dict' object has no attribute 'to_dict' (or model_dump).

This can happen if nested objects are not fully deserialized into BaseModel instances before accumulation.

Verified with
epro_issue_1088.py.

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