Session Event Streaming
Managed Agent sessions communicate through events rather than a single request and response. A client sends user or system events to a session, then observes session, span, and agent events that describe work as it is queued, processed, streamed, interrupted, or redirected. For SDK users, the important mental model is that a running session is a long-lived workflow with an event log, while streaming is the low-latency view of that log. This page explains how to read that stream, how deltas relate to accumulated state, and how the TypeScript SDK’s streaming surfaces and provider packages support the same event-oriented contract.
Sources: src/resources/beta/messages/index.ts, src/resources/messages/index.ts, packages/aws-sdk/src/core/streaming.ts, packages/bedrock-sdk/src/core/streaming.ts, packages/foundry-sdk/src/core/streaming.ts, packages/vertex-sdk/src/core/streaming.ts
Purpose and Scope
Use session event streaming when a Managed Agent task needs progress visibility before the final result is available. The official Managed Agents model distinguishes events you send from events you receive. User events such as a message start or steer agent work, system events can update session instructions, and returned session or agent events provide observability into status and progress. Stream-only preview events carry deltas, so consumers should treat the stream as both a notification channel and an incremental state feed rather than as a replacement for persisted session history.
This page is focused on the event stream pattern: sending events, consuming returned events, interpreting deltas, and accumulating partial output. It also relates Managed Agent streaming to the repository’s stable Messages streaming types because those generated exports show the SDK’s core vocabulary for raw stream events, content block deltas, message deltas, text deltas, signature deltas, and input JSON deltas. Managed Agent events use their own session-oriented domains, but developers benefit from the same discipline used for Messages streaming: handle start events, append deltas in order, finalize on stop events, and inspect stop or error conditions before continuing.
Core Event Model
A Managed Agent stream has directionality. The client sends user and system events into a session, while the service emits session, span, and agent events back to the client. Event names generally follow a domain and action convention, while stream-only delta preview events are named separately. Persisted events include server-side processing timestamps, and a null processing timestamp means the harness has queued the event behind earlier work. That detail matters operationally: a UI should distinguish accepted-but-waiting events from completed work, and automation should avoid assuming that a queued steering event has already changed the agent’s behavior.
When a stream opts into deltas, the consumer receives partial updates before the complete event is available. Deltas are useful for live transcript rendering, tool input display, progress indicators, and cancellation interfaces. They also introduce ordering and accumulation responsibilities. The safe pattern is to maintain an accumulator keyed by the event or content block being streamed, apply each delta in arrival order, and only expose durable state after the corresponding stop or completion signal. If the stream reports an error event, the accumulator should be marked incomplete and the application should fetch or reconcile persisted session state before resuming.
Source-to-Code Mapping
The TypeScript SDK exposes a broad generated Messages index for stable API streaming, including raw message stream events, raw content block start and stop events, raw content block delta events, message delta events, text deltas, input JSON deltas, citation deltas, and signature deltas. Those names provide the closest source-level reference for how this repository models incremental Claude output. The beta Messages index mirrors that generated style for beta features, with beta-prefixed content, tool, citation, compaction, fallback, and diagnostics types that are relevant when newer event shapes are exposed before becoming stable.
Provider packages keep the streaming contract usable outside the direct Anthropic API endpoint. The AWS platform, Foundry, and Vertex packages re-export the core SDK streaming module, so code written against the shared streaming abstractions can remain portable across those package entry points. Bedrock needs additional translation because AWS Bedrock returns a binary event stream rather than Anthropic-style server-sent events. Its streaming adapter decodes AWS event frames, parses Anthropic-shaped JSON payloads, emits named SSE frames when a payload has a type, and converts AWS exception frames into standard error events.
Delta Handling and Accumulation
For session event streaming, treat every delta as a patch, not as a complete event. Text deltas append text, JSON deltas extend structured input or output buffers, and higher-level message or event deltas update metadata such as usage, stop details, or progress state. The stable Messages exports demonstrate this vocabulary with raw stream events and specialized delta types, while the Managed Agent documentation applies the same idea to session and agent progress. A robust consumer should keep the raw event available for logging, update an accumulator for user-facing display, and finalize only after the matching stop signal arrives.
Accumulation must also account for refusals, interruptions, and provider errors. Claude streaming responses can end with a refusal stop reason, and the official guidance is to reset or rephrase the conversation context before continuing rather than blindly appending another turn. In Managed Agent sessions, the analogous principle is to inspect terminal events and stop reasons before sending follow-up events. If an interruption or redirect happens mid-execution, keep the partial accumulated state visible as provisional, then send the steering event through the session event API and wait for subsequent session events to confirm how the agent processed it.
Provider Streaming Behavior
Direct Anthropic, AWS platform, Foundry, and Vertex package users can rely on the shared core streaming exports surfaced by their package-specific streaming modules. That means application code should prefer SDK stream helpers and event iteration patterns instead of manually parsing provider responses whenever possible. The package wrappers exist to keep public imports stable while each provider handles its own authentication and transport differences elsewhere in the package. For event-streaming code, this supports a single consumer design: subscribe to events, branch on event type, accumulate deltas, handle errors, and close or reconcile on terminal events.
Bedrock is the important exception because it performs an explicit normalization step. The Bedrock streaming adapter preserves response status, status text, headers other than stream framing headers, and the wire URL, while rewriting the body to text event stream format. It drops frames that do not carry a type because there is no SSE event name for them, and it emits error events for recognized AWS exception frames. This behavior is useful for Managed Agent and Messages stream consumers because downstream code can process Anthropic-shaped SSE events even when the upstream provider used AWS binary framing.
Compact Reference
Use these names as the practical vocabulary for implementing a session stream consumer: user events and system events are outbound controls; session, span, and agent events are inbound observability records; event start and event delta records are stream-only incremental updates; processed timestamps describe server-side recording; null processed timestamps indicate queued work. In SDK code, look for raw stream events, content block start and stop events, content block delta events, message delta events, text deltas, input JSON deltas, citation deltas, and signature deltas when designing accumulation logic for Claude output.
A typical reader workflow is straightforward. First, create or resume the Managed Agent session using the beta Managed Agents APIs described elsewhere in this wiki. Second, send a user message event that represents the next instruction or task. Third, open or consume the event stream and update a local accumulator as deltas arrive. Fourth, render provisional output while preserving raw events for diagnostics. Fifth, wait for completion, interruption, refusal, or error events before deciding whether to send another user event, update the system prompt, redirect the session, or fetch persisted events for reconciliation.
Relevant Source Files
src/resources/beta/messages/index.ts: Re-exports the generated beta Messages resource and many beta-prefixed content, tool, citation, diagnostics, fallback, and streaming-adjacent types. It matters because Managed Agent features often live under beta surfaces, and the file shows how beta API shapes are collected for SDK consumers.src/resources/messages/index.ts: Re-exports the stable Messages resource, batch resource, and streaming event and delta types such as raw message stream events, raw content block events, message delta events, text deltas, input JSON deltas, signature deltas, and stop-related types. It provides the clearest repository evidence for the SDK’s delta and accumulation vocabulary.packages/aws-sdk/src/core/streaming.ts: Re-exports the shared core streaming module for the Anthropic AWS platform package. It matters because provider-specific packages preserve the same streaming import surface for consumers that target AWS-oriented deployments.packages/bedrock-sdk/src/core/streaming.ts: Implements Bedrock stream normalization by converting AWS binary event streams into Anthropic-style server-sent events, parsing JSON payloads, naming events from payload types, and emitting normalized error frames for AWS exceptions.packages/foundry-sdk/src/core/streaming.ts: Re-exports the shared core streaming module for the Microsoft Foundry package, keeping stream consumer code aligned with the main SDK abstractions.packages/vertex-sdk/src/core/streaming.ts: Re-exports the shared core streaming module for the Google Vertex package, supporting the same event and delta consumption model across Vertex-backed usage.
Troubleshooting and Next Steps
If a live session UI appears stuck, first check whether the latest persisted event has a null processing timestamp, because that indicates queued work rather than a completed turn. If output appears malformed, inspect whether deltas were applied out of order or finalized before a stop event. If provider-specific streaming fails only on Bedrock, review the normalization behavior and ensure downstream code expects SSE event names and JSON data frames. Next, read the Managed Agent Sessions page for session lifecycle, the Beta Sessions Reference for resource methods, and the Streaming Responses page for core Messages streaming patterns.