import { ... } from "@langchain/langgraph-sdk";Strip headless-tool interrupts from a user-facing interrupt list.
Execute and resume all newly seen headless-tool interrupts from a values
payload. Callers own handledIds and should clear it when the thread changes.
Get the API key from the environment. Precedence:
Overrides the fetch implementation used for LangSmith calls. You should use this if you need to use an implementation of fetch other than the default global (e.g. for dealing with proxies).
Parses a headless-tool interrupt value from the graph. Accepts both
toolCall (LangChain JS) and tool_call (Python / JSON snake_case).
Public v1 name for TransportAdapter plus optional high-level
capabilities. Renamed to reflect that this interface now denotes the
full agent-server protocol contract (not merely wire transport):
any object that satisfies it can back a useStream call. See
plan-custom-transport.md §4 for the rollout.
The extra optional methods let adapters surface thread state and
history without the framework needing to issue a parallel HTTP
request — useStream.hydrate() calls getState?() when present
and falls back to client.threads.getState otherwise. Adapters
that don't know how to produce these values can simply omit them.
The legacy TransportAdapter export is retained for back-compat and
resolves to the same structural type; new code should prefer
AgentServerAdapter.
Typed error thrown through media.stream / rejected from
media.blob / media.objectURL when a handle fails before its
message completes. Carries the bytes accumulated up to the failure
point on partialBytes for callers that want to salvage or diagnose.
Incrementally assembles messages events into complete message objects.
Error wrapper for protocol-level error responses returned by the server.
Transport adapter that speaks the thread-centric protocol over HTTP
commands plus SSE event streams. Bound to a specific threadId
at construction. Each openEventStream call opens an independent
filtered SSE connection via POST /threads/:thread_id/stream/events.
Transport adapter that speaks the thread-centric protocol over a
bidirectional WebSocket. Bound to a specific threadId — the socket
connects to ws://.../threads/:thread_id/stream/events.
Async iterable handle for raw event subscriptions.
An optional transform maps each incoming event before it is queued
or delivered to a waiting consumer. This is used by named custom
channel subscriptions (e.g. "custom:a2a") to unwrap the payload
so callers receive the raw emitted data instead of the protocol
event envelope.
High-level wrapper around a protocol connection to a specific thread.
In the thread-centric protocol, threads are durable (backed by
checkpoints) and connections are ephemeral. A ThreadStream is the
client-side handle for interacting with a thread: starting runs,
subscribing to events, consuming assembled projections (messages,
values, toolCalls, etc.), and responding to interrupts.
Construct via client.threads.stream(threadId?, { assistantId? }).
Public v1 name for TransportAdapter plus optional high-level
capabilities. Renamed to reflect that this interface now denotes the
full agent-server protocol contract (not merely wire transport):
any object that satisfies it can back a useStream call. See
plan-custom-transport.md §4 for the rollout.
The extra optional methods let adapters surface thread state and
history without the framework needing to issue a parallel HTTP
request — useStream.hydrate() calls getState?() when present
and falls back to client.threads.getState otherwise. Adapters
that don't know how to produce these values can simply omit them.
The legacy TransportAdapter export is retained for back-compat and
resolves to the same structural type; new code should prefer
AgentServerAdapter.
Mutable view of a streamed message as message and content-block events are assembled into a single structure.
Shared surface across every media handle returned by MediaAssembler.
The handle is live while its parent message is active:
partialBytes is a snapshot of all bytes received so far.stream is a lazy, single-consumer byte stream (see
accessor docstring).blob / objectURL settle on message-finish.error becomes set if the handle terminates in any of the
MediaAssemblyErrorKind failure modes.Base stream interface shared by all stream types.
Contains core properties for state management, messaging, and stream control that are common to CompiledStateGraph, ReactAgent, and DeepAgent streams.
This interface provides the foundation that all stream types build upon:
values, isLoading, error)messages)interrupt)submit, stop)branch, history)Configuration for BaseClient and the exported LangGraph SDK Client.
Shared surface across every media handle returned by MediaAssembler.
The handle is live while its parent message is active:
partialBytes is a snapshot of all bytes received so far.stream is a lazy, single-consumer byte stream (see
accessor docstring).blob / objectURL settle on message-finish.error becomes set if the handle terminates in any of the
MediaAssemblyErrorKind failure modes.Client-side implementation returned by headlessTool.implement(...).
Represents a headless tool interrupt payload emitted by LangChain's
schema-only tool({ ... }) overload.
Servers may serialize the nested tool call as toolCall (JS) or
tool_call (Python). Use parseHeadlessToolInterruptPayload to
normalize either shape before reading fields.
Shared surface across every media handle returned by MediaAssembler.
The handle is live while its parent message is active:
partialBytes is a snapshot of all bytes received so far.stream is a lazy, single-consumer byte stream (see
accessor docstring).blob / objectURL settle on message-finish.error becomes set if the handle terminates in any of the
MediaAssemblyErrorKind failure modes.An interrupt thrown inside a thread.
Dispatch callbacks receive a freshly-started handle on its first
matching content-block-start. Exactly one callback fires per
(messageId, blockType) pair.
Dispatch callbacks receive a freshly-started handle on its first
matching content-block-start. Exactly one callback fires per
(messageId, blockType) pair.
Shared surface across every media handle returned by MediaAssembler.
The handle is live while its parent message is active:
partialBytes is a snapshot of all bytes received so far.stream is a lazy, single-consumer byte stream (see
accessor docstring).blob / objectURL settle on message-finish.error becomes set if the handle terminates in any of the
MediaAssemblyErrorKind failure modes.Remote counterpart of an in-process run.extensions.<name> projection.
Each extension is the client-side view of a compile-time
StreamTransformer projection. The server auto-forwards named
StreamChannel.remote(name) outputs on the custom:<name> channel, and
this handle exposes them via two dual interfaces:
AsyncIterable<T> — iterate every item pushed by a streaming
transformer (e.g. a StreamChannel).PromiseLike<T> — await resolves with the final value observed
when the run terminates. For streaming transformers this is the
last item pushed; for final-value transformers it is the single
value emitted on run end.Subscribing is lazy: the underlying custom:<name> subscription is
opened on first property access and cached.
Options for ThreadStream construction.
Transport abstraction implemented by concrete client transports such as WebSocket or SSE adapters.
In the thread-centric protocol, transports are bound to a specific thread at construction time — the thread ID is part of the connection URL.
Stream interface for ReactAgent instances created with createAgent.
Extends UseGraphStream with tool calling capabilities. Tool calls are automatically typed based on the agent's tools configuration.
Use this interface when streaming from an agent created with createAgent.
For subagent streaming capabilities, use UseDeepAgentStream with createDeepAgent.
This interface is subject to change.
Options for configuring an agent stream.
Use this options interface when calling useStream with a ReactAgent
created via createAgent.
This interface is subject to change.
Stream interface for DeepAgent instances created with createDeepAgent.
Extends UseAgentStream with subagent streaming capabilities. Subagent streams are automatically typed based on the agent's subagent configuration, enabling type-safe access to subagent state and messages.
Use this interface when streaming from an agent created with createDeepAgent
that orchestrates multiple specialized subagents.
This interface is subject to change.
Options for configuring a deep agent stream.
Use this options interface when calling useStream with a DeepAgent
created via createDeepAgent. Includes all agent options plus
subagent-specific configuration.
Shared surface across every media handle returned by MediaAssembler.
The handle is live while its parent message is active:
partialBytes is a snapshot of all bytes received so far.stream is a lazy, single-consumer byte stream (see
accessor docstring).blob / objectURL settle on message-finish.error becomes set if the handle terminates in any of the
MediaAssemblyErrorKind failure modes.AI message type that can be parameterized with custom tool call types.
Template for the bag type.
Streaming custom data from inside the nodes.
Stream event with detailed debug information.
Default tool call type when no specific tool definitions are provided.
Stream event with error information.
Stream event with events occurring during execution.
Stream event with a feedback key to signed URL map. Set feedbackKeys in
the RunsStreamPayload to receive this event.
Infer the Bag type from an agent, defaulting to the provided Bag.
Currently returns the provided Bag for all types. Can be extended in the future to extract Bag from agent types.
Infer the node names from a compiled graph.
Extracts the ~NodeType phantom property from CompiledGraph instances,
providing a union of all node names defined in the graph.
Infer the per-node return types from a compiled graph.
Extracts the ~NodeReturnType phantom property from CompiledGraph instances,
which is a mapped type of { [nodeName]: ReturnType } for each node.
Infer the state type from an agent, graph, or direct state type.
Detection order:
~agentTypes) → InferAgentState~RunOutput) → Extract RunOutput~OutputType) → Extract OutputTypeInfer subagent state map from a DeepAgent.
For DeepAgent, creates a map of subagent names to their state types. For non-DeepAgent, returns DefaultSubagentStates.
Infer tool call types from an agent.
For agents, extracts typed tool calls from the agent's tools. For non-agents, returns DefaultToolCall.
Infer the successful return type of a LangChain tool.
Resolution order mirrors InferToolInput: func, then
invoke, then _call, so inference survives cross-package
boundaries where _call is protected.
Kinds of failure that can terminate a media handle prematurely.
"message-error" — the upstream message emitted an error event
before completion."stream-closed" — the transport stream closed before
message-finish arrived (thread closed, transport dropped, etc.)."fetch-failed" — the block was url-sourced and the lazy
fetch() rejected (CORS, 404, 5xx, network).Block types this assembler knows how to reassemble into media handles.
Union of all message types.
Stream event with message chunks coming from LLM invocations inside nodes.
Metadata stream event with information about the run and thread
Resolves the appropriate stream interface based on the agent/graph type.
This type automatically selects the correct stream interface based on
the type of agent or graph passed to useStream:
DeepAgent (~deepAgentTypes) → UseDeepAgentStream
ReactAgent (~agentTypes) → UseAgentStream
CompiledGraph / Default → BaseStream
Resolves the appropriate options interface based on the agent/graph type.
This type automatically selects the correct options interface based on the type of agent or graph:
DeepAgent → UseDeepAgentStreamOptions
filterSubagentMessages optionReactAgent → UseAgentStreamOptions
CompiledGraph / Default → UseGraphStreamOptions
import type { SubgraphCheckpointsStreamEvent } from "./types.stream.subgraph.js";
Keyed map of ThreadExtension handles, typed off a declared transformer projection shape.
Used as the return type of ThreadStream.extensions. TExtensions
is expected to match the in-process run.extensions shape (i.e. the
output of InferExtensions<TTransformers> from
@langchain/langgraph); each value type is unwrapped via
UnwrapExtension so thread.extensions.foo resolves with the
transformer's emitted payload, not the in-process Promise<T> /
StreamChannel<T> wrapper.
Access any string key to obtain a ThreadExtension<unknown>; keys
that appear in TExtensions narrow to their declared payload type.
Infer a tool call type from a single tool.
Works with tools created via tool() from @langchain/core/tools.
For DynamicStructuredTool, this extracts the input type from the _call method, which is the most reliable source as it's the pre-computed input type.
Infer a union of tool call types from an array of tools.
Works with tools created via tool() from @langchain/core/tools.
The lifecycle state of a tool call.
pending: Tool call received, awaiting resultcompleted: Tool execution finished successfullyerror: Tool execution failed (result.status === "error")Represents a tool call paired with its result. Useful for rendering tool invocations and their outputs together.
Unwrap a single in-process projection value to its observable payload type:
Promise<T> / PromiseLike<T> → T (final-value transformers)StreamChannel<T> / AsyncIterable<T> → T (streaming transformers)This lets a ThreadStream<TExtensions> generic accept the same shape
that graph.streamEvents(..., { version: "v3" }) returns in-process
(via InferExtensions<TTransformers> from @langchain/langgraph),
without forcing users to redeclare payload types on the remote side.
Stream event with updates to the state after each step. The streamed outputs include the name of the node that produced the update as well as the update.
Stream event with values after completion of each step.
Message stream event specific to LangGraph Server.