Skip to content

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 ​

  1. Download supervisor-worker-swarm-flow.json, or take it from the samples folder on GitHub.
  2. In the studio's workflow editor, import the file (see import and export).
  3. 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).
  4. Open the run and click the Supervisor node to read its trace.
  5. Then change one thing at a time (see below).

How it works ​

Diagram of the Supervisor + Worker Swarm workflowRuns Manual Trigger, then Supervisor, then Output. Supervisor Chat Model (echo) is attached to Supervisor as its chat model; Worker: Researcher is attached to Supervisor as its worker; Worker: Computer is attached to Supervisor as its worker; Researcher Chat (echo) is attached to Worker: Researcher as its chat model; MCP: lookup_kb is attached to Worker: Researcher as its tool; Computer Chat (echo) is attached to Worker: Computer as its chat model; MCP: calculator is attached to Worker: Computer as its tool; MCP: get_current_time is attached to Worker: Computer as its tool.Manual Trigger (manual_trigger)Manual Triggermanual_triggerSupervisor (supervisor_node)Supervisorsupervisor_nodeSupervisor Chat Model (echo) (llm_call)Supervisor Chat Model (…llm_callWorker: Researcher (agent_orchestrator)Worker: Researcheragent_orchestratorResearcher Chat (echo) (llm_call)Researcher Chat (echo)llm_callMCP: lookup_kb (mcp_tool)MCP: lookup_kbmcp_toolWorker: Computer (agent_orchestrator)Worker: Computeragent_orchestratorComputer Chat (echo) (llm_call)Computer Chat (echo)llm_callMCP: calculator (mcp_tool)MCP: calculatormcp_toolMCP: get_current_time (mcp_tool)MCP: get_current_timemcp_toolOutput (output)Outputoutput
Solid arrows are the order the steps run in. Dashed lines attach a chat model, memory, tools or workers to an agent; the agent uses them while it runs.
NodeTypeRole
Manual Triggermanual_triggerStep in the run
Supervisorsupervisor_nodeStep in the run
OutputoutputStep in the run
Supervisor Chat Model (echo)llm_callAttached to Supervisor on its chat_model port
Worker: Researcheragent_orchestratorAttached to Supervisor on its worker port
Researcher Chat (echo)llm_callAttached to Worker: Researcher on its chat_model port
MCP: lookup_kbmcp_toolAttached to Worker: Researcher on its tool port
Worker: Computeragent_orchestratorAttached to Supervisor on its worker port
Computer Chat (echo)llm_callAttached to Worker: Computer on its chat_model port
MCP: calculatormcp_toolAttached to Worker: Computer on its tool port
MCP: get_current_timemcp_toolAttached 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 answered Supervisor: 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_model port: 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 worker port 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.

Further reading ​

This website (not the L2M product) uses Google Analytics, only after you accept cookies. Cookie settings