Skip to content

fix: pass unknown SSE event types through stream instead of dropping silently#1363

Closed
atishay2 wants to merge 1 commit intoanthropics:mainfrom
atishay2:fix/streaming-silent-event-drop
Closed

fix: pass unknown SSE event types through stream instead of dropping silently#1363
atishay2 wants to merge 1 commit intoanthropics:mainfrom
atishay2:fix/streaming-silent-event-drop

Conversation

@atishay2
Copy link
Copy Markdown

Fixes #1357

Problem

Stream.__stream__() and AsyncStream.__stream__() used separate if statements with no else
clause. Any SSE event not in the hardcoded list (message_start, message_delta, etc.) was silently
dropped.

This broke client.beta.sessions.events.stream() entirely — managed agents emit event types like
agent.message, session.status_running, agent.tool_use which don't match the Messages API event
names.

Fix

Converted the if/if/if/if chain to if/elif/elif/elif/else in both the sync and async __stream__()
methods. The else clause passes unrecognized event types through process_data() for discriminated
union parsing.

Testing

Existing test suite passes (2230 passed). The 5 test_aws.py failures are pre-existing and caused by
ANTHROPIC_API_KEY being set in the environment — unrelated to this change.

…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
@atishay2 atishay2 requested a review from a team as a code owner April 12, 2026 03:57
@localden
Copy link
Copy Markdown
Collaborator

Thank you for the PR - this was already addressed on main - see src/anthropic/_streaming.py:100. Closing as resolved.

@localden localden closed this Apr 28, 2026
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.

[BUG] Managed Agents: client.beta.sessions.events.stream() silently drops all events

2 participants