interface UseDeepAgentStreamOptionsOptions forwarded to the internal AsyncCaller, such as retry,
API key for authentication.
Base URL of the LangGraph API server.
Options forwarded to the internal AsyncCaller, such as retry,
LangGraph SDK client used to send requests and receive responses.
Headers applied to every request.
Whether to fetch the history of the thread.
Initial values to display immediately when loading a thread.
Specify the key within the state that contains messages.
Callback that is called when a checkpoints event is received.
Callback that is called when a new stream is created.
Callback that is called when a custom event is received.
Callback that is called when an error occurs.
Callback that is called when the stream is finished.
Callback that is called when a LangChain event is received.
Callback that is called when a metadata event is received.
Callback that is called when the stream is stopped by the user.
Callback that is called when a tasks event is received.
Callback that is called when the thread ID is updated (ie when a new thread is created).
Callback that is called when a tool lifecycle event is received.
Callback that is called when an update event is received.
Will reconnect the stream on mount
Manage the thread state externally.
Thread ID this transport is bound to.
Throttle the stream.
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),
});API key for authentication.
Base URL of the LangGraph API server.
Defaults to http://localhost:8123, unless the runtime provides a
langgraph_api:url global override.
Options forwarded to the internal AsyncCaller, such as retry,
concurrency, or custom fetch behavior.
LangGraph SDK client used to send requests and receive responses.
Headers applied to every request.
The configured API key, when present, is added as the x-api-key
header after these defaults are initialized.
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.
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.
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].messagesInitial 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.
Specify the key within the state that contains messages. Defaults to "messages".
Callback that is called when a new stream is created.
Callback that is called when a custom event is received.
Callback that is called when an error occurs.
Callback that is called when the stream is finished.
If you declare no parameters (side effects only), the SDK skips an extra
post-stream getHistory when branching history is disabled, so loading
ends as soon as the run stream completes.
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.
onStop: ({ mutate }) => {
mutate((prev) => ({
...prev,
ui: prev.ui?.map(component =>
component.props.isLoading
? { ...component, props: { ...component.props, stopped: true, isLoading: false }}
: component
)
}));
}Callback that is called when the thread ID is updated (ie when a new thread is created).
Will reconnect the stream on mount
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.
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 toolsManage the thread state externally.
Thread ID this transport is bound to.
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.
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.