Optionaloptions: SubagentManagerOptionsAdd a serialized message to a subagent from stream events.
This method handles the raw serialized message data from SSE events. Uses MessageTupleManager for proper chunk concatenation, matching how the main stream handles messages.
The namespace ID (pregel task ID) from the stream
The serialized message from the stream
Optionalmetadata: Record<string, unknown>Optional metadata from the stream event
Clear all subagent state.
Complete a subagent with a result.
Called when a tool message is received for the subagent.
The tool call ID of the subagent
The result content
The final status (complete or error)
Get all currently running subagents. Filters out incomplete/phantom subagents.
Get a specific subagent by tool call ID.
Get all subagents as a Map. Filters out incomplete/phantom subagents that lack subagent_type.
Get all subagents triggered by a specific AI message.
The ID of the AI message.
Array of subagent streams triggered by that message.
Get all subagents of a specific type.
Get the tool call ID for a given namespace ID. Returns the namespace ID itself if no mapping exists.
Check if any subagents are currently tracked.
Check if a tool call is a subagent invocation.
Mark a subagent as running and update its namespace.
Called when update events are received with a namespace indicating which subagent is streaming.
The tool call ID of the subagent
Optionaloptions: { namespace?: string[] }Additional update options
Mark a subagent as running using a namespace ID. Resolves the namespace ID to the actual tool call ID via the mapping.
The namespace ID (pregel task ID) from the subgraph
Optionalnamespace: string[]The full namespace array
Try to match a subgraph to a pending subagent by description. Creates a mapping from namespace ID to tool call ID if a match is found.
Uses a multi-pass matching strategy:
The namespace ID (pregel task ID) from the subgraph
The description from the subgraph's initial message
The matched tool call ID, or undefined if no match
Process a tool message to complete a subagent.
The tool call ID from the tool message
The result content
Whether the tool execution was successful
Reconstruct subagent state from historical messages.
This method parses an array of messages (typically from thread history) to identify subagent executions and their results. It's used to restore subagent state after:
The reconstruction process:
Note: Internal subagent messages (their streaming conversation) are not reconstructed since they are not persisted in the main thread state.
Array of messages from thread history
Optionaloptions: { skipIfPopulated?: boolean }Optional configuration
OptionalskipIfPopulated?: booleanIf true, skip reconstruction if subagents already exist
Register new subagent(s) from AI message tool calls.
Called when an AI message is received with tool calls. Creates pending subagent entries for each subagent tool call.
The tool calls from an AI message
OptionalaiMessageId: null | stringThe ID of the AI message that triggered the tool calls
Update subagent values from a values stream event.
Called when a values event is received from a subagent's namespace.
This populates the subagent's state values, making them accessible
via the values property.
The namespace ID (pregel task ID) from the stream
The state values from the stream event
Manages subagent execution state.
Tracks subagents from the moment they are invoked (AI message with tool calls) through streaming to completion (tool message result).