API Reference
AgentAsToolOptions
type AgentAsToolOptions = Omit<RunAgentOptions, "prompt" | "sessionId" | "memory" | "signal"> & {
description: string;
inputDescription?: string;
memory?: Memory;
name: string;
resultFrom?: (result) => string;
run?: RunFn;
sessionId?: string;
};Defined in: tools/agent-as-tool.ts:59
Options for agentAsTool.
Type Declaration
| Name | Type | Description | Defined in |
|---|---|---|---|
description | string | What this sub-agent is for — tells the parent model when to call it. | tools/agent-as-tool.ts:66 |
inputDescription? | string | Describes the task argument to the parent model. Has a sensible default. | tools/agent-as-tool.ts:80 |
memory? | Memory | Backing store for the child run. Default: a fresh SessionMemoryStore created per call, which is what makes each call context-isolated. Supply one (with a stable sessionId) to give the sub-agent memory that persists across calls. | tools/agent-as-tool.ts:73 |
name | string | Model-facing tool name (keep it snake_case), e.g. "researcher". | tools/agent-as-tool.ts:64 |
resultFrom()? | (result) => string | How to turn the child RunResult into the tool-result text. Default: the last assistant message's text (falling back to a clear placeholder when the run produced none). | tools/agent-as-tool.ts:86 |
run? | RunFn | Override how the child run executes (for tests). Default runAgent. | tools/agent-as-tool.ts:88 |
sessionId? | string | Session key for the child run. Default: `${name}:${toolCallId}` — unique per call, so invocations stay isolated and each is traceable to its call. | tools/agent-as-tool.ts:78 |
Remarks
Reuses the run contract: everything runAgent needs except the fields
the tool controls — prompt (the model's task), sessionId and memory (the
isolation defaults), and signal (forwarded from the tool-call context). So
model is required, and system / tools / maxSteps / stopWhen / hooks
/ toolExecution / onEvent configure the child run. Mirrors the
Omit<RunAgentOptions, …> "RunBase" shape used by runGoal and the dispatcher.