function subagentRoute<TAgents>(agents, options?): object;Defined in: packages/ai/src/activities/chat/agents/route.ts:94
Build decide() questions for a subagent router.
One yes/no question per agent, plus an order choice. pick returns main, one name, { names, order }, or { steps }. Names follow the agents array order. { names, order } overrides subagents.order for that turn. then: agents that run after the other selected agents. The lead group starts together. The then agents then run one after another in list order, and each reads the text so far. Used only when the router picks at least one agent from each group. Otherwise pick returns { names, order }.
An agent with inputSchema needs input. needsInput(result) lists the picked agents that need it, with their schemas. Make each input, then pass them as pick(result, { inputs }). Each name with an input becomes { name, input }. pick throws when a picked agent with a schema has no input.
TAgents extends readonly DefinedAgent<string, readonly SubagentTool[], SchemaInput | undefined, readonly InterruptDefinition<any, any, any, any, any>[], any>[]
TAgents
SubagentRouteOptions<TAgents>
needsInput: (result) => InputNeed<TAgents[number]>[];The picked agents that have an inputSchema, in agent-list order. Make an input for each one and pass it to pick in inputs.
RouteAnswers<TAgents>
InputNeed<TAgents[number]>[]
pick: (result, pickOptions?) => SubagentRouterPick;RouteAnswers<TAgents>
RoutePickOptions<TAgents>
questions: RouteQuestions<TAgents>;const route = subagentRoute(agents)
const result = await decide({ adapter, state, questions: route.questions })
const inputs = { pricer: { sku: 'A-1' } }
return route.pick(result, { inputs })