LangChain Reference home pageLangChain ReferenceLangChain Reference
  • GitHub
  • Main Docs
Deep Agents
LangChain
LangGraph
Integrations
LangSmith
LangGraph
  • Web
  • Channels
  • Pregel
  • Prebuilt
  • Remote
  • Stream
  • Overview
  • Getting started
  • useStream
  • Selectors
  • Interrupts & headless tools
  • Subagents & subgraphs
  • Fork & edit from a checkpoint
  • Submission queue
  • Multimodal media
  • Transports
  • provideStream & context
  • Type safety
  • Migrating to v1
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
OverviewGetting starteduseStreamSelectorsInterrupts & headless toolsSubagents & subgraphsFork & edit from a checkpointSubmission queueMultimodal mediaTransportsprovideStream & contextType safetyMigrating to v1
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/svelteUseStreamReturn
Interface●Since v1.0

UseStreamReturn

Copy
interface UseStreamReturn

Properties

Methods

View source on GitHub
property
assistantId: string
property
client: Client
property
error: unknown
property
hydrationPromise: Promise<void>
property
interrupt: Interrupt<InterruptType> | undefined
property
interrupts: Interrupt<InterruptType>[]
property
isLoading: boolean
property
isThreadLoading: boolean
property
messages: BaseMessage<MessageStructure<MessageToolSet>, MessageType>[]
property
subagents: ReadonlyMap<keyof SubagentStates & string extends never ? string : keyof SubagentStates & string, SubagentDiscoverySnapshot>
property
subgraphs: ReadonlyMap<string, SubgraphDiscoverySnapshot>
property
subgraphsByNode: ReadonlyMap<string, readonly SubgraphDiscoverySnapshot[]>
property
threadId: string | null
property
toolCalls: InferToolCalls<T>[]
property
values: StateType
method
disconnect→ Promise<void>
method
getThread→ ThreadStream<Record<string, unknown>> | undefined
method
respond→ Promise<void>
method
respondAll→ Promise<void>
method
stop→ Promise<void>
method
submit→ Promise<void>

Svelte binding return type for useStream. Reactive projections are exposed as getters on a stable object so templates can read stream.messages directly without a .value / .current hop and $derived wrappers auto-track the getter read.

Destructuring (const { messages } = stream) breaks reactivity — this is a Svelte 5 constraint and applies to every getter-object pattern. Access fields through the live stream handle instead.

Assistant id the thread is bound to for its lifetime.

LangGraph SDK client used to construct thread streams.

The last error observed on the active run or hydration attempt. undefined when no error has occurred. Cleared optimistically when a new submit starts.

Promise that settles when the current thread's initial hydration completes. Useful in SvelteKit load() handlers (or any async-init site) to block until the controller has reconciled with server-held state. A fresh promise is installed on every threadId change.

Convenience alias for interrupts[0] — the primary interrupt most UIs should act on when only one is pending. undefined when no interrupt is active.

All unresolved protocol interrupts observed on the root namespace during the active thread. Populated from lifecycle / input events and seeded on hydration from thread.getState(). Cleared optimistically when a new run starts or an interrupt is resolved via respond.

true while a run is active or being started on the current thread. Driven by root-namespace lifecycle events (running → true, terminal phases → false). Use this to disable submit buttons and show in-flight spinners.

true while the initial thread.getState() hydration for the active thread is in flight. Distinct from isLoading — thread loading covers the one-time fetch that seeds values / messages before any user submit.

The root message projection. Assembled from two sources and merged in real time:

  1. messages-channel deltas — token-level streaming events (message-start, content-block-delta, message-finish) emitted by the runtime. These drive live, token-by-token updates.
  2. values.messages snapshots — the authoritative ordering and any messages the agent produces without token streaming (human turns, tool results, echoes from subagents).

If the backend only emits values events (no messages channel), every message will appear fully-formed on each values update rather than streaming. This is a backend/runtime concern — the Svelte layer faithfully renders whatever the server sends.

Equivalent to calling useMessages(stream) with no target.

Subagents discovered on the root run. For DeepAgent-typed streams the key set is narrowed to the subagent names declared on the agent brand (keyof InferSubagentStates<T>).

Subgraphs discovered on the root run.

A namespace is classified as a subgraph iff at least one strictly-deeper namespace has been observed with it as a prefix. This is inferred from the lifecycle event stream — plain function nodes (orchestrator, writer in the nested-stategraph example) never appear here even though the server emits namespaced lifecycle events for them. Promotion is monotonic and retroactive; an entry appears as soon as the first descendant event lands.

Subgraphs indexed by the graph node that produced them (addNode("visualizer_0", …)). Each value is an array because parallel fan-outs and loops can spawn multiple invocations of the same node; arrays preserve insertion order. Updates in lock-step with subgraphs.

Id of the thread the controller is bound to. null until the first submit creates or selects a thread (or until an explicit threadId option is provided and hydrated).

Root-namespace tool calls assembled from the tools channel. Each entry is a fully parsed AssembledToolCall with name, args, and id — suitable for rendering approval UIs or forwarding to headless tool handlers.

When the stream is typed with an agent brand or tool list, entries are narrowed via InferToolCalls. Equivalent to calling useToolCalls(stream) with no target.

The most recent values-channel snapshot emitted at the root namespace — i.e. the thread-level state as the server sees it after each superstep. Updated on every root values event, not on token-level deltas: if you render stream.values.messages directly you'll see full turns appear at once instead of streaming token-by-token. Use messages (or useMessages) for the token-streamed view.

Equivalent to calling useValues(stream).

Disconnect the client without cancelling the run server-side. Alias for stop({ cancel: false }).

Returns the bound ThreadStream, if one exists (undefined until the thread is hydrated or the first submit completes). Prefer the projections and selector composables for UI work; use this for low-level protocol access (raw subscriptions, state commands, etc.).

Resume a pending protocol interrupt by sending a response payload back to the interrupted namespace.

When options.interruptId is omitted, walks getThread()?.interrupts from newest to oldest and resumes the first not yet resolved by a prior respond() call. That may be a root or subgraph interrupt and is not necessarily interrupt (interrupts[0], root-only). Safe when exactly one interrupt is pending; otherwise pass an explicit options.interruptId (and options.namespace for subgraph interrupts).

The server validates namespace against the pending interrupt. Root interrupts use namespace: [] (default when omitted). For subgraph interrupts, copy namespace from getThread()?.interrupts.

Resume several pending interrupts at the same checkpoint in a single command — required when a run pauses on multiple interrupts at once (e.g. parallel tool-authorization prompts), which sequential respond calls cannot handle. responsesById maps each pending interruptId to its response, so different interrupts can receive different payloads. Pass options.config / options.metadata to fold run-level config and metadata into the resumed run, mirroring submit().

Stop the active run on the current thread. By default cancels the run server-side and disconnects the client; pass { cancel: false } or use disconnect for join/rejoin. Sets isLoading to false immediately; values and messages are preserved.

Dispatch a new run on the bound thread.

input is typed as Partial<StateType> so IDE autocompletion surfaces the state keys declared on the root composable.