| name | streaming-cast |
| description | Implements LangGraph v3 event streaming for graphs with subgraphs and agents. Use when adding streaming to runtime/API endpoint, need token streaming, custom stream projections, subagent streaming, or ask "add streaming", "stream tokens", "stream graph". |
| version | 2026.05.27 |
| author | Proact0 |
| allowed-tools | ["Read","Write","Edit","AskUserQuestion"] |
Streaming {{ cookiecutter.act_name }}'s Casts (v3)
Implement v3 event streaming to consume {{ cookiecutter.cast_snake }}_graph() output in runtime, API endpoints, or other consumers. Event streaming returns a run stream object with typed projections (stream.messages, stream.values, stream.subgraphs, stream.output, stream.tool_calls, ...) for independent consumption.
When to Use
- Adding streaming output to a runtime or API endpoint
- Need token-by-token LLM output, tool call lifecycle, or final output streaming
- Custom progress events from nodes via stream writer (with custom transformers)
- Subagent/subgraph projection for source identification
- Transport integration (SSE recommended, WebSocket optional)
When NOT to Use
- Building graph structure (nodes, edges, state) →
developing-cast
- DeepAgent harness (create_deep_agent, backends) →
developing-deepagent
- Architecture design →
architecting-act
- Testing →
testing-cast
Quick Start
casts/{{ cookiecutter.cast_snake }}/modules/ and casts/{{ cookiecutter.cast_snake }}/graph.py are reserved for graph definition. Stream consumer code lives anywhere else — pick the entry point that fits the project (an additional module within the cast such as runtime.py, an external API endpoint module, a script, or a test).
from langchain_core.messages import HumanMessage
from casts.{{ cookiecutter.cast_snake }}.graph import {{ cookiecutter.cast_snake }}_graph
graph = {{ cookiecutter.cast_snake }}_graph()
config = {
"configurable": {
"actor_id": "user-123",
"thread_id": "session-1",
},
"recursion_limit": 2000,
}
stream = await graph.astream_events(
{"messages": [HumanMessage(content="hello")]},
config=config,
version="v3",
)
async for message in stream.messages:
async for token in message.text:
print(token, end="", flush=True)
final_state = await stream.output
Implementation Workflow
- Choose projection(s) for the use case (see table below).
- Open the event stream with
stream_events() (sync) or astream_events() (async).
- Consume projections — token, reasoning, tool-call argument chunks, tool execution lifecycle, subgraph/subagent handles.
- Filter by
subgraph.graph_name or subagent.name when multi-source attribution is needed.
- Wire to transport (SSE recommended; WebSocket optional).
| Goal | Projection |
|---|
| LLM token-by-token output | stream.messages → message.text |
| LLM reasoning deltas | stream.messages → message.reasoning |
| Tool-call argument chunks (LLM-side) | stream.messages → message.tool_calls |
| Tool execution lifecycle | stream.tool_calls |
| Per-step state snapshots | stream.values |
| Final state only | stream.output |
| Nested subgraph/agent | stream.subgraphs |
| Deep Agent delegated task | stream.subagents |
| Custom transformer projections | stream.extensions["<name>"] |
| HITL interrupts | stream.interrupts / stream.interrupted |
| Raw protocol events | iterate the stream object |
Multiple projections are consumed concurrently via asyncio.gather (async) or stream.interleave(...) (sync). Each projection iterator independently reads from the underlying event stream.
Component Reference
Core Concepts
Stream Consumption
Subgraph & Subagent
Patterns
Verification