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-sdkindexThreadStreamOptions
Interfaceā—Since v1.9

ThreadStreamOptions

Options for ThreadStream construction.

Copy
interface ThreadStreamOptions

Properties

property
assistantId: string
property
fetch: (input: URL | RequestInfo, init?: RequestInit) => Promise<Response>

Optional fetch override, forwarded to the SSE transport. Useful for auth proxies, Next.js route handlers, or tests with injected mocks. Ignored when webSocketFactory is also supplied.

property
maxReconnectAttempts: number

Maximum reconnect attempts after an unexpected SSE disconnect. Defaults to 5. Set to 0 to disable automatic reconnection.

property
onReconnect: (options: __type) => void

Called before each SSE reconnect attempt (after backoff delay).

property
reconnectDelayMs: (attempt: number) => number

Backoff before each SSE reconnect attempt. Defaults to webSocketReconnectDelayMs from ./websocket.js.

property
startingCommandId: number

Starting command ID for the internal command counter. Mostly useful for tests.

property
streamIdleReconnect: IdleReconnectMode

Built-in "sse" transport only: idle-reconnect policy guarding against half-open sockets that hang with no error or close (e.g. a platform revision rollover).

  • "auto" (default): arm only once the server's SSE keep-alive heartbeats are observed (LangGraph Platform emits : heartbeat every ~5s), sizing the window from their cadence. Independent of agent activity; stays dormant on heartbeat-less servers.
  • a number: a fixed idle window in milliseconds.
  • 0: disables it.
property
transport: ThreadStreamTransport

How this thread talks to the agent server. Accepts either a built-in transport string or a custom AgentServerAdapter:

  • "sse": HTTP commands + one SSE event stream per subscription.
  • "websocket": single bidirectional WebSocket.
  • an AgentServerAdapter: custom transport that replaces the built-in factories entirely. fetch / webSocketFactory are ignored in this mode.

Defaults to the client-level streamProtocol ("v2-websocket" → "websocket", otherwise "sse").

property
webSocketFactory: (url: string) => WebSocket

Optional WebSocket factory. Supplying it flips the adapter into WebSocket mode — SSE is bypassed entirely.

View source on GitHub