A team is implementing a streaming response handler in Python. They observe that occasionally an event arrives with event: 'error' and the stream terminates. The current code does not handle this event type and the application crashes. What is the complete set of SSE event types that a robust streaming handler must handle?
Select an answer to reveal the explanation.
Short Explanation and Infographic
Here's the deal — b is correct because the Anthropic streaming API emits all seven message lifecycle events plus an error event for API-level errors (such as context length exceeded mid-stream, or server errors). The error event carries a structured JSON body with error type and message.
Full explanation below image
Full Explanation
B is correct because the Anthropic streaming API emits all seven message lifecycle events plus an error event for API-level errors (such as context length exceeded mid-stream, or server errors). The error event carries a structured JSON body with error type and message. A robust handler must explicitly handle error events to log error details and gracefully terminate the stream rather than crashing on an unexpected event type. A is wrong because 'error' is documented as an SSE event type in the Anthropic streaming specification, not a client-side network exception; network exceptions are raised at the socket level and are distinct from SSE error events. C is wrong because the simplified four-event schema does not match the Anthropic API specification; the actual event taxonomy is more granular as described in option B. D is wrong because content_block_start and content_block_stop are present for all content blocks, not only when tool use is active; they bracket every text and thinking block in the stream.