Streaming SSE and Recovery
atomic-noteD2 · 33.1%Section: D2 Applications & IntegrationUpdated 2026-11-15
Claude streaming emits named server-sent events. Render incrementally while assembling each typed content block by index, and never treat a partial stream as a validated final response.
Blueprint area: D2 - Applications and Integration MOC (official domain weight 33.1%).
Engineering principles
- Expect
message_start, zero or morecontent_block_start/delta/stop,message_delta, and finallymessage_stop;pingcan appear throughout. - Concatenate text deltas and partial tool-input JSON; parse a complete tool input once the relevant block is complete (or use SDK helpers).
- An error may arrive after HTTP 200 as an SSE event. Maintain explicit stream-failed vs stream-complete states.
- If the transport breaks, preserve partial output only as incomplete and decide whether the operation is safe to retry.
Failure modes
- Retrying after an action may duplicate an external side effect.
- Assuming each event holds a complete JSON value fails on partial deltas.
Check your understanding
- ☐ Simulate a disconnect mid-tool-input and verify no tool runs with incomplete JSON.
- ☐ Ensure UI receives a completion/error signal rather than hanging.
Related knowledge
Messages API Contract · Retries Timeouts and Idempotency · Exam Blueprint and Coverage
Evidence and verification
- Provenance: author-written engineering synthesis aligned to exam guide objectives; this is not a transcript or hidden Skilljar lesson.
- Primary references:
- Check currency: model options, pricing, API flags, release-specific behavior and runtime permissions can change after the source was read. See Source Register.