LangChain Reference home pageLangChain ReferenceLangChain Reference
  • GitHub
  • Main Docs
Deep Agents
LangChain
LangGraph
Integrations
LangSmith
LangGraph
  • Web
  • Channels
  • Pregel
  • Prebuilt
  • Remote
LangGraph SDK
  • Client
  • Auth
  • React
  • Logging
  • React Ui
  • 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
LangGraph SDK
ClientAuthReactLoggingReact UiServer
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-sdkreactUseDeepAgentStreamOptions
Interface●Since v1.6

UseDeepAgentStreamOptions

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.

Copy
interface UseDeepAgentStreamOptions

Bases

UseAgentStreamOptions<StateType, Bag>

Example

Copy
const stream = useStream<typeof agent>({
  assistantId: "deep-agent",
  apiUrl: "http://localhost:2024",

  // DeepAgent-specific options
  subagentToolNames: ["task", "delegate"],
  filterSubagentMessages: true,

  onError: (error) => console.error(error),
});

Properties

property
apiKey: string | null

API key for authentication.

  • If a string is provided, that key will be used
  • If undefined (default), the key will be auto-loaded from environment variables (LANGGRAPH_API_KEY, LANGSMITH_API_KEY, or LANGCHAIN_API_KEY)
  • If null, no API key will be set (skips auto-loading)
property
apiUrl: string
property
assistantId: string

The ID of the assistant to use.

property
callerOptions: AsyncCallerParams
property
client: Client<DefaultValues, DefaultValues, unknown>

LangGraph SDK client used to send requests and receive responses.

property
defaultHeaders: Record<string, HeaderValue>
property
fetchStateHistory: boolean | __type

Whether to fetch the history of the thread. If true, the history will be fetched from the server. Defaults to 10 entries. If false, only the last state will be fetched from the server.

property
filterSubagentMessages: boolean

Whether to filter out messages from subagent namespaces.

When true, only messages from the main agent are included in the messages array. Subagent messages are still accessible via the subagents map and individual subagent streams.

This is useful when you want to display subagent progress separately from the main conversation, or when subagent messages would be too verbose in the main message list.

Copy
const stream = useStream<typeof agent>({
  assistantId: "deep-agent",
  filterSubagentMessages: true,
});

// stream.messages only contains main agent messages
// Subagent messages are in stream.getSubagentsByType("researcher")[0].messages
property
initialValues: StateType | null

Initial values to display immediately when loading a thread. Useful for displaying cached thread data while official history loads. These values will be replaced when official thread data is fetched.

Note: UI components from initialValues will render immediately if they're predefined in LoadExternalComponent's components prop, providing instant cached UI display without server fetches.

property
messagesKey: string

Specify the key within the state that contains messages. Defaults to "messages".

property
onCheckpointEvent: (data: __type, options: __type) => void

Callback that is called when a checkpoints event is received.

property
onCreated: (run: RunCallbackMeta) => void

Callback that is called when a new stream is created.

property
onCustomEvent: (data: GetCustomEventType<Bag>, options: __type) => void

Callback that is called when a custom event is received.

property
onError: (error: unknown, run: RunCallbackMeta | undefined) => void

Callback that is called when an error occurs.

property
onFinish: (state: ThreadState<StateType>, run: RunCallbackMeta | undefined) => void

Callback that is called when the stream is finished.

property
onLangChainEvent: (data: __type) => void

Callback that is called when a LangChain event is received.

property
onMetadataEvent: (data: __type) => void

Callback that is called when a metadata event is received.

property
onStop: (options: __type) => void

Callback that is called when the stream is stopped by the user. Provides a mutate function to update the stream state immediately without requiring a server roundtrip.

Copy
onStop: ({ mutate }) => {
  mutate((prev) => ({
    ...prev,
    ui: prev.ui?.map(component =>
      component.props.isLoading
        ? { ...component, props: { ...component.props, stopped: true, isLoading: false }}
        : component
    )
  }));
}
property
onTaskEvent: (data: __type | __type | __type, options: __type) => void

Callback that is called when a tasks event is received.

property
onThreadId: (threadId: string) => void

Callback that is called when the thread ID is updated (ie when a new thread is created).

property
onUpdateEvent: (data: __type, options: __type) => void

Callback that is called when an update event is received.

property
reconnectOnMount: boolean | () => RunMetadataStorage

Will reconnect the stream on mount

property
subagentToolNames: string[]

Tool names that indicate subagent invocation.

When an AI message contains tool calls with these names, they are automatically tracked as subagent executions. This enables the subagents, activeSubagents, getSubagent(), getSubagentsByType(), and getSubagentsByMessage() properties on the stream.

