Velamuvi AIAcademy

Lesson 2 of 6 · Concepts

Orchestrator and Workers

The most common multi-agent design: a lead agent plans, briefs workers with their own tools, checks results and combines them, with parallel workers in Python.

  • 7 min read
  • Advanced
  • Reviewed
In this lesson you will learn
  • Describe the roles of a lead agent and its worker agents
  • Write a clear brief: objective, output, tools and limits
  • Check worker results for missing sources and gaps in coverage
  • Scale the number of workers to the difficulty of the task
  • Run workers in parallel and handle a failed worker

A lead and its workers

The Agent Workflows course introduced orchestrator-workers as a workflow, where each worker is a single, contained step. In a multi-agent system the workers are agents: each runs its own loop, with its own tools and its own context, for as many steps as its part of the job needs.

The flow: plan the sub-tasks, brief each worker, let them work (in parallel where possible), check each result, fill gaps with follow-up briefs, then combine everything into the answer.

Briefs, results and checks

Here a lead agent researches e-bikes for a small team. The models are stand-ins, but the structure, the checks and the follow-up are what a real lead does:

Try it yourselfPython
# A lead agent splits a research question into briefs, workers handle them, the lead checks and combines.
QUESTION = "Which e-bike should our team of 3 buy for city commuting, under 2,500 euros each?"

def lead_plan(question):
    """Stands in for the lead model. Each brief says: objective, output, tools, limits."""
    return [
        {"id": "w1", "objective": "List e-bike models under 2,500 EUR suitable for city commuting",
         "output": "findings + sources", "tools": ["web_search"], "max_searches": 5},
        {"id": "w2", "objective": "Compare range and reliability of those models from reviews",
         "output": "findings + sources", "tools": ["web_search", "fetch_page"], "max_searches": 8},
        {"id": "w3", "objective": "Find which models local bike shops can service, and warranty terms",
         "output": "findings + sources", "tools": ["web_search"], "max_searches": 5},
    ]

# Stand-ins for worker agents. Each runs its own loop with its own tools, then returns a summary.
WORKER_RESULTS = {
    "w1": {"findings": ["Volta City 3: 2,190 EUR", "Urbo S: 2,450 EUR", "Ridge Commute: 1,980 EUR"],
           "sources": ["shop-a.example/ebikes", "shop-b.example/city"], "seconds": 40},
    "w2": {"findings": ["Volta City 3: 70 km range, few repair complaints",
                        "Ridge Commute: 55 km range, motor faults in 2 of 9 reviews"],
           "sources": ["review-site.example/volta", "forum.example/ridge"], "seconds": 65},
    "w3": {"findings": ["Two local shops service Volta and Urbo; none service Ridge"],
           "sources": [], "seconds": 35},           # no sources: the lead shouldn't trust it
}

def run_worker(brief):
    return WORKER_RESULTS[brief["id"]]

def accept(result):
    """The lead checks every result before using it."""
    problems = []
    if not result.get("findings"):
        problems.append("no findings")
    if not result.get("sources"):
        problems.append("no sources")
    return problems

briefs = lead_plan(QUESTION)
results, gaps = {}, []
for brief in briefs:                      # in production these run in parallel
    result = run_worker(brief)
    problems = accept(result)
    if problems:
        gaps.append(f"{brief['id']} ({brief['objective'][:40]}...): {', '.join(problems)}")
    else:
        results[brief["id"]] = result

print("Accepted findings:")
for wid, r in results.items():
    for f in r["findings"]:
        print(f"  [{wid}] {f}")
print("Gaps to fix or report:", gaps)
# The lead also checks coverage: did the review worker cover every model found?
models = {f.split(":")[0] for f in results["w1"]["findings"]}
reviewed = {f.split(":")[0] for f in results.get("w2", {}).get("findings", [])}
for model in sorted(models - reviewed):
    print(f"Follow-up brief: compare range and reliability of {model} from reviews")
times = [WORKER_RESULTS[b["id"]]["seconds"] for b in briefs]
print(f"Time one after another: {sum(times)} s; in parallel: {max(times)} s")

Three things happened that a careless lead would miss. Worker 3 returned findings with no sources, so the lead didn't use them and listed the gap instead. Worker 2 reviewed only two of the three models, so the lead wrote a follow-up brief for the missing one. And because the workers are independent, running them in parallel took 65 seconds instead of 140.

Writing a good brief

The brief is everything a worker knows about its job: it doesn't see the user's conversation or the other workers. Anthropic's 2025 write-up of its research system found that short, vague task descriptions made sub-agents duplicate each other's work or misread the task. A good brief has four parts:

PartExample
Objective“Compare range and reliability of these three models from independent reviews.”
Output“A list of findings, each with a source URL. Under 200 words.”
Tools and sources“Use web_search and fetch_page. Prefer reviews from the last two years.”
Limits“At most 8 searches. Don't cover prices; another worker does.”

The last line matters more than it looks. Telling a worker what not to do is how you stop two workers doing the same job.

How many workers?

Match the effort to the question. Anthropic's lead agent was given rules of thumb: a simple fact needs one agent and a few tool calls, a direct comparison needs two to four workers, and only complex research justifies ten or more. Early versions without such guidance sometimes started dozens of sub-agents for simple questions.

Put the limits in two places: in the lead's prompt (guidance on how many workers to use) and in code (a hard cap on workers, tool calls and total tokens that the lead can't exceed, however it plans).

When workers fail

Workers fail like any agent: timeouts, empty results, step limits, nonsense. The lead must treat each result as unverified until checked:

  • Retry a worker that failed for a transient reason, once or twice.
  • Re-brief a worker whose result missed the point, with a clearer objective.
  • Report gaps honestly in the final answer instead of filling them with guesses.

Common mistakes

Practice exercise

Write the function of a lead agent that turns a structured brief into a clear task message for a worker.

Your solutionPython
brief = {"objective": "Find warranty terms for the Volta City 3",
         "output": "a list of findings, each with a source URL",
         "tools": ["web_search", "fetch_page"],
         "limits": "at most 5 searches; don't contact shops"}

# Turn the brief into the task message for a worker agent, one line per part, exactly:
# Objective: ...
# Output: ...
# Tools: web_search, fetch_page
# Limits: ...
Knowledge check

Two workers keep researching the same topic. What is the best fix?

Summary

  • A lead agent plans, briefs, checks and combines; worker agents each handle one sub-task in their own context.
  • A good brief has an objective, an output format, tools and sources, and limits, including what not to do.
  • The lead checks results for sources and coverage, and sends follow-up briefs for gaps.
  • Scale the number of workers to the task, with hard limits in code.
  • Run independent workers in parallel, and handle failures by retrying, re-briefing or reporting gaps.

Next: handoffs, passing control of a conversation from one agent to another.

Finished reading? Tick it off to track your progress.