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
defineAgent
function defineAgent<TName, TTools, TSchema, TInterrupts, TInput, TResult, TProduces>(agent): DefinedAgent<TName, TTools, TSchema, TInterrupts, TInput, TResult, TProduces>;Defined in: packages/ai/src/activities/chat/agents/define-agent.ts:180
Define a named child agent. Pass the same object to chat({ subagents }). Pass the agents array to useChat({ subagents }) when you render parts yourself. The hook uses it for types only. It does not call run.
Type Parameters#
TName#
TName extends string
TTools#
TTools extends readonly SubagentTool[] = readonly []
TSchema#
TSchema extends SchemaInput | undefined = undefined
TInterrupts#
TInterrupts extends readonly InterruptDefinition<any, any, any, any, any>[] = readonly []
TInput#
TInput extends SchemaInput | undefined = undefined
TResult#
TResult = unknown
TProduces#
TProduces extends AgentProduces | undefined = undefined
Parameters#
agent#
DefinedAgent<TName, TTools, TSchema, TInterrupts, TInput, TResult, TProduces>
Returns#
DefinedAgent<TName, TTools, TSchema, TInterrupts, TInput, TResult, TProduces>
Example#
const researcher = defineAgent({
name: 'researcher',
description: 'Looks up facts',
run: (ctx) =>
chat({
adapter: openaiText('gpt-6.1-sol'),
messages: ctx.messages,
threadId: ctx.threadId,
runId: ctx.runId,
parentRunId: ctx.parentRunId,
subagentRunId: ctx.subagentRunId,
resume: ctx.resume,
}),
})