Skip to main content

06. Multi-Agent Systems

Specialized Agents (Research, Coding, Reviewer)

Specialized agents are role-shaped workers with a narrow job, prompt, and tool allowlist. Research finds and cites evidence, Coding implements changes, and Reviewer scores work against a rubric — a classic trio you can run as a pipeline under a supervisor.

What you will learn

  • Define specialized agents and why roles beat mega-prompts
  • Specify research, coding, and reviewer contracts
  • Wire a research → code → review pipeline with rework caps
  • Choose tool allowlists per specialty
  • Answer interview questions with short, solid answers
Research coding and reviewer specialized agents with distinct tools
Interview staple: specialties = narrow job + prompt + tool allowlist + output contract.

Definition

A specialized agent is a worker (or standalone agent) optimized for one skill class: distinct system prompt, success criteria, and tool allowlist. Specialization is an organization choice — not a different model brand requirement.

Research, coding, and reviewer are the most common product trio: gather grounded facts, change the system, then gate quality before release. They usually sit under a supervisor that owns the parent goal.

Introduction

This lesson (#6 in Multi-Agent Systems) follows Supervisor and Worker Agents. You know the org chart; now define concrete worker personas.

Next: Debate-Based Agents and Conflict Resolution — when specialists disagree.

Why specialize

  • Smaller prompts and clearer evals per role
  • Hard permission boundaries (search ≠ deploy)
  • Better critique when the reviewer is not the author
  • Easier swaps (replace research tools without touching coding)

Research agent

  • Job - find, extract, and cite evidence for a question
  • Tools - web/search, docs, RAG, scrapers (read-heavy)
  • Output - claims[], sources[], confidence — not a final essay
  • Non-goals - inventing citations; writing production code
  • Fail closed - mark unknown when sources are thin

Coding agent

  • Job - implement a change that satisfies a brief + tests
  • Tools - repo read/edit, tests, linters, limited shell
  • Output - files_changed[], test_results, risk_notes, PR/diff ref
  • Non-goals - merging without review; expanding scope silently
  • Safety - no secrets tools; sandbox destructive commands

Reviewer agent

  • Job - score an artifact against a rubric or test suite
  • Tools - read artifacts, run checks; usually no write/deploy
  • Output - verdict (pass/fail), rubric_scores, must_fix[]
  • Non-goals - rewriting the whole solution as the author
  • Strength - separate model or prompt from the coding agent

Pipeline shape

The classic flow is sequential with a capped rework loop from reviewer back to coding (and sometimes research).

Research to coding to reviewer to ship with rework loop
Cap reviewer→coding rework. Escalate after max fails — do not thrash.
  • Research produces a brief the coding agent may trust
  • Coding implements only within the brief + tests
  • Reviewer gates release with structured must_fix items
  • Supervisor owns budgets, retries, and human escalate

Contracts per specialty

If roles only “chat,” specialization collapses. Validate JSON (or schemas) between hops.

Output contracts for research coding and reviewer agents
claims/sources → diff/tests → verdict/must_fix — typed handoffs.
  • Research - claims[], sources[], confidence
  • Coding - files_changed[], test_results, risk_notes
  • Reviewer - verdict, rubric_scores, must_fix[]
  • Reject malformed outputs before the next role runs

Failure modes

  • Role blur - coding agent also “researches” via hallucinated facts
  • Reviewer rubber-stamp - same prompt praises itself; diversify or use tests
  • Research essay dump - no claims schema; coding cannot use it
  • Scope creep - coding ignores non-goals in the brief
  • Infinite rework - uncapped fail loops between coding and reviewer

Program / implementation notes

Register three worker roles with allowlists and Zod/JSON Schema validators. Drive the pipeline from a graph or crew runner with max_rework.

  • Prefer tests/linters as part of reviewer when the domain allows
  • Log role, contract version, and artifact ids on every hop
  • Next: Debate-Based Agents and Conflict Resolution

Advantages and limitations

  • Advantage: clearer quality gates and safer tool splits
  • Advantage: reusable personas across products
  • Advantage: easier evals per role
  • Limitation: more latency than one-shot agents
  • Limitation: weak contracts erase the benefit of roles
  • Limitation: not every task needs all three specialties

Key points

  • Specialized agents = narrow job + prompt + allowlist + output contract.
  • Research cites evidence; coding changes systems; reviewer gates quality.
  • Keep reviewer write tools minimal; keep research from inventing sources.
  • Pipeline: research → coding → review with capped rework.
  • Validate typed handoffs between roles.
  • Usually run under a supervisor that owns budgets and escalate.

FAQs

Do specialized agents need different LLMs?

Not required. Separate prompts and tools often suffice. Different models help when one role needs stronger coding or cheaper research.

Can one process host all three roles?

Yes. Specialization is about policy and allowlists, not process count.

Should the reviewer rewrite the code?

Prefer structured must_fix feedback. Let the coding agent rewrite so authorship and tool use stay clear.

When skip the research agent?

When the brief is already grounded (ticket + spec + tests) and no external evidence is needed.

Interview questions

  1. What is a specialized agent?

    Answer An agent role with a narrow job, dedicated prompt, tool allowlist, and output contract — not a mega-prompt that does everything.

  2. What should a research agent return?

    Answer Structured claims with sources and confidence — evidence the next role can use — not an uncited essay.

  3. What makes a good coding agent boundary?

    Answer Repo/test tools under a brief, structured change reports, and explicit non-goals so scope cannot silently expand.

  4. Why separate the reviewer from the coder?

    Answer Independent critique reduces rubber-stamping and creates a clear quality gate before release.

  5. How do you stop coding↔reviewer thrash?

    Answer Max rework attempts, clear must_fix items, and escalate or ship-with-warning when the budget ends.

  6. Give a compact pipeline example.

    Answer Research builds claims JSON → coding opens a PR that satisfies tests → reviewer returns pass/fail with must_fix → supervisor ships or retries.

Related topics

Practice task

Complete each numbered practice step in a notebook or doc before opening the next lesson.

  1. Write tool allowlists for research, coding, and reviewer for a “fix a bug from a GitHub issue” product.
  2. Define the three output schemas (fields only) for those roles.
  3. Draw the pipeline and mark the rework edge with max attempts = 2.
  4. List two non-goals for the coding agent.
  5. Answer interview questions 1, 2, and 4 in two sentences each.