LangChain Reference home pageLangChain ReferenceLangChain Reference
  • GitHub
  • Main Docs
Deep Agents
LangChain
LangGraph
Integrations
LangSmith
LangGraph
  • Web
  • Channels
  • Pregel
  • Prebuilt
  • Remote
React SDK
Vue SDK
Svelte SDK
Angular SDK
LangGraph SDK
  • Ui
  • Client
  • Auth
  • React
  • Logging
  • React Ui
  • Utils
  • Server
LangGraph Checkpoint
LangGraph Checkpoint MongoDB
LangGraph Checkpoint Postgres
  • Store
LangGraph Checkpoint Redis
  • Shallow
  • Store
LangGraph Checkpoint SQLite
LangGraph Checkpoint Validation
  • Cli
LangGraph API
LangGraph CLI
LangGraph CUA
  • Utils
LangGraph Supervisor
LangGraph Swarm
⌘I

LangChain Assistant

Ask a question to get started

Enter to send•Shift+Enter new line

Menu

LangGraph
WebChannelsPregelPrebuiltRemote
React SDK
Vue SDK
Svelte SDK
Angular SDK
LangGraph SDK
UiClientAuthReactLoggingReact UiUtilsServer
LangGraph Checkpoint
LangGraph Checkpoint MongoDB
LangGraph Checkpoint Postgres
Store
LangGraph Checkpoint Redis
ShallowStore
LangGraph Checkpoint SQLite
LangGraph Checkpoint Validation
Cli
LangGraph API
LangGraph CLI
LangGraph CUA
Utils
LangGraph Supervisor
LangGraph Swarm
Language
Theme
JavaScript@langchain/langgraph-sdkuiCustomStreamOrchestrator
Class●Since v2.0

CustomStreamOrchestrator

Copy
class CustomStreamOrchestrator

Constructors

Properties

Methods

View source on GitHub
constructor
constructor
property
messageManager: MessageTupleManager
property
stream: StreamManager<StateType, Bag>
property
activeSubagents: SubagentStreamInterface<SubagentStates[keyof SubagentStates], ToolCall, keyof SubagentStates & string>[]

Currently active subagents (where status === "running").

Use this to track and display subagents that are actively executing. Completed or errored subagents are not included.

Copy
// Show loading indicators for active subagents
stream.activeSubagents.map(subagent => (
  <SubagentCard
    key={subagent.id}
    type={subagent.toolCall.args.subagent_type}
    isLoading={true}
  />
));
property
branch: string

The current branch of the thread. Used for navigating between different conversation branches.

property
error: unknown

Last seen error from the stream, if any. Reset to undefined when a new stream starts.

property
interrupt: Interrupt<GetInterruptType<Bag>> | undefined

Current interrupt, if the stream is interrupted. Convenience alias for interrupts[0]. For workflows with multiple concurrent interrupts, use interrupts instead.

property
interrupts: Interrupt<GetInterruptType<Bag>>[]

All current interrupts from the stream. When using Send() fan-out with per-task interrupt() calls, multiple interrupts may be pending simultaneously.

property
isLoading: boolean

Whether the stream is currently running. true while streaming, false when idle or completed.

property
messages: Message<ToolCall>[]

Messages accumulated during the stream. Includes both human and AI messages. AI messages include typed tool calls based on the agent's tools.

property
streamValues: StateType | null
property
subagents: Map<string, SubagentStreamInterface<SubagentStates[keyof SubagentStates], ToolCall, keyof SubagentStates & string>>

All currently active and completed subagent streams.

Keyed by tool call ID for easy lookup. Includes subagents in all states: pending, running, complete, and error.

Copy
// Iterate over all subagents
stream.subagents.forEach((subagent, toolCallId) => {
  console.log(`Subagent ${toolCallId}: ${subagent.status}`);
});

// Get a specific subagent
const specific = stream.subagents.get("call_abc123");
property
toolCalls: ToolCallWithResult<ToolCall>[]

Tool calls paired with their results.

Each entry contains the tool call request and its corresponding result. Useful for rendering tool invocations and their outputs together.

Copy
stream.toolCalls.map(({ call, result }) => (
  <ToolCallCard
    name={call.name}
    args={call.args}
    result={result}
  />
));
property
values: StateType

The current state values of the stream. Updated as streaming events are received.

method
dispose

Tear down the orchestrator. Marks the instance as disposed, unsubscribes from the stream, and aborts any in-progress stream. After calling this method, no further notifications will be emitted.

method
getMessagesMetadata→ MessageMetadata<StateType> | undefined

Retrieve stream-level metadata for a given message.

method
getSnapshot→ number

Return the current version number, incremented on each state change. Useful as a cache key for external sync (e.g. useSyncExternalStore).

method
getSubagent→ SubagentStreamInterface<Record<string, unknown>, DefaultToolCall, string> | undefined

Look up a single subagent stream by its tool call ID.

method
getSubagentsByMessage→ SubagentStreamInterface<Record<string, unknown>, DefaultToolCall, string>[]

Retrieve all subagent streams associated with a specific AI message.

method
getSubagentsByType→ SubagentStreamInterface<Record<string, unknown>, DefaultToolCall, string>[]

Retrieve all subagent streams matching a given tool name / type.

method
getToolCalls→ ToolCallWithResult<DefaultToolCall>[]

Get tool calls (with results) that belong to a specific AI message.

method
reconstructSubagentsIfNeeded

Reconstruct subagent streams from history values when subagent filtering is enabled and the stream is not currently loading. This is a no-op if subagents are already populated.

method
setBranch

Update the current branch and notify listeners.

method
stop

Abort the current stream and invoke the onStop callback if one was provided in the options.

method
submit→ Promise<void>

Submit input values and start a new stream run.

Delegates to submitDirect. Override or wrap this method in framework adapters to add queuing or other middleware.

method
submitDirect→ Promise<void>

Start a new stream run against the custom transport.

This is the low-level submit entry point that handles thread ID resolution, optimistic value merging, and transport invocation. Prefer submit unless you need to bypass higher-level wrappers.

method
subscribe→ () => void

Register a listener that is called whenever the orchestrator state changes.

method
switchThread

Switch to a different thread. If the thread ID actually changed, the current stream is cleared and listeners are notified.

method
syncThreadId

Synchronize the external thread ID with the orchestrator. If the ID has changed, the current stream is cleared and listeners are notified.

Framework-agnostic orchestrator for custom transport streams.

Encapsulates all business logic shared across React, Vue, Svelte, and Angular for custom transport (non-LGP) streaming.