agent
agent_tool() exposes an agent tool for generic spawned helpers.
Constructor parameters configure spawned helpers and are not visible to the model:
model: Model[ModelResponse] | None = Nonemodel_args: dict[str, Any] | None = Noneoutput_schema: type[BaseModel] | OutputSchema[Any] | None = None
Model-facing call parameters (the arguments the model sets per call):
name: strtask: str
Permissions
agent does not issue a ToolPermissionRequest for the spawn itself. Spawned
helpers inherit the configured base tools and their permissions= /
approval_callback= through normal shim inheritance, so filesystem and bash
checks still happen inside the child when it uses those tools.
name must be one word. It can be task-relevant or random, and is used only
for logging and tracing. task is the full instruction for the helper,
including the context it needs and the expected output.
Example tool call:
{
"name": "Researcher",
"task": "Review the refund exception policy and return the two most relevant constraints."
}
agent is agent-as-tool, not handoff. The caller waits for the helper result
and then continues its own loop. The spawned helper treats the explicit task
as its assigned work, not the generated name. Generic spawned helpers do not
inherit the parent’s system prompt or conversation history.
Tool visibility has two inheritance paths that are easy to conflate:
- Direct descriptor tools are resolved through
AgentDescriptor.toolsandToolConfig. These are the tools inherited, replaced, or filtered byINHERIT_TOOLS,OVERRIDE_TOOLS, andRESTRICT_TOOLS.only(...). - Shim-contributed tools are added later by inherited descriptor shims during
prepare_turn(...). When the parent exposesbase_harness_tools(cwd=..., permissions=..., approval_callback=...)throughHarnessToolsShim, spawned helpers get those same configured base tools and prompt guidance through this shim path.
Inherited direct tools and shim-contributed tools are merged by tool name so duplicate definitions are exposed only once. Predefined handoffs are separate: the model sees them as schemas, but the runner handles them as control transfers rather than normal agent-as-tool calls.
Tool inheritance is controlled by the same ToolConfig policy used by
AgentDescriptor.tools:
INHERIT_TOOLSinherits parent tools and merges child-local additions.OVERRIDE_TOOLSignores parent tools; with no explicit tools it exposes no direct tools.RESTRICT_TOOLS.only(...)filters inherited parent tools by name and then merges child-local additions.- Bare
Tools(...)andNoneare compatibility shorthands for override behavior.
agent supports parallel calls when the parent Tools configuration enables
parallel_tool_calls. Recursive spawning is bounded by process-local
Runner safety limits: Runner(agent_max_depth=4, agent_max_threads=16).
agent_max_depth is inclusive: a direct child is depth 1, and the default
allows spawned agents through depth 4. These limits are execution policy, not
part of the tool schema. When the depth limit is reached, the tool result is:
Agent depth limit reached. Solve the task yourself.
When the live-agent thread limit is reached, the tool result is:
Agent thread limit reached. Solve the task yourself.