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* | unknown | |
interrupt_after* | unknown | |
control* | unknown | |
transformers | Sequence[Callable[[tuple[str, ...]], Any]] | None | Default: None |
**kwargs | Any | Default: {} |
Stream events from this graph.
For version="v1" / "v2", delegates to
Runnable.(a)stream_events; synchronous v1/v2 event streaming is
not implemented in langchain-core, so use astream_events for
those versions. 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.
Honored on every version that can run; type-checked
only on the version="v3" overloads.
Nodes to interrupt after, if any. Honored
on every version that can run; type-checked only on
the version="v3" overloads.
Optional run control used to request cooperative
drain. Honored on every version that can run;
type-checked only on the version="v3" overloads.
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" on astream_events,
forwarded to Runnable.astream_events, which passes
them through to astream — so execution kwargs such as
context, durability, interrupt_before,
interrupt_after and control are honored on every
version that can run. 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.