Class References
Function References
- text
- textOptions
- combineStrategies
- convertMessagesToModelMessages
- convertZodToJsonSchema
- createReplayStream
- embedding
- generateMessageId
- maxIterations
- messages
- modelMessageToUIMessage
- modelMessagesToUIMessages
- normalizeToUIMessage
- parsePartialJSON
- summarize
- toServerSentEventsStream
- toServerSentEventsResponse
- toolDefinition
- uiMessageToModelMessages
- realtimeToken
- untilFinishReason
Interface References
- AIAdapter
- AIAdapterConfig
- AgentLoopState
- AudioPart
- AudioVisualization
- BaseStreamChunk
- TextCompletionChunk
- TextOptions
- ChunkRecording
- ChunkStrategy
- ClientTool
- ContentPartSource
- ContentStreamChunk
- DefaultMessageMetadataByModality
- DocumentPart
- DoneStreamChunk
- EmbeddingOptions
- EmbeddingResult
- ErrorStreamChunk
- ImagePart
- InternalToolCallState
- JSONParser
- ModelMessage
- ProcessorResult
- ProcessorState
- RealtimeAdapter
- RealtimeClientOptions
- RealtimeConnection
- RealtimeMessage
- RealtimeSessionConfig
- RealtimeToken
- RealtimeTokenAdapter
- RealtimeTokenOptions
- ResponseFormat
- ServerTool
- StreamProcessorEvents
- StreamProcessorHandlers
- StreamProcessorOptions
- SummarizationOptions
- SummarizationResult
- TextPart
- ThinkingPart
- ThinkingStreamChunk
- Tool
- ToolCall
- ToolCallPart
- ToolCallStreamChunk
- ToolConfig
- ToolDefinition
- ToolDefinitionConfig
- ToolDefinitionInstance
- ToolInputAvailableStreamChunk
- ToolResultPart
- ToolResultStreamChunk
- UIMessage
- VideoPart
Type Alias References
- AgentLoopStrategy
- AnyClientTool
- TextStreamOptionsForModel
- TextStreamOptionsUnion
- ConstrainedContent
- ConstrainedModelMessage
- ContentPart
- ContentPartForModalities
- ExtractModalitiesForModel
- ExtractModelsFromAdapter
- InferToolInput
- InferToolName
- InferToolOutput
- MessagePart
- RealtimeEvent
- RealtimeMessagePart
- RealtimeMode
- RealtimeStatus
- ModalitiesArrayToUnion
- Modality
- StreamChunk
- ToolCallState
- ToolResultState
Variable References
SubagentBinding
Defined in: packages/ai/src/activities/chat/agents/bound.ts:117
Internal
What a host adds to every activity call an agent makes through ctx. Apps using plain chat({ subagents }) do not set it.
For hosts that run agents, such as @tanstack/ai-harness.
Properties#
budget?#
optional budget?: SubagentBudget;Defined in: packages/ai/src/activities/chat/agents/bound.ts:148
The subagent tree budget. A child's ctx.chat({ subagents }) passes it down, so limits hold across the whole tree.
chatMiddleware?#
optional chatMiddleware?: readonly AnyChatMiddleware[];Defined in: packages/ai/src/activities/chat/agents/bound.ts:122
Added before the call's own middleware on every ctx.chat call. A child's ctx.chat({ subagents }) passes it down to its own children.
debug?#
optional debug?: DebugOption;Defined in: packages/ai/src/activities/chat/agents/bound.ts:165
The debug option for the model calls of a child agent that set no debug of their own. A child's ctx.chat({ subagents }) passes it down to its own children.
extend?#
optional extend?: (ctx) => Partial<SubagentContextExtension>;Defined in: packages/ai/src/activities/chat/agents/bound.ts:170
Adds fields to the ctx of every run. A host declares their types by augmenting SubagentContextExtension. It passes down to nested children.
Parameters#
ctx#
Returns#
Partial<SubagentContextExtension>
generationMiddleware?#
optional generationMiddleware?: readonly GenerationMiddleware<unknown>[];Defined in: packages/ai/src/activities/chat/agents/bound.ts:134
Added before the call's own middleware on every generation call. A child's ctx.chat({ subagents }) passes it down to its own children.
interrupts?#
optional interrupts?: readonly InterruptDefinition<any, any, any, any, any>[];Defined in: packages/ai/src/activities/chat/agents/bound.ts:143
Interrupt definitions added to every ctx.chat call, so the host middleware in chatMiddleware can stop the child with them. The call's own interrupts (for example, the agent's own definitions) win: a host definition with the same id is not added. A child's ctx.chat({ subagents }) passes them down to its own children. A plain chat() call does not get them.
keys?#
optional keys?: ProviderKeys;Defined in: packages/ai/src/activities/chat/agents/bound.ts:154
The provider keys an agent reads as ctx.keys. subagents.keys sets them. A child's ctx.chat({ subagents }) passes them down to its own children. Without them, ctx.keys reads each provider's env names.
lastChatMiddleware?#
optional lastChatMiddleware?: readonly AnyChatMiddleware[];Defined in: packages/ai/src/activities/chat/agents/bound.ts:129
Added after the call's own middleware on every ctx.chat call, so it sees the final config and tool results (for example a host middleware that scrubs secrets or logs results). A child's ctx.chat({ subagents }) passes it down to its own children, after their own.
promptCache?#
optional promptCache?: PromptCacheRetention;Defined in: packages/ai/src/activities/chat/agents/bound.ts:159
The prompt cache retention of the parent call. A child's ctx.chat() uses it when the call gives no promptCache.
start?#
optional start?: (call, options) => Promise<{
done: Promise<unknown>;
subagentRunId: string;
}>;Defined in: packages/ai/src/activities/chat/agents/bound.ts:177
Starts a child without waiting for it and returns its id at once. The agent tools call it for background: true. With wake: true, the host starts a new parent turn when the child ends. It does not pass down to nested children.
Parameters#
call#
agent#
string
input?#
unknown
parentToolCallId?#
string
prompt?#
string
options#
wake#
true
Returns#
Promise<{ done: Promise<unknown>; subagentRunId: string; }>