- Stream subagent progress:在每个 subagent parallel 运行时 tracking execution。
- Stream LLM tokens:stream main agent 和每个 subagent 的 tokens。
- Stream tool calls:查看 subagent execution 内的 tool calls 和 results。
- Stream custom updates:从 subagent nodes 内 emit user-defined signals。
Enable subgraph streaming
Deep Agents 使用 LangGraph subgraph streaming 暴露来自 subagent execution 的 events。若要接收 subagent events,请在 streaming 时启用stream_subgraphs。
Namespaces
启用subgraphs 后,每个 streaming event 都会包含一个 namespace,用于标识是哪个 agent 生成了它。Namespace 是 node names 和 task IDs 组成的 path,表示 agent hierarchy。
| Namespace | Source |
|---|---|
() (empty) | Main agent |
("tools:abc123",) | Main agent 的 task tool call abc123 生成的 subagent |
("tools:abc123", "model_request:def456") | Subagent 内部的 model request node |
Subagent progress
使用stream_mode="updates" 在每个 step 完成时 tracking subagent progress。这适合展示哪些 subagents 处于 active 状态,以及它们已完成哪些工作。
Output
LLM tokens
使用stream_mode="messages" stream main agent 和 subagents 的 individual tokens。每个 message event 都包含标识 source agent 的 metadata。
Tool calls
当 subagents 使用 tools 时,你可以 stream tool call events 来显示每个 subagent 正在做什么。Tool call chunks 会出现在messages stream mode 中。
Custom updates
在 subagent tools 内使用get_stream_writer emit custom progress events:
Output
Stream multiple modes
组合多个 stream modes,以获得 agent execution 的完整 picture:Common patterns
Track subagent lifecycle
监控 subagents 何时 start、run 和 complete:v2 streaming format
需要 LangGraph >= 1.1。
version="v2"),这是推荐方法。每个 chunk 都是包含 type、ns 和 data keys 的 StreamPart dict,无论 stream mode、mode 数量或 subgraph settings 如何,shape 都相同。
V2 format 消除了 nested tuple unpacking,让在 Deep Agents 中处理 subgraph streaming 更直接。比较两种 formats:
Related
- Subagents:在 Deep Agents 中 configure 和 use subagents
- Frontend streaming:使用
useStream为 Deep Agents 构建 React UIs - LangChain Event Streaming:LangChain agents 的 general streaming concepts
Connect these docs to Claude, VSCode, and more via MCP for real-time answers.

