ExperimentalThe agent's state type
Tool call type from agent's tools
Map of subagent names to their state types
Type configuration bag
ExperimentalactiveCurrently active subagents (where status === "running").
Use this to track and display subagents that are actively executing. Completed or errored subagents are not included.
The ID of the assistant to use.
The current branch of the thread. Used for navigating between different conversation branches.
LangGraph SDK client used to send requests and receive responses.
Last seen error from the stream, if any.
Reset to undefined when a new stream starts.
Experimentalexperimental_Tree of all branches for the thread. This API is experimental and subject to change.
Get the metadata for a message, such as first thread state the message was seen in and branch information.
The metadata for the message, or undefined if not found
ExperimentalgetGet subagent stream by tool call ID.
Use this when you have a specific tool call ID and need to access its corresponding subagent stream.
The tool call ID that initiated the subagent
The subagent stream, or undefined if not found
ExperimentalgetGet all subagents triggered by a specific AI message.
Useful for rendering subagent activities grouped by conversation turn. Each AI message that contains subagent tool calls will have its triggered subagents returned by this method.
The ID of the AI message that triggered the subagents
Array of subagent streams triggered by that message
ExperimentalgetGet all subagents of a specific type.
Returns streams with properly inferred state types based on subagent name. When called with a literal string that matches a subagent name, TypeScript will infer the correct state type for that subagent.
Overload for known subagent names - returns typed streams. TypeScript infers the state type from SubagentStates[TName].
Overload for unknown names - returns untyped streams. Used when the subagent name is not known at compile time.
// Get all researcher subagents with typed state
const researchers = stream.getSubagentsByType("researcher");
researchers.forEach(researcher => {
// researcher.values is typed based on ResearchMiddleware
console.log("Research messages:", researcher.values.messages.length);
console.log("Status:", researcher.status);
});
// Get all writer subagents
const writers = stream.getSubagentsByType("writer");
// writers have different state type based on WriterMiddleware
ExperimentalgetGet tool calls for a specific AI message.
Use this to find which tool calls were initiated by a particular assistant message, useful for rendering tool calls inline with messages.
Array of tool calls initiated by the message
Flattened history of thread states of a thread. Contains all states in the current branch's history.
Current interrupt, if the stream is interrupted.
Convenience alias for interrupts[0].
For workflows with multiple concurrent interrupts, use interrupts instead.
All current interrupts from the stream. When using Send() fan-out with per-task interrupt() calls, multiple interrupts may be pending simultaneously.
Whether the stream is currently running.
true while streaming, false when idle or completed.
Whether the thread is currently being loaded.
true during initial thread data fetch.
Join an active stream that's already running.
The ID of the run to join
OptionallastEventId: stringOptional last event ID for resuming from a specific point
Optionaloptions: {Optional configuration for the stream
Messages accumulated during the stream. Includes both human and AI messages. AI messages include typed tool calls based on the agent's tools.
Set the branch of the thread.
The branch identifier to switch to
Stops the currently running stream.
A promise that resolves when the stream is stopped.
ExperimentalsubagentsAll currently active and completed subagent streams.
Keyed by tool call ID for easy lookup. Includes subagents in all states: pending, running, complete, and error.
Create and stream a run to the thread.
ExperimentaltoolTool calls paired with their results.
Each entry contains the tool call request and its corresponding result. Useful for rendering tool invocations and their outputs together.
The current state values of the stream. Updated as streaming events are received.
Stream interface for DeepAgent instances created with
createDeepAgent.Extends UseAgentStream with subagent streaming capabilities. Subagent streams are automatically typed based on the agent's subagent configuration, enabling type-safe access to subagent state and messages.
Use this interface when streaming from an agent created with
createDeepAgentthat orchestrates multiple specialized subagents.This interface is subject to change.
Example
Remarks
This interface adds subagent streaming on top of UseAgentStream:
subagents- Map of all subagent streams by tool call IDactiveSubagents- Array of currently running subagentsgetSubagent(id)- Get a specific subagent by tool call IDgetSubagentsByType(type)- Get all subagents of a specific type with typed stategetSubagentsByMessage(messageId)- Get all subagents triggered by a specific AI messageIt also enables the
filterSubagentMessagesoption to exclude subagent messages from the mainmessagesarray.