Copy
const stream = useStream<typeof agent>({
  assistantId: "deep-agent",
  // Track both "task" and "delegate" as subagent tools
  subagentToolNames: ["task", "delegate", "spawn_agent"],
});

// Now stream.subagents will include executions from any of these tools
property
thread: UseStreamThread<StateType>

Manage the thread state externally.

property
threadId: string | null

The ID of the thread to fetch history and current values from.

property
throttle: number | boolean

Throttle the stream. If a number is provided, the stream will be throttled to the given number of milliseconds. If true, updates are batched in a single macrotask. If false, updates are not throttled or batched.

Inherited fromUseAgentStreamOptions

Properties

PapiKey: string | null
—

API key for authentication.

PapiUrl: stringPassistantId: string
—

The ID of the assistant to use.

PcallerOptions: AsyncCallerParamsPclient: Client
—

LangGraph SDK client used to send requests and receive responses.

PdefaultHeaders: Record<string, HeaderValue>PfetchStateHistory: boolean | __type
—

Whether to fetch the history of the thread.

PinitialValues: StateType | null
—

Initial values to display immediately when loading a thread.

PmessagesKey: string
—

Specify the key within the state that contains messages.

PonCheckpointEvent: (data: __type, options: __type)
—

Callback that is called when a checkpoints event is received.

PonCreated: (run: RunCallbackMeta)
—

Callback that is called when a new stream is created.

PonCustomEvent: (data: GetCustomEventType<Bag>, options: __type)
—

Callback that is called when a custom event is received.

PonError: (error: unknown, run: RunCallbackMeta | undefined)
—

Callback that is called when an error occurs.

PonFinish: (state: ThreadState<StateType>, run: RunCallbackMeta | undefined)
—

Callback that is called when the stream is finished.

PonLangChainEvent: (data: __type)
—

Callback that is called when a LangChain event is received.

PonMetadataEvent: (data: __type)
—

Callback that is called when a metadata event is received.

PonStop: (options: __type)
—

Callback that is called when the stream is stopped by the user.

PonTaskEvent: (data: __type | __type | __type, options: __type)
—

Callback that is called when a tasks event is received.

PonThreadId: (threadId: string)
—

Callback that is called when the thread ID is updated (ie when a new thread is created).

PonUpdateEvent: (data: __type, options: __type)
—

Callback that is called when an update event is received.

PreconnectOnMount: boolean | ()
—

Will reconnect the stream on mount

Pthread: UseStreamThread<StateType>
—

Manage the thread state externally.

PthreadId: string | null
—

The ID of the thread to fetch history and current values from.

Pthrottle: number | boolean
—

Throttle the stream.

Inherited fromUseStreamOptions

Properties

PapiKey: string | null
—

API key for authentication.

PapiUrl: stringPassistantId: string
—

The ID of the assistant to use.

PcallerOptions: AsyncCallerParamsPclient: Client
—

LangGraph SDK client used to send requests and receive responses.

PdefaultHeaders: Record<string, HeaderValue>PfetchStateHistory: boolean | __type
—

Whether to fetch the history of the thread.

PinitialValues: StateType | null
—

Initial values to display immediately when loading a thread.

PmessagesKey: string
—

Specify the key within the state that contains messages.

PonCheckpointEvent: (data: __type, options: __type)
—

Callback that is called when a checkpoints event is received.

PonCreated: (run: RunCallbackMeta)
—

Callback that is called when a new stream is created.

PonCustomEvent: (data: GetCustomEventType<Bag>, options: __type)
—

Callback that is called when a custom event is received.

PonError: (error: unknown, run: RunCallbackMeta | undefined)
—

Callback that is called when an error occurs.

PonFinish: (state: ThreadState<StateType>, run: RunCallbackMeta | undefined)
—

Callback that is called when the stream is finished.

PonLangChainEvent: (data: __type)
—

Callback that is called when a LangChain event is received.

PonMetadataEvent: (data: __type)
—

Callback that is called when a metadata event is received.

PonStop: (options: __type)
—

Callback that is called when the stream is stopped by the user.

PonTaskEvent: (data: __type | __type | __type, options: __type)
—

Callback that is called when a tasks event is received.

PonThreadId: (threadId: string)
—

Callback that is called when the thread ID is updated (ie when a new thread is created).

PonUpdateEvent: (data: __type, options: __type)
—

Callback that is called when an update event is received.

PreconnectOnMount: boolean | ()
—

Will reconnect the stream on mount

Pthread: UseStreamThread<StateType>
—

Manage the thread state externally.

PthreadId: string | null
—

The ID of the thread to fetch history and current values from.

Pthrottle: number | boolean
—

Throttle the stream.

View source on GitHub