Skip to content
Source
Sign inSign up
TanStack/ai
Open History to see the last commit

DefinedAgent.md

181 lines4.9 KB

Defined in: packages/ai/src/activities/chat/agents/define-agent.ts:112

A named child agent. run is a chat() call (or any stream of AG-UI chunks), or a promise of a plain value such as an image result. A chat({ stream: false }) result counts as its text. TTools and TSchema stay on the object so useChat({ subagents }) can type that child's parts. TResult is the value a promise run resolves to.

Extends

  • SubagentInfo

Type Parameters

TName

TName extends string = string

TTools

TTools extends ReadonlyArray<SubagentTool> = ReadonlyArray<SubagentTool>

TSchema

TSchema extends SchemaInput | undefined = SchemaInput | undefined

TInterrupts

TInterrupts extends ReadonlyArray<InterruptDefinition<any, any, any, any>> = ReadonlyArray<InterruptDefinition<any, any, any, any>>

TInput

TInput extends SchemaInput | undefined = any

TResult

TResult = unknown

TProduces

TProduces extends AgentProduces | undefined = AgentProduces | undefined

Properties

description

description: string;

Defined in: packages/ai/src/activities/chat/agents/define-agent.ts:124

Required here: the router and the synthetic tool both read it.

Overrides

AGUISubagentInfo.description

inputSchema?

optional inputSchema?: TInput;

Defined in: packages/ai/src/activities/chat/agents/define-agent.ts:144

The input this agent needs, such as a short brief. run reads it as ctx.input, and the client card as part.subagent.input. In tool mode, the parent model writes it when it calls this agent's tool. Without it, the tool takes a text prompt. When the run uses sessionId or background, that name is reserved. A subagents.router gives it in its pick as { name, input }. The input is checked against this schema first. A router can start this agent only when the schema is a Standard Schema, such as a zod schema. A plain JSON Schema works in tool mode only. A turn with a router input cannot resume after an interrupt.


interrupts?

optional interrupts?: TInterrupts;

Defined in: packages/ai/src/activities/chat/agents/define-agent.ts:146


name

name: TName;

Defined in: packages/ai/src/activities/chat/agents/define-agent.ts:122

Unique name or identifier of the subagent.

Overrides

AGUISubagentInfo.name

outputSchema?

optional outputSchema?: TSchema;

Defined in: packages/ai/src/activities/chat/agents/define-agent.ts:147


produces?

optional produces?: TProduces;

Defined in: packages/ai/src/activities/chat/agents/define-agent.ts:132

What this agent makes. See AgentProduces.


run

run: (ctx) => 
  | AsyncIterable<AGUIEvent, any, any>
  | Promise<AsyncIterable<AGUIEvent, any, any>>
| Promise<TResult>;

Defined in: packages/ai/src/activities/chat/agents/define-agent.ts:125

Parameters

ctx

SubagentRunContext<TInput>

Returns

| AsyncIterable<AGUIEvent, any, any> | Promise<AsyncIterable<AGUIEvent, any, any>> | Promise<TResult>


subagents?

optional subagents?: unknown;

Defined in: packages/ai/src/activities/chat/agents/define-agent.ts:148


tools?

optional tools?: TTools;

Defined in: packages/ai/src/activities/chat/agents/define-agent.ts:145