Orchestrator and workers
Read · 1 of 2
Agents as tools
For big jobs, an orchestrator splits the work and hands each piece to a worker. The neat trick: to the orchestrator, a worker is just a tool. Calling it runs a whole agent loop with its own tools and its own fresh context.
Workers run in parallel, keep the orchestrator's context small (it only sees their final answers), and can each be simple.
Read this lesson as text
An agent whose tool is another agent.
Agents as tools
For big jobs, an orchestrator splits the work and hands each piece to a worker. The neat trick: to the orchestrator, a worker is just a tool. Calling it runs a whole agent loop with its own tools and its own fresh context.
Workers run in parallel, keep the orchestrator's context small (it only sees their final answers), and can each be simple.
Exercise: A team of agents
Input: comma-separated cities. The boss model calls ask_worker(city) for each one at once. Each worker is its own agent that calls get_temp(city).
Write one function run_agent(brain, task, tools) that runs the loop for any brain and any tools (a dict of name → function), with failing tools returning ERROR …. Use it for the boss, and inside ask_worker for each worker. Print the boss's answer.