Skip to main content
LearnMLAcademy
Intermediate10 min read

Build a Multi-Agent Research Assistant

Coordinate multi-agent workflows for automated web research and fact synthesis, with reproducible setup, model evaluation, and an end-to-end project task.

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

1. Project Goal

Build a bounded research workflow in which a coordinator delegates two independent questions to local-source researchers, a verifier checks evidence and conflicts, and a synthesizer produces a cited result. Then compare its quality and overhead with one agent.

2. What You Will Build

Coordinator, researcher, verifier and synthesizer responsibilities
Typed task envelopes, explicit ownership and shared state
Local/mock research sources with reproducible citations
Quality-versus-cost/latency evaluation and a one-agent fallback

3. Skills / Prerequisites

Review unfamiliar foundations before implementing the project. Each link points to an existing lesson used by the workflow.

4. Dataset or Inputs

The runnable project uses two local source records: one measured benefit and one limitation. This keeps every claim inspectable. Optional web or provider integrations belong outside the core path and must preserve source, permission and budget controls.

Understand every project input

Understand every project input
RoleOwned inputRequired output / done condition
Coordinatorresearch question + budgetNon-overlapping tasks and final stop decision
Researcherone task + allowed sourcesClaims paired with exact source evidence
Verifierall findingsAccepted/rejected claims and conflicts
Synthesizeraccepted findings onlyCited answer without new unsupported claims
Shared statetasks, owners, status, evidence, spendSingle inspectable source of workflow truth

5. Architecture / Workflow

Coordinator decomposes only genuinely separable work and assigns one owner per task.

Researchers inspect disjoint or complementary local sources and return structured evidence.

Verifier checks source presence, claim support, duplication and contradiction.

Synthesizer writes from accepted findings; coordinator stops when coverage and budgets are satisfied.

Project figure

A coordinator delegates bounded work to specialized roles

Where are tasks split, verified and synthesized?

Coordinator / planner
owns plan, budgets and shared state
↙ ↓ ↘
Researcher A
source set 1
Researcher B
source set 2
Verifier
claims + evidence
↘ ↓ ↙
Synthesizer
writes only accepted findings
The coordinator owns the plan and shared state. Researchers return evidence, the verifier checks claims and the synthesizer writes only from accepted findings.

6. Environment / Dependencies

  • Python 3.10+ standard library
  • Local source dictionary
  • Sequential list execution for the runnable baseline
  • Optional async/provider adapters only after correctness

7. Data or Input Understanding

Multiple agents are useful when work is independent, parallel or benefits from a separate verification role. One agent is better when the task is short, tightly coupled or cheaper to solve in one context.

A handoff is not a vague chat message. It needs task ID, owner, input evidence, expected output, acceptance criteria and budget. Shared state prevents two researchers from unknowingly repeating the same work.

8. Baseline / Simplest Working Approach

First ask one deterministic function to read both local sources and write a cited summary. Record its completeness, latency and operation count.

Add multiple roles only if delegation or independent verification produces a measurable improvement worth the coordination overhead.

Project figure

Every handoff carries ownership, evidence and acceptance criteria

What prevents delegated work from becoming an ambiguous message chain?

Assign
owner + question
Accept
inputs understood
Work
evidence + trace
Verify
criteria + conflicts
Close
result merged
A task envelope names the owner, inputs, expected output, deadline or budget and done condition. The receiver accepts, rejects or requests clarification before work begins.

Worked Example: Compare sequential and parallel latency

Given: Coordinator takes 0.5 s, each of two researchers takes 1.2 s, verifier 0.7 s and synthesizer 0.8 s. Only the researchers can run in parallel.

  1. 1Sequential latency = 0.5 + 1.2 + 1.2 + 0.7 + 0.8 = 4.4 s.
  2. 2Parallel researcher stage latency = max(1.2, 1.2) = 1.2 s.
  3. 3Parallel total = 0.5 + 1.2 + 0.7 + 0.8 = 3.2 s.
  4. 4Speedup = 4.4 / 3.2 = 1.375×, before orchestration/network overhead.

Interpretation: Parallelism saves 1.2 seconds in this idealized trace, but it does not reduce the total research work or model cost.

9. Step-by-Step Implementation

Step 1: Run the local role pipeline

Each role is a plain function with a narrow contract. This makes the handoffs and evidence visible before any framework or model is added.

Run the local role pipelineRUNNABLE CODE
SOURCES = {
  "market.txt": "Pilot users completed the task 18% faster.",
  "risk.txt": "The sample contained 40 users and one industry.",
}

def researcher(task, source_name):
    return {"task": task, "source": source_name, "evidence": SOURCES[source_name]}

def verifier(findings):
    accepted = [f for f in findings if f["source"] in SOURCES and f["evidence"]]
    conflicts = []
    return {"accepted": accepted, "conflicts": conflicts}

def synthesizer(verified):
    return " ".join(f"{f['evidence']} [{f['source']}]" for f in verified["accepted"])

tasks = [("measure benefit", "market.txt"), ("identify limitation", "risk.txt")]
findings = [researcher(*task) for task in tasks]
report = synthesizer(verifier(findings))
print(report)
Representative expected output: Pilot users completed the task 18% faster. [market.txt] The sample contained 40 users and one industry. [risk.txt]

Step 2: Represent shared state explicitly

A coordinator updates task status and spend; workers may write only their owned result fields.

Represent shared state explicitlyCONCEPTUAL PSEUDOCODE
state = {
  "budget_steps": 8, "steps_used": 0,
  "tasks": {
    "benefit": {"owner": "researcher_a", "status": "pending"},
    "limits": {"owner": "researcher_b", "status": "pending"},
  },
  "accepted_findings": [], "conflicts": [],
}

Step 3: Handle disagreement

Conflicting supported claims are preserved for verifier or human judgment; the synthesizer must not silently choose the more fluent one.

Handle disagreementCONCEPTUAL PSEUDOCODE
if claims_conflict(a, b):
    state["conflicts"].append({"claim_a": a, "claim_b": b})
    return request_review(state["conflicts"])

10. Expected Results / Outputs

Read the output as evidence, not decoration

Read the output as evidence, not decoration
DesignCoverageLatencyOperationsReading
One agent2/2 facts3.0 s3Cheapest baseline for tiny corpus
Four roles, sequential2/2 + verification4.4 s5More inspectable, slower
Four roles, researchers parallel2/2 + verification3.2 s5Parallel benefit, same work/cost

11. Evaluation

Measure claim coverage, source correctness, contradiction detection, unsupported-claim rate and final usefulness. Pair quality with total calls, tokens, wall-clock latency and cost.

Compare against a one-agent baseline on the same fixed sources and rubric. Count duplicated work and failed handoffs; do not reward additional role messages as progress.

Project figure

More agents can improve coverage while increasing coordination cost

When does parallelism stop paying for itself?

quality plateauscost + latencynumber of collaborating agents12345
The illustrative frontier improves quickly from one to three agents, then flattens while latency and cost continue rising. Choose the smallest team that meets measured quality needs.

12. Failure Analysis

Failure mode → diagnosis → response

Failure mode → diagnosis → response
Observed failureLikely causeNext action
Duplicate findingsTasks overlap or ownership unclearCoordinator assigns non-overlapping scopes
Lost evidenceHandoff omits source metadataRequire typed evidence envelope
Conflict hiddenSynthesizer resolves silentlyVerifier records and escalates conflict
Run never endsNo coverage/step stopSuccess criteria plus global budget

13. Improve the Project

Use asynchronous execution only for independent tasks and preserve deterministic joins.
Add source-quality ranking and claim-level citation checks.
Route only difficult conflicts to a human reviewer.
Test whether a two-role researcher/verifier design matches four-role quality at lower cost.

14. Production Considerations

What changes beyond the notebook

What changes beyond the notebook
AreaProduction requirement
OwnershipOne owner and done condition for every task
BudgetsGlobal plus per-worker steps, time, tokens and cost
SecurityRole-specific tools and least-privilege source access
ObservabilityParent trace with child spans, handoffs, conflicts and final citations

15. Summary / Key Takeaways

  • Multi-agent systems are justified by separable work or valuable independent verification, not by task size alone.
  • The coordinator owns decomposition, non-overlapping assignments, shared state, budgets and the final stop decision.
  • A useful handoff names the owner, evidence, expected output and acceptance criteria.
  • Researchers return claims with sources; the verifier preserves contradictions instead of rewarding fluent agreement.
  • The synthesizer writes only from accepted findings and must not introduce unsupported claims.
  • Parallel workers can reduce wall-clock latency but usually do not reduce total work, calls or cost.
  • Quality gains must be compared with a one-agent baseline and measured against duplication, handoff failures, latency and cost.

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 "Build a Multi-Agent Research Assistant"?

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 5practical selection
When is a multi-agent design most justified?
Question 2 of 5numerical/formula
Two independent researchers each take 1.2 s. If they run in parallel, how long is the research stage ideally?
Question 3 of 5conceptual
What must a useful handoff include?
Question 4 of 5application/scenario
Two researchers return supported but conflicting claims. What should the system do?
Question 5 of 5debugging/diagnostic
A four-agent workflow costs more but matches the one-agent baseline on quality. What is the best conclusion?

Knowledge Check Review & Explanations

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

1When is a multi-agent design most justified?▼

Correct Answer: When work is genuinely separable or independent verification adds measured value

Multiple roles add coordination cost, so they should solve a concrete decomposition, parallelism or verification need.

2Two independent researchers each take 1.2 s. If they run in parallel, how long is the research stage ideally?▼

Correct Answer: 1.2 s

Parallel stage latency is the maximum worker duration, max(1.2,1.2)=1.2 seconds, excluding orchestration overhead.

3What must a useful handoff include?▼

Correct Answer: Owner, inputs/evidence, expected output, acceptance criteria and budget

A structured task envelope makes responsibility, completion and verification explicit.

4Two researchers return supported but conflicting claims. What should the system do?▼

Correct Answer: Preserve the conflict for verification or human review

Conflicts are evidence that needs resolution. Silent synthesis can hide uncertainty and create unsupported conclusions.

5A four-agent workflow costs more but matches the one-agent baseline on quality. What is the best conclusion?▼

Correct Answer: Use the simpler baseline unless another measured requirement justifies the overhead

Architecture should earn its complexity. Equal quality with higher cost and coordination risk favors the simpler design.

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