V2 persistent sessions should support `includePartialMessages` for streaming token output
Problem
The V2 session API (unstable_v2_resumeSession / unstable_v2_createSession) does not support streaming token output. When iterating session.stream(), only complete messages are yielded (system, assistant, result), never stream_event with content_block_delta / text_delta.
In contrast, the V1 query() API supports includePartialMessages: true which causes the CLI subprocess to emit incremental stream_event messages as tokens arrive from the Anthropic API.
Impact
This makes V2 sessions unsuitable for real-time display use cases (IM bots, streaming UIs) where users expect to see text appear progressively. The V2 path has excellent latency (no cold start), but the lack of streaming forces a trade-off: either use V2 (fast start, no streaming) or V1 (3-5s cold start, real streaming).
Requested Change
Add includePartialMessages?: boolean to SDKSessionOptions so V2 persistent sessions can yield SDKPartialAssistantMessage (stream_event) messages during response generation, just like V1's query() does.
The underlying capability already exists — the CLI subprocess receives streaming tokens from the Anthropic API internally. The V2 session mode just doesn't forward them to stdout.
Context
We're building an IM bridge (Feishu/Lark, Telegram, Discord) that connects Claude Code to messaging platforms. V2 sessions are ideal for persistent multi-turn conversations, but the lack of streaming means users see no output until the full response is ready (5-20 seconds of blank waiting).
With includePartialMessages support in V2, we'd get the best of both worlds: persistent session (no cold start) + real-time streaming output.
Environment
- Claude Code CLI: 2.1.87
- SDK: @anthropic-ai/claude-agent-sdk (latest)
- Platform: macOS
This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