stream_events(
self,
input: InputT | Command | None,
config: RunnableConfig | Name | Type | Description |
|---|---|---|
input* | InputT | Command | None | Graph input. |
config | RunnableConfig | None | Default: NoneOptional runnable config. |
version | Literal['v1', 'v2', 'v3'] | Default: 'v2' |
interrupt_before | All | Sequence[str] | None | Default: None |
interrupt_after | All | Sequence[str] | None | Default: None |
control | RunControl | None | Default: None |
transformers | Sequence[Callable[[tuple[str, ...]], Any]] | None | Default: None |
**kwargs | Any | Default: {} |
Stream events from this graph.
For version="v1" / "v2", yields StreamEvent dicts (see
Runnable.stream_events). For version="v3", returns a
GraphRunStream whose typed projections the caller drives by
iterating — no background thread.
The version="v3" API is experimental and may change.
Builds a StreamMux from the built-in transformers, this
graph's compile-time stream_transformers, and any additional
transformers= supplied at the call site. run.output,
run.interrupted, and run.interrupts work regardless of
which transformers are registered.
Note:
Nesting v1 stream(stream_mode="messages") inside a node
of a stream_events(version="v3") run is not fully
supported. The outer v3 messages handler reroutes
BaseChatModel.invoke through the v2 event protocol, so
the inner v1 handler does not see on_llm_new_token
chunks. The inner stream still yields a finalized message
via on_llm_end. Use stream_events(version="v3") for the
inner graph as well, or call chat_model.stream(...)
explicitly, to get token-level streaming.
Streaming-event schema version. "v3" selects the
content-block-centric streaming protocol.
Nodes to interrupt before, if any. Only
used for version="v3".
Nodes to interrupt after, if any. Only
used for version="v3".
Optional run control used to request cooperative
drain. Only used for version="v3".
Extra transformer classes or configured
factories appended after compile-time
stream_transformers. Factories are called as
factory(scope) so they can propagate to subgraph
scopes. Only used for version="v3".
For version="v1"/"v2", forwarded to
Runnable.stream_events. For version="v3", forwarded
to the underlying stream(...) call (e.g. context,
durability, output_keys, print_mode, debug).
stream_mode and subgraphs are not accepted under
version="v3" and raise TypeError if supplied; v3
owns them.