Open History to see the last commit
1---
2id: SubagentsBag
3title: SubagentsBag
4---
5
6Defined in: packages/ai/src/activities/chat/agents/spawn.ts:108
7
8## Type Parameters
9
10### TAgents
11
12`TAgents` *extends* `ReadonlyArray`\<[`DefinedAgent`](DefinedAgent.md)\> = `ReadonlyArray`\<[`DefinedAgent`](DefinedAgent.md)\>
13
14## Properties
15
16### agents
17
18```ts
19agents: TAgents;
20```
21
22Defined in: packages/ai/src/activities/chat/agents/spawn.ts:111
23
24***
25
26### binding?
27
28```ts
29optional binding?: SubagentBinding;
30```
31
32Defined in: packages/ai/src/activities/chat/agents/spawn.ts:129
33
34What a host adds to every activity call a child makes through `ctx`
35(`ctx.chat`, `ctx.generateImage`, and the rest). Apps do not set it.
36
37***
38
39### keys?
40
41```ts
42optional keys?: ProviderKeySource;
43```
44
45Defined in: packages/ai/src/activities/chat/agents/spawn.ts:145
46
47Provider keys that agents read as `ctx.keys`: an object by provider id,
48for example `{ openai: userKey }`, or a function that returns the key of
49a provider, for example `(provider) => getByokKey(request, provider)`.
50A missing or empty key falls back to the keys of the parent agent, then
51to the provider's `env` names. A child's `ctx.chat({ subagents })` passes
52them on. The keys it sets itself win for those providers.
53
54***
55
56### limits?
57
58```ts
59optional limits?: SubagentLimits;
60```
61
62Defined in: packages/ai/src/activities/chat/agents/spawn.ts:136
63
64Limits for the whole tree of children the model starts through tools:
65depth, total calls, children at once, and time per child. A refused
66start returns to the model as a tool error. Only the root chat's limits
67apply: a nested chat in a child uses the root's budget.
68
69***
70
71### order?
72
73```ts
74optional order?: "parallel" | "sequence";
75```
76
77Defined in: packages/ai/src/activities/chat/agents/spawn.ts:123
78
79How a router list runs. `parallel` starts every name together.
80`sequence` runs each name after the previous one finishes, and passes
81that child's text to the next child.
82
83***
84
85### router?
86
87```ts
88optional router?: (ctx) =>
89 | SubagentRouterPick
90| Promise<SubagentRouterPick>;
91```
92
93Defined in: packages/ai/src/activities/chat/agents/spawn.ts:112
94
95#### Parameters
96
97##### ctx
98
99###### abortSignal?
100
101`AbortSignal`
102
103###### agents
104
105`NoInfer`\<`TAgents`\>
106
107###### messages
108
109(
110 \| [`UIMessage`](UIMessage.md)\<`unknown`\>
111 \| [`ModelMessage`](ModelMessage.md)\<
112 \| `string`
113 \| [`ContentPart`](../type-aliases/ContentPart.md)\<`unknown`, `unknown`, `unknown`, `unknown`, `unknown`\>[]
114 \| `null`\>)[]
115
116#### Returns
117
118 \| [`SubagentRouterPick`](../type-aliases/SubagentRouterPick.md)
119 \| `Promise`\<[`SubagentRouterPick`](../type-aliases/SubagentRouterPick.md)\>
120
121***
122
123### sandbox?
124
125```ts
126optional sandbox?: "own" | "inherit";
127```
128
129Defined in: packages/ai/src/activities/chat/agents/spawn.ts:124
130
131***
132
133### strategy?
134
135```ts
136optional strategy?: "exclusive" | "handoff";
137```
138
139Defined in: packages/ai/src/activities/chat/agents/spawn.ts:117