Skip to main content
LearnMLAcademy
Advanced10 min read

Multi-Agent Systems, Handoffs & Agent Communication

Architect multi-agent systems with role delegation, handoffs, and consensus, with workflow diagrams, tool-use traces, and safety-focused exercises.

What you will master in this lesson
Intuitive core mechanisms & practical real-world intuition
Step-by-step mathematical breakdown & visual diagrams
Runnable Python implementation & practical trade-offs

Divide work without losing control of the result

A multi-agent system divides work among specialized agents and defines how tasks, evidence, status, and ownership move between them. A manager may orchestrate workers, one agent may call another as a tool, or a peer may hand off a task. The benefit comes from useful specialization—not from adding more model calls.

What You Will Learn

  • Compare manager-worker, agent-as-tool, and handoff topologies.
  • Write a delegation contract with scope, permissions, budget, and success criteria.
  • Transfer only necessary context and evidence between agents.
  • Keep task ownership and final synthesis explicit.

Calling a specialist is not the same as handing over control

When an agent uses another agent as a tool, the specialist receives a bounded request, returns a result, and control goes back to the original controller. In a handoff, the receiving agent becomes responsible for the conversation or task until another explicit transfer occurs.

Every delegation needs a contract: scope, inputs, expected output, permissions, budget, deadline, and success criteria. Pass evidence and state needed for that contract—not the entire conversation by default. Unless ownership is deliberately handed off, one coordinator remains responsible for resolving conflicts and producing the final answer.

Three multi-agent topologies

Three multi-agent topologies
TopologyControl ownerContext transferBest fitMain failure
Manager-workersManager delegates and synthesizesBounded task packets to workersParallel specialist subtasksManager bottleneck or duplicate work
Agents-as-toolsController remains in chargeOne request and structured returnNested specialist capabilityAmbiguous result contract
Handoff / peerOwnership transfers to receiverTask state plus explicit authorityDifferent agent should continue the taskLost ownership or missing context

Instructional figure

Three multi-agent topologies

Who owns control in manager-worker, agent-as-tool, and handoff designs?

MANAGER–WORKERS

Manager
↙ ↓ ↘
A
B
C

AGENT AS TOOL

Controller
Specialist
Return

HANDOFF

Owner A
Transfer state + control
Owner B
Agents-as-tools return to a controller. A handoff transfers ownership. Manager-worker keeps delegation and synthesis under one manager.

Delegate a task and check what comes back

  1. Use more than one agent only when tasks are genuinely parallel, require different tools, or need distinct expertise.

  2. Choose a topology: manager and workers, agents-as-tools, or a peer-to-peer handoff.

  3. Define a delegation contract with scope, inputs, expected output, permissions, budget, deadline, and success criteria.

  4. Pass the necessary state and evidence—not entire noisy histories—and state who owns updates after a handoff.

  5. Track progress, detect duplicate work or conflicting decisions, validate every returned result, and keep one owner for the final outcome.

Instructional figure

A delegation contract from assignment to integration

What information must cross an agent boundary?

Owner defines contract
Scope + inputs + permissions
Specialist executes
Structured result + evidence
Validate + integrate
A bounded contract travels to the specialist; a structured result and evidence return. The owner validates and integrates rather than accepting an unexamined answer.

Should this be one agent or several?

Should this be one agent or several?
SignalPrefer one agentConsider multiple agents
Work structureMostly sequential and coherentIndependent specialist subtasks
Tools / permissionsSame tools and authorityDistinct permission boundaries
ParallelismLittle useful overlapIndependent work can run concurrently
Coordination costWould dominate the taskMeasured quality/time gain exceeds it

A Realistic Example: Preparing a market report through bounded delegation

A coordinator delegates official-statistics research and competitor analysis in parallel. Each specialist returns a structured result with sources and status. A fact-checker examines the combined claims, and the coordinator resolves contradictions before producing one report.

Read the Mechanism in Code

Use the label and note to understand what this block represents before reading each line.

