LangChain Reference home pageLangChain ReferenceLangChain Reference
  • GitHub
  • Main Docs
Deep Agents
LangChain
LangGraph
Integrations
LangSmith
LangGraph
  • Web
  • Channels
  • Pregel
  • Prebuilt
  • Remote
  • Stream
LangGraph SDK
  • Ui
  • Client
  • Auth
  • React
  • Logging
  • React Ui
  • Utils
  • Server
  • Stream
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
WebChannelsPregelPrebuiltRemoteStream
LangGraph SDK
UiClientAuthReactLoggingReact UiUtilsServerStream
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 v1.8

CustomStreamOrchestrator

Framework-agnostic orchestrator for custom transport streams.

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

Copy
class CustomStreamOrchestrator

Constructors

constructor
constructor

Properties

property
messageManager: MessageTupleManager
property
stream: StreamManager<StateType, Bag>

Live byte stream.

Lazy: not materialised unless accessed. On first access the stream is seeded with every byte already accumulated (partialBytes) and then wired to future chunks. For URL-sourced blocks, first access triggers fetch() and pipes the response body through.

Repeated access returns the same ReadableStream reference — you can safely read it once, release the lock, and re-acquire a reader later (e.g. React StrictMode effect re-invokes). The standard ReadableStream.locked semantics prevent concurrent readers; use stream.tee() when you truly need multiple live consumers.

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: __type
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: InterruptPayload<unknown>[]

Interrupt payloads collected during the run, if any. Mirrors the in-process run.interrupts.

property
isLoading: boolean

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

property
messages: "messages"
property
streamValues: StateType | null
property
subagents: AsyncIterable<SubagentHandle>
property
toolCalls: AsyncIterable<ClientAssembledToolCall<string, unknown, unknown>>
property
values: "values"

Methods

method
dispose→ Promise<void>

Tear everything down.

Detaches the bound thread (so no further bind() calls reopen runtimes) and disposes every live runtime in parallel. Safe to call multiple times — subsequent calls find an empty registry and resolve immediately.

method
getMessagesMetadata→ MessageMetadata<StateType> | undefined

Retrieve stream-level metadata for a given message.

method
getSnapshot→ T
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→ Promise<void>

Disconnect the client from the active run and mark the controller idle. By default also cancels the run server-side; pass { cancel: false } or call disconnect to keep the agent running (join/rejoin).

method
submit→ Promise<void>

Submit input to the active thread.

To resume a pending interrupt, use respond instead.

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→ Promise<SubscriptionHandle<EventForChannel<TChannel>, YieldForChannel<TChannel>>>

Subscribe to raw wire channels and receive protocol events.

For assembled projections, use the lazy getters instead: thread.messages, thread.values, thread.toolCalls, thread.subgraphs, thread.subagents, thread.output.

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.

method
trackStreamMode

Custom transports do not negotiate stream modes with the server the way LangGraph Platform streams do, but framework adapters call this method on both orchestrator variants. Keep the API surface aligned as a no-op.

View source on GitHub