The whole hunk
from line 71, old and new numbered
/
lines
from line 71
7171
7272When partial messages are enabled, you receive raw Claude API streaming events wrapped in an object. The type has different names in each SDK:
7373
74* **Python**: `StreamEvent` (import from `claude_agent_sdk.types`)
75* **TypeScript**: `SDKPartialAssistantMessage` with `type: 'stream_event'`
74* **Python**: [`StreamEvent`](/docs/en/agent-sdk/python#streamevent) (import from `claude_agent_sdk.types`)
75* **TypeScript**: [`SDKPartialAssistantMessage`](/docs/en/agent-sdk/typescript#sdkpartialassistantmessage) with `type: 'stream_event'`
7676
77Both contain raw Claude API events, not accumulated text. You need to extract and accumulate text deltas yourself. Here's the structure of each type:
78
79<CodeGroup>
80 ```python Python theme={null}
81 @dataclass
82 class StreamEvent:
83 uuid: str # Unique identifier for this event
84 session_id: str # Session identifier
85 event: dict[str, Any] # The raw Claude API stream event
86 parent_tool_use_id: str | None # Always None
87 ```
88
89 ```typescript TypeScript theme={null}
90 type SDKPartialAssistantMessage = {
91 type: "stream_event";
92 event: BetaRawMessageStreamEvent; // From Anthropic SDK
93 parent_tool_use_id: string | null;
94 uuid: UUID;
95 session_id: string;
96 ttft_ms?: number; // Time to first token in ms, present only on message_start events
97 user_message_uuid?: string;
98 };
99 ```
100</CodeGroup>
77Both contain raw Claude API events, not accumulated text. You need to extract and accumulate text deltas yourself.
10178
10279The `parent_tool_use_id` field is always `None` in Python and `null` in TypeScript. Stream events are emitted for the main session only; token-level deltas from subagents aren't forwarded. To attribute output to a subagent, use complete messages, which carry `parent_tool_use_id`. See [Detect subagent invocation](/docs/en/agent-sdk/subagents#detect-subagent-invocation).
10380