In short.
This Claude Agent SDK guide helps developers build live agent interfaces, but applications must reconstruct streamed output and distinguish tool-input completion from tool execution. It explains partial-message options, event types, complete-block messages and interrupted streams in Python and TypeScript. Subagent token deltas are excluded, and structured-output fragments remain unvalidated until the final result. No code was executed; performance and runtime reliability were not assessed.
Researched and written by an AI model and checked by a second AI model. How it works
Covers the complete page at [https://code.claude.com/docs/en/agent-sdk/streaming-output.md], including streaming options, event references, message ordering, cut-off streams, tool-input streaming, UI examples, structured-output limitations and version notices. Linked pages and the documentation index are excluded. No examples were executed; runtime behavior, compatibility, performance and costs remain unassessed.
The overview
Identity
Stream responses in real-time is a Claude Agent SDK documentation page at [https://code.claude.com/docs/en/agent-sdk/streaming-output.md]. It combines a practical tutorial with an event reference for receiving incremental text and tool-call input in Python and TypeScript.
Assessment
The guide is useful for developers adding visible progress to chat interfaces or multi-step agent applications. Its strongest material is the precise relationship between incremental events, completed content blocks and final results, including what can be missing when a stream ends early.
The examples provide concrete starting points for event handling. They do not establish production reliability, measured response latency or compatibility with a particular application, and none was executed.
Users
The intended readers are Python and TypeScript developers integrating Claude agents into applications, especially interfaces that need to display text before a content block finishes or show which tool the agent is preparing to call.
Beginners should understand asynchronous iteration, message-type checks and JSON fragments before adapting the examples. Experienced developers will find details about event ordering, message identifiers, interrupted streams and structured-output validation.
Capabilities
The page demonstrates printing text chunks as they arrive, detecting the start of a tool call, accumulating its JSON input and displaying tool-related status messages. It includes equivalent Python and TypeScript examples.
Its event reference covers message start and stop, content-block start and stop, incremental content updates and message-level updates such as usage and stop reasons. Complete AssistantMessage blocks and the final ResultMessage remain available when partial streaming is enabled.
Using it
Requirements
The Python examples import query and ClaudeAgentOptions from claude_agent_sdk, with StreamEvent from claude_agent_sdk.types. TypeScript imports query from @anthropic-ai/claude-agent-sdk. Both examples use asynchronous iteration over messages.
The examples configure allowed tools such as Read, Bash and Grep. Installation, authentication, supported language-runtime versions, operating-system requirements and the broader permission setup are not explained on this page.
Mechanism
Partial streaming adds messages containing raw Claude API events. Python represents them as StreamEvent; TypeScript uses SDKPartialAssistantMessage with type stream_event. Text arrives in content_block_delta events whose delta.type is text_delta. These events contain fragments rather than accumulated text, so the application must assemble them.
Each non-empty content block also produces an AssistantMessage before its content_block_stop event. A text block and a tool-use block therefore produce separate complete messages sharing one message ID, available as message.message.id in TypeScript and message.message_id in Python. The documented sequence places tool execution after message_stop, with ResultMessage arriving when the overall work finishes.
Setup
Set include_partial_messages=True in Python or includePartialMessages: true in TypeScript. In the message loop, first identify the streaming wrapper, then inspect its event field, then filter content_block_delta events for text_delta before displaying delta.text.
For tool input, detect a tool_use block in content_block_start, record its name and accumulate partial_json from input_json_delta events. Keep handling complete messages and final results separately because enabling partial output does not remove them.
Example
The tool-streaming example asks the agent to read README.md, records the tool name and appends incoming JSON fragments to a string. The combined UI example asks it to find TODO comments, prints a tool-name indicator and streams text outside tool-call blocks. These are documented examples; neither was executed.
The UI example prints done when content_block_stop arrives. Because the documented message flow places tool execution later, that label marks completion of the streamed call input; it does not establish that the tool executed successfully.
Assessment & evidence
Limitations
Streaming events cover the main session only. Subagent token deltas are not forwarded, and parent_tool_use_id is always None in Python or null in TypeScript for these events. Complete messages carry the parent identifier needed for subagent attribution. Python StreamEvent also lacks the user_message_uuid field described for TypeScript.
Structured output arrives as unvalidated input_json_delta fragments; only the final ResultMessage.structured_output contains the validated result. Applications should not treat intermediate JSON as validated structured data.
For cut-off streams, the page says message_stop still arrives, but content_block_stop can be missing for an open tool call and message_delta can be absent after a dropped connection or non-streaming fallback. An open tool call's input must be treated as incomplete.
Reasoning
This guide fits applications where showing text and tool preparation incrementally is valuable enough to justify additional event-handling state. The documented tradeoff is direct access to fragments in exchange for assembling output and managing completion correctly.
Because completed AssistantMessage blocks still arrive alongside partial events, an implementation should reconcile the two representations. Otherwise, displaying both as new text could duplicate output. This is an implementation inference from the documented message flow, not an observed test result.
Alternatives
The directly documented alternative is to leave partial streaming disabled and consume AssistantMessage objects as each non-empty content block completes, followed by the final result. That reduces the need to assemble fragments when block-level updates are sufficient.
The page links separate guides for CLI streaming and sending messages to a running agent. Their implementation details are outside this page. It provides no comparison with other SDKs or streaming frameworks.
Evidence
The evidence consists of the complete documentation page at [https://code.claude.com/docs/en/agent-sdk/streaming-output.md], including its reference material and Python and TypeScript examples. Its captured source revision is sha256:355c4b90fa6b286dd1ed7f94e08cfbcfc750e8616a7615d0e119a63e10a66309.
The page supports descriptions of the documented interface and behavior. No code was executed, linked documentation was not supplied, and there are no independent benchmark or runtime results in the evidence.
Access & freshness
Costs
The page supplies no model prices, SDK fees, subscription requirements or worked usage costs. The cost of running its examples and any effect of partial streaming on billing are unknown from this evidence.
Rights
The supplied page contains no explicit licence or redistribution terms for its text or code examples. Rights to redistribute the documentation or reuse its snippets are unknown from this evidence. The SDK packages' licences are also not established here.
Freshness
The page was captured on 2026-11-23 at 16:46:38.050 UTC. It provides no publication or last-updated date.
It states that Claude Code versions before v2.1.290 could end a cut stream without message_stop. It identifies TypeScript Agent SDK v0.3.290 and Python Agent SDK v0.2.164 as the starting versions bundling Claude Code v2.1.290 or later. These are documented thresholds for that fix; the latest available SDK versions are unknown from this page.
Actions
First decide whether incremental fragments are necessary or complete content blocks provide enough feedback. For partial output, confirm the SDK version, enable the appropriate option and implement separate handling for text deltas, tool-input fragments, completed blocks and the final result.
Before relying on an interface built from these examples, verify interruption handling, incomplete tool input, duplicate-text prevention and the distinction between input completion and execution success. Use the final structured result for validated JSON. Resolve installation, authentication, pricing and reuse terms through their applicable documentation; this page does not establish them.
