Open History to see the last commit
1---
2id: runAgentStream
3title: runAgentStream
4---
5
6```ts
7function runAgentStream(
8 agent,
9 input,
10 sink?,
11 parentToolCallId?,
12binding?): AsyncIterable<AGUIEvent>;
13```
14
15Defined in: packages/ai/src/activities/chat/agents/spawn.ts:732
16
17Run one agent and stream its chunks, from `SUBAGENT_STARTED` to
18`SUBAGENT_FINISHED` or `SUBAGENT_ERROR`. The package root exports this
19as `runAgentStream`. The caller checks `ctx.input` against
20`agent.inputSchema` first. Pass `createSubagentSink()` to keep the
21child's interrupt objects and token usage. The finished event carries
22`interruptIds` only.
23
24## Parameters
25
26### agent
27
28[`DefinedAgent`](../interfaces/DefinedAgent.md)
29
30### input
31
32[`SubagentRunInput`](../interfaces/SubagentRunInput.md)
33
34### sink?
35
36[`SubagentSink`](../interfaces/SubagentSink.md)
37
38### parentToolCallId?
39
40`string`
41
42### binding?
43
44[`SubagentBinding`](../interfaces/SubagentBinding.md)
45
46## Returns
47
48`AsyncIterable`\<[`AGUIEvent`](../type-aliases/AGUIEvent.md)\>