The API key to use.
The URL of the API to use.
The ID of the assistant to use.
Custom call options, such as custom fetch implementation.
Client used to send requests.
Default headers to send with requests.
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.
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.
Specify the key within the state that contains messages. Defaults to "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.
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 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. Provides a mutate function to update the stream state immediately without requiring a server roundtrip.
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 for headless tool lifecycle events.
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.
The ID of the thread to fetch history and current values from.
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.
Headless tool implementations to execute locally when the agent interrupts
with a schema-only tool({ ... }) call from LangChain.
onStop: ({ mutate }) => {
mutate((prev) => ({
...prev,
ui: prev.ui?.map(component =>
component.props.isLoading
? { ...component, props: { ...component.props, stopped: true, isLoading: false }}
: component
)
}));
}