mirror of
https://github.com/langchain-ai/langgraph.git
synced 2026-08-25 09:02:25 +02:00
Adds a first-class `tools` stream mode with `tool-started` / `tool-output-delta` / `tool-finished` / `tool-error` events, exposed as `run.tool_calls` (an EventLog of ToolCallStream handles) through the new `ToolCallTransformer`. Tool authors call `langgraph.config.emit_tool_output_delta(chunk)` from inside a tool body to stream partial output; outside a tool call it is a silent no-op. `StreamTransformer` now declares `required_stream_modes`, and `GraphStreamer` computes the request set purely as the union of those declarations — no hardcoded base set. Built-in transformers (Values/Messages/Subgraph) migrated to the new scheme; raw channels like `custom` / `updates` / `checkpoints` / `tasks` / `debug` are opt-in via a transformer that declares them. Renames `StreamingHandler` → `GraphStreamer` (and file/test) and makes it subclassable: - `builtin_factories: ClassVar[tuple[TransformerFactory, ...]]` — extend to bundle default transformers (an `AgentStreamer` appends `ToolCallTransformer` here). - `_make_run_stream` / `_make_async_run_stream` — override to return a `GraphRunStream` / `AsyncGraphRunStream` subclass with typed accessors over the extra projections. Drops the now-redundant `values_transformer` arg from `GraphRunStream` / `AsyncGraphRunStream` constructors — `output` / `interrupted` / `interrupts` resolve the transformer lazily off the mux via a shared `BaseRunStream._values_transformer` property.