Skip to main content
Use agent.as_tool(...) (Python) / agent.asTool(...) (TS) to wrap a specialist agent as a callable tool, then attach it to a coordinator. The coordinator decides when to delegate and to whom.

Coordinator + specialist

The sub-agent’s tool input is a single string (the prompt). Its output is { output, usage, iterations, ... }, which is captured in the coordinator’s result.meta.tool_calls.

Pipelines

Stack multiple specialists under one coordinator (researcher → writer → editor, etc.). The coordinator chooses the order based on its instructions. See 08_multi_agent for a three-agent editorial pipeline.

Tracing

When tracing is enabled (default), sub-agent calls appear as nested SubAgent spans under the coordinator’s run. You get the full tree, token usage, and timings for every agent in one place.