fix: pass unknown SSE event types through stream instead of dropping silently#1363
Closed
atishay2 wants to merge 1 commit intoanthropics:mainfrom
Closed
fix: pass unknown SSE event types through stream instead of dropping silently#1363atishay2 wants to merge 1 commit intoanthropics:mainfrom
atishay2 wants to merge 1 commit intoanthropics:mainfrom
Conversation
…silently The __stream__ methods in Stream and AsyncStream used separate if statements with no else clause, causing any unrecognized event type to be silently dropped. This broke client.beta.sessions.events.stream() entirely since managed agents emit different event names (agent.message, session.status_*) that don't match the hardcoded Messages API event list. Fix: Convert if/if/if/if to if/elif/elif/elif/else in both sync and async __stream__ methods so unknown events pass through process_data() instead of being silently discarded. Fixes anthropics#1357
Collaborator
|
Thank you for the PR - this was already addressed on |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #1357
Problem
Stream.__stream__()andAsyncStream.__stream__()used separateifstatements with noelseclause. Any SSE event not in the hardcoded list (
message_start,message_delta, etc.) was silentlydropped.
This broke
client.beta.sessions.events.stream()entirely — managed agents emit event types likeagent.message,session.status_running,agent.tool_usewhich don't match the Messages API eventnames.
Fix
Converted the
if/if/if/ifchain toif/elif/elif/elif/elsein both the sync and async__stream__()methods. The
elseclause passes unrecognized event types throughprocess_data()for discriminatedunion parsing.
Testing
Existing test suite passes (2230 passed). The 5
test_aws.pyfailures are pre-existing and caused byANTHROPIC_API_KEYbeing set in the environment — unrelated to this change.