Conceptual pseudocode
contracts = [
    Task(role="statistics", output="sourced_metrics", budget=3),
    Task(role="competitors", output="comparison_table", budget=3),
]
statistics, competitors = await_all(
    delegate(task) for task in contracts
)
review = fact_checker.run(evidence=[statistics, competitors])
report = coordinator.merge_validated(statistics, competitors, review)
Learner note: Conceptual delegation example. Task, delegate(), and fact_checker are application abstractions.

Hands-On Runnable Python Lab: Join Two Worker Results Without Hiding a Conflict

Worker A reports a $40 price from P1; worker B reports $45 from P2 and a 30-day refund period from R1. Duration fixtures are 0.8 s and 1.2 s, followed by 0.2 s of coordinator work.

serial = 0.8 + 1.2 + 0.2 = 2.2 s; ideal_parallel = max(0.8, 1.2) + 0.2 = 1.4 s
The max term applies only when workers are independent and start together. Scheduling, network contention and join overhead can reduce the ideal saving.
  1. Collect facts with worker and source IDs.
  2. Group values by field; preserve both prices instead of last-write-wins.
  3. Expose the conflict while retaining the uncontested refund fact.
  4. Calculate latency separately from correctness: faster disagreement is still disagreement.

Parallel workers meet at an explicit conflict-aware join

A manager delegates to two independent workers. A returns price 40 and B returns price 45 plus refunds. At the join, the price conflict remains unresolved.CoordinatorWorker A · 0.8 s$40 [P1]Worker B · 1.2 s$45 [P2]Join · 0.2 sprice conflict: preserve bothIdeal parallel time = 1.2 + 0.2 = 1.4 sDo not finalize an unresolved price
Independent worker durations determine the ideal critical path. The join preserves the two conflicting prices rather than choosing the last result.

Independent worker durations determine the ideal critical path. The join preserves the two conflicting prices rather than choosing the last result.

Complete Python ExercisepythonRunnable
workers = [
    {"name": "A", "seconds": 0.8, "facts": {"price_usd": (40, "P1")}},
    {"name": "B", "seconds": 1.2,
     "facts": {"price_usd": (45, "P2"), "refund_days": (30, "R1")}},
]
grouped = {}
for worker in workers:
    for field, (value, source) in worker["facts"].items():
        grouped.setdefault(field, []).append((value, source, worker["name"]))
for field, records in sorted(grouped.items()):
    values = {record[0] for record in records}
    status = "CONFLICT" if len(values) > 1 else "SUPPORTED"
    print(field, status, records)
join_seconds = 0.2
serial = sum(worker["seconds"] for worker in workers) + join_seconds
parallel = max(worker["seconds"] for worker in workers) + join_seconds
print(f"serial estimate: {serial:.1f} s")
print(f"ideal parallel estimate: {parallel:.1f} s")
print(f"ideal saving: {serial - parallel:.1f} s")
print("Final price answer: withheld pending source resolution")
Run with Python 3 using only its standard library. No API key, paid service or model download is required. Model proposals and external observations are explicitly simulated; the application logic really executes.
Output from This Exact ProgramOutput
price_usd CONFLICT [(40, 'P1', 'A'), (45, 'P2', 'B')]
refund_days SUPPORTED [(30, 'R1', 'B')]
serial estimate: 2.2 s
ideal parallel estimate: 1.4 s
ideal saving: 0.8 s
Final price answer: withheld pending source resolution
Captured with Python 3.12. Fixture timings, prices and evaluation results are teaching inputs, not provider benchmarks.

What This Run Shows

  1. Multiple sources do not imply conflict when values agree; here 40 and 45 genuinely differ.
  2. The refund field survives even though the price cannot be finalized.
  3. Latency comes from supplied timings, not measured model workers.

The coordinator must maintain a consistent result contract, not merely write a fluent synthesis. Explicit ownership, conflict resolution and stop rules matter more than the number of agents.

From the Exercise to an Application

From the Exercise to an Application
SituationPractical choiceImportant qualification
Independent specialist tasksConsider concurrent workersMeasure coordination overhead and duplicate retrieval.
Sequential dependent workPrefer one controller or a state graphParallelism cannot skip true dependencies.
Different conversation owner neededUse an explicit handoffTransfer necessary context and scoped authority.
Experiment: Change worker B’s price to 40.

The price becomes SUPPORTED by the merge rule. Agreement still does not prove truth: both workers could share the same bad source.

Summary / Key Takeaways

  • Multi-agent systems are useful when work benefits from genuine specialization, parallelism, or separate tool/permission boundaries.
  • A manager-worker topology keeps synthesis centralized; agents-as-tools nests specialists under one controller; handoffs transfer control to another agent.
  • Delegation should use explicit contracts containing scope, inputs, expected output, permissions, budget, deadline, and success criteria.
  • Only necessary context and evidence should cross agent boundaries; transferring entire histories increases noise and cost.
  • Ownership of task state and the final answer must remain clear, especially after handoffs.
  • Duplicate work, conflicting conclusions, coordination failures, and repeated context can make multi-agent systems worse than one capable agent.
  • Use multiple agents only when evaluation shows that the added coordination complexity produces measurable value.

Verified Further Reading

These primary research papers and current official specifications support the concepts and implementation guidance in this lesson. The explanations, analogies, exercises, and code above remain original teaching material.

Apply this concept in a real hands-on project

You have studied the idea. Now use it in working Python code, see the calculation and output, and explain what changed. Each project includes step-by-step instructions, full source and tests.

Practice challenge: predict an outcome first, run the code, and explain the difference.

Track Your Progress0% curriculum done

Finished "Multi-Agent Systems, Handoffs & Agent Communication"?

Mark this lesson as completed to update your progress bar and track your milestones across the full curriculum.

Overall Progress0 / 167 lessons

Was this tutorial helpful?

Your feedback helps us continuously refine and improve our open-access tutorials.

Knowledge Check

Progress: 0/5

Test your active recall. Choose one answer for each question, then check it to reveal the step-by-step reasoning.

Question 1 of 5conceptual
Which topology keeps one central agent responsible for delegating and synthesizing worker results?
Question 2 of 5conceptual
What is the defining difference between 'agent as a tool' and a handoff?
Question 3 of 5practical selection
Which item belongs in a delegation contract?
Question 4 of 5debugging/diagnostic
Two specialist agents independently perform the same expensive search because neither knows task ownership. What failure occurred?
Question 5 of 5practical selection
When should you prefer one capable agent over multiple agents?

Knowledge Check Review & Explanations

Review the questions, verified correct answers, and conceptual explanations for this lesson.

1Which topology keeps one central agent responsible for delegating and synthesizing worker results?▼

Correct Answer: Manager-worker

In manager-worker orchestration, the manager decomposes work, delegates, and integrates the outputs.

2What is the defining difference between 'agent as a tool' and a handoff?▼

Correct Answer: An agent-as-tool returns to the controller, while a handoff transfers conversational/task control to another agent

Agents-as-tools behave like nested specialists under one controller; handoffs transfer control/ownership to another agent.

3Which item belongs in a delegation contract?▼

Correct Answer: Scope, inputs, expected output, permissions, budget, deadline, and success criteria

Explicit contracts reduce ambiguous handoffs and clarify what the specialist is allowed and expected to do.

4Two specialist agents independently perform the same expensive search because neither knows task ownership. What failure occurred?▼

Correct Answer: Duplicate work caused by poor coordination

Multi-agent systems need explicit ownership and task tracking to prevent duplicated work.

5When should you prefer one capable agent over multiple agents?▼

Correct Answer: When the task is simple enough that specialization/parallelism does not justify coordination overhead

Multi-agent designs add latency, context transfer, and coordination failure modes, so they need a clear benefit.

Keep moving through the path

Continue Learning

Free Download: ML Interview Cheatsheet

100 essential Machine Learning interview questions and answers covering foundations, algorithms, evaluation, deep learning, Python, system design and interview strategy. Enter your email to download it instantly.

Next