AgentAsToolOptions
type AgentAsToolOptions =
| AgentAsToolIdentity & {
agent: Agent;
}
| AgentAsToolIdentity & Omit<RunAgentOptions, "prompt" | "sessionId" | "memory" | "signal"> & {
agent?: undefined;
memory?: Memory;
run?: RunFn;
};Defined in: tools/agent-as-tool.ts:90
Options for agentAsTool — two mutually exclusive forms.
Config form 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.
Agent form takes one self-contained Agent value instead. The
agent closes over its own model and memory, so per-call context isolation
becomes the agent's concern: an agent whose memory persists will remember
across calls (each call still gets a distinct default sessionId, so
isolation holds unless you also pin AgentAsToolIdentity.sessionId).