Supervisor and worker agents: a runnable example
What you get: A Supervisor agent with two worker agents, each with its own chat model and MCP tools, that runs on a fresh install.
Needs: No API key · Nodes: 11
A Supervisor node coordinates two worker agents. The researcher has an MCP knowledge-base lookup tool; the computer has a calculator and a clock. The Supervisor sees each worker as one tool and decides which to call for each step, and each worker runs its own agent loop. Every agent uses the built-in echo provider and the mock MCP server built into L2M, so it runs with no API key. Echo never asks for a tool, so a local run shows the wiring, not the delegation: the Supervisor answers on its first turn and hands nothing off. Attach a real chat model to see it delegate.
Steps
- Download supervisor-worker-swarm-flow.json, or take it from the samples folder on GitHub.
- In the studio's workflow editor, import the file (see import and export).
- Click Run in the editor, or call the run API with a question for the team (as in the zero-key agent recipe, with the workflow id
wf-supervisor-worker-swarm). - Open the run and click the Supervisor node to read its trace.
- Then change one thing at a time (see below).
How it works
| Node | Type | Role |
|---|---|---|
| Manual Trigger | manual_trigger | Step in the run |
| Supervisor | supervisor_node | Step in the run |
| Output | output | Step in the run |
| Supervisor Chat Model (echo) | llm_call | Attached to Supervisor on its chat_model port |
| Worker: Researcher | agent_orchestrator | Attached to Supervisor on its worker port |
| Researcher Chat (echo) | llm_call | Attached to Worker: Researcher on its chat_model port |
| MCP: lookup_kb | mcp_tool | Attached to Worker: Researcher on its tool port |
| Worker: Computer | agent_orchestrator | Attached to Supervisor on its worker port |
| Computer Chat (echo) | llm_call | Attached to Worker: Computer on its chat_model port |
| MCP: calculator | mcp_tool | Attached to Worker: Computer on its tool port |
| MCP: get_current_time | mcp_tool | Attached to Worker: Computer on its tool port |
6 node types. Each type links to its config fields in the node reference.
What a run does
We ran the sample on a fresh install with "What is 17% of 2340, and what does MCP stand for?":
- The Supervisor made one model call and stopped after 1 iteration with
stopReason: "final_answer". Echo answeredSupervisor: What is 17% of 2340, and what does MCP stand for?. - Both workers, their chat models and their tools are marked skipped (
attachment_only_node). Workers are not steps in the run: they run only when the Supervisor calls them, and echo never did.
The Supervisor is offered one tool per worker, named delegate_to_ plus the worker's name with every character other than letters, digits, _ and - turned into _: here delegate_to_Worker__Researcher and delegate_to_Worker__Computer. Each tool's description starts with "Delegate task to" and the worker's name, followed by the start of the worker's system prompt as a hint. Name workers so the Supervisor's model can tell them apart; two workers with the same name make the run fail.
See delegation in a recorded run
The demo's Research swarm workflow is the same pattern with a researcher and an analyst, recorded with a scripted stand-in model, so it shows the delegation without a key. In its run the Supervisor calls delegate_to_researcher, then delegate_to_analyst, then writes the team summary: three iterations. Play it in the demo.
Make it yours
- Give each worker its own real chat model on its
chat_modelport: a small, cheap model often does for a narrow worker, while the Supervisor needs one that plans well. - Swap a worker's mock tools for your own MCP servers.
- Add a third worker on the Supervisor's
workerport when a new kind of task appears, rather than giving one agent every tool. Each worker adds a tool to the Supervisor's list and model calls to each run, so add one only for a distinct job.
Make it safer
These controls are optional; the recipe runs without them.
- Keep write tools on one worker only, and require approval for them: see human approval for agent tool calls.
- Record a good run as a golden run and replay it after each change.