Capstone 10 — Multi-Agent Software Engineering Team
A multi-agent software team is an architect, parallel coders, a reviewer, and a tester passing typed messages over a shared task board. SWE-AF, MetaGPT, AutoGen 0.4, Cognition's Devin, and Factory's Droids all landed on that shape in 2026. Parallel worktrees turn wall-clock time into throughput, and the handoffs between roles become the failure surface. Build the team, evaluate it on SWE-bench Pro, and report which handoffs break and how often.
Learning Objectives
- Design a four-role software team (architect, parallel coders, reviewer, tester) where each role has its own model, permissions, and typed messages on a shared task board.
- Isolate parallel coders in git worktrees plus Daytona sandboxes, and merge their branches with a three-way merge coordinator that calls an LLM only when files overlap.
- Gate reviews so the reviewer cannot approve its own diffs, and measure its false-approval rate with an injected-bug probe.
- Measure token amplification, pass@1, and cost per solved issue against a single-agent baseline on 50 SWE-bench Pro issues, then write a handoff-failure post-mortem.
Problem
A multi-agent software team is a set of role-specialized agents (architect, coders, reviewer, tester) that split one engineering task between them and coordinate through typed messages. Single-agent coding harnesses hit a ceiling on large tasks, and not because any individual agent is weak. A 200k-token context cannot hold an architecture plan, four parallel codebase slices, reviewer commentary, and test output at once. The factory shape fixes that by giving each concern its own context: the architect owns the plan, coders implement in parallel worktrees, the reviewer gates, and the tester verifies. SWE-AF's "factory" architecture, MetaGPT's roles, and AutoGen's typed actor graph are three framings of that one design.
The failure surface is the handoff. The architect plans something the coders cannot implement. Coders produce conflicting diffs. The reviewer approves a hallucinated fix. The tester races a coder that is still writing. You will build one of these teams, run it on 50 SWE-bench Pro issues, track every handoff, and publish the post-mortem.
Concept
Each role is a typed agent with its own model and its own permissions.
- Architect (Claude Opus 4.7) reads the issue, writes a plan, and breaks it into subtasks with explicit interfaces.
- Coders (Claude Sonnet 4.7, N parallel instances, each in a
git worktreeplus a Daytona sandbox) implement the subtasks independently. - Reviewer (GPT-5.4) reads the merged diff and either approves it or requests specific changes.
- Tester (Gemini 2.5 Pro) runs the test suite in isolation and reports pass/fail with artifacts.
Roles communicate through a shared task board, either file-backed or Redis. Each role consumes only the tasks it is permitted to handle, and handoffs are A2A-protocol-typed messages. Three coordination concerns need explicit answers. Merge conflicts go to a coordinator role or an automatic three-way merge. Shared state needs a rule, and the rule here is that the plan freezes once coders start, with replans treated as separate events. Reviewer gatekeeping means the reviewer cannot approve its own changes or changes it proposed.
Token amplification is the hidden cost. Every role boundary adds summary prompts and handoff context, so a 40-turn single-agent run becomes 160 total turns across four roles. That is why the rubric weighs token efficiency against a single-agent baseline. The question is not whether multi-agent works. The question is whether it wins per dollar.
Architecture
GitHub issue URL
|
v
Architect (Opus 4.7)
reads issue, produces plan with subtasks + interfaces
|
v
Task board (file / Redis)
|
+-- subtask 1 ---+-- subtask 2 ---+-- subtask 3 ---+-- subtask 4 ---+
v v v v v
Coder A Coder B Coder C Coder D (4 parallel)
(Sonnet) (Sonnet) (Sonnet) (Sonnet)
worktree A worktree B worktree C worktree D
Daytona Daytona Daytona Daytona
| | | |
+--------+-------+-------+--------+
v
merge coordinator (three-way merge + conflict resolution)
|
v
Reviewer (GPT-5.4)
|
v
Tester (Gemini 2.5 Pro) -> passes? -> open PR
-> fails? -> route back to coder
Stack
- Orchestration: LangGraph with shared state + per-agent sub-graphs
- Messaging: A2A protocol (Google 2025) for typed inter-agent messages
- Models: Opus 4.7 (architect), Sonnet 4.7 (coders), GPT-5.4 (reviewer), Gemini 2.5 Pro (tester)
- Worktree isolation:
git worktree addper coder + Daytona sandbox - Merge coordinator: custom three-way merge + LLM-mediated conflict resolution
- Eval: SWE-bench Pro (50 issues), SWE-AF scenarios, HumanEval++ for unit tests
- Observability: Langfuse with role-tagged spans, per-agent token accounting
- Deployment: K8s with each role as a separate Deployment + HPA on backlog
Build It
-
Task board. Build a file-backed JSONL log of typed messages:
plan_request,subtask,diff_ready,review_needed,test_needed,approved,rejected,replan_needed. Agents subscribe to tags. -
Architect. Read the GitHub issue and run Opus 4.7 with a plan template that requires explicit subtask interfaces (files touched, public functions, test impact). It emits one
plan_requestcontaining a DAG of subtasks. -
Coders. Run N parallel workers, each claiming one subtask from the board. Each spawns a fresh
git worktree addbranch and a Daytona sandbox, implements its subtask, and emitsdiff_readywith the patch and test deltas. -
Merge coordinator. Once all coders finish, three-way merge the N branches into a staging branch. Call the LLM for conflict resolution only when file-level overlap exists.
-
Reviewer. GPT-5.4 reads the merged diff and cannot approve diffs it authored. It emits
approved(a no-op) orreview_feedbackwith specific change requests routed back to the relevant coder. -
Tester. Gemini 2.5 Pro runs the test suite in a clean sandbox and captures artifacts. It emits
test_passedortest_failedwith stacktraces, and failed tests loop back to the coder who owns the failing subtask. -
Handoff accounting. Every message crossing a role boundary gets a span in Langfuse with payload size and model used. Compute per-subtask token amplification as (coder_tokens + reviewer_tokens + tester_tokens + architect_share) / coder_tokens. The reference
main.pyreports the aggregate form instead: total team tokens divided by total single-agent baseline tokens across matched trials. -
Eval. Run the 50 SWE-bench Pro issues. Compare pass@1 and $-per-solved-issue against a single-agent baseline: one Sonnet 4.7 in a single worktree.
-
Post-mortem. For each failed issue, name the handoff that broke (plan too vague, merge conflict, reviewer false-approve, tester flake) and produce a handoff-failure histogram.
Use It
$ team run --issue https://github.com/acme/widget/issues/842
[architect] plan: 4 subtasks (parser, cache, api, migration)
[board] dispatched to 4 coders in parallel worktrees
[coder-A] subtask parser -> 42 lines, tests pass locally
[coder-B] subtask cache -> 88 lines, tests pass locally
[coder-C] subtask api -> 31 lines, tests pass locally
[coder-D] subtask migration -> 19 lines, tests pass locally
[merge] 3-way merge: 0 conflicts
[reviewer] comments on cache (thread pool sizing); routed to coder-B
[coder-B] revision: 92 lines; submits
[reviewer] approved
[tester] all 412 tests pass
[pr] opened #3382 4 coders, 1 revision, $4.90, 18m
Ship It
outputs/skill-multi-agent-team.md is the deliverable. Given an issue URL and a parallelism level, the team produces a merge-ready PR with per-role token accounting.
| Weight | Criterion | How it is measured |
|---|---|---|
| 25 | SWE-bench Pro pass@1 | Matched 50-issue subset, pass@1 |
| 20 | Parallel speedup | Wall-clock vs single-agent baseline |
| 20 | Review quality | False-approval rate on injected-bug probe |
| 20 | Token efficiency | Total tokens per solved issue vs single-agent |
| 15 | Coordination engineering | Merge-conflict resolution, handoff-failure histogram |
| 100 |
My bet is that you should get the single-agent baseline running before you write the architect. Step 8 defines it as one Sonnet 4.7 in a single worktree, and two criteria in the rubric, parallel speedup and token efficiency (20 points each), are both measured against it. If the baseline only shows up at the end, you will have no speedup or tokens-per-solved-issue comparison until the last day, and by then you have no room to react if multi-agent turns out to lose per dollar.
I'd also build the injected-bug probe from Exercise 1 before tuning anything else on the team. The Problem section names the reviewer approving a hallucinated fix as one of the handoff failures, and the review-quality criterion scores the false-approval rate directly. A reviewer that waves bugs through leaves the tester as the last gate before a bad PR, so I'd rather know that rate early.
Exercises
-
Inject an obvious bug into a diff mid-run (an extra
return Nonebefore the main body). Measure the reviewer's false-approve rate, then tune the reviewer prompt until false-approval is under 5%. -
Reduce to a single coder: architect, coder, reviewer, and tester, with the coder running the plan's subtasks sequentially. Compare wall-clock and pass rate.
-
Replace the merge coordinator with a single-writer constraint, so subtasks touch disjoint file sets. Measure the planning burden this puts on the architect.
-
Swap the reviewer from GPT-5.4 to Claude Opus 4.7. Measure the change in false-approval rate and token cost.
-
Add a fifth role, a documenter (Haiku 4.5), that produces a changelog entry after review. Measure whether the documentation quality justifies the extra token spend.
Key Terms
| Term | What people say | What it actually means |
|---|---|---|
| Parallel worktree | "Isolated branch" | git worktree add producing a fresh working tree per coder |
| Task board | "Shared message bus" | File or Redis store of typed messages agents subscribe to |
| Handoff | "Role boundary" | Any message crossing from one role's context to another's |
| Token amplification | "Multi-agent overhead" | Total tokens across roles / single-agent tokens for the same task |
| A2A protocol | "Agent-to-agent" | Google's 2025 spec for typed inter-agent messages |
| Merge coordinator | "Integrator" | Component that runs three-way merge and mediates conflicts |
| False approval | "Reviewer hallucination" | Reviewer approves a diff with known bugs |
Further Reading
- SWE-AF factory architecture: the reference 2026 multi-agent factory
- MetaGPT: role-based multi-agent framework
- AutoGen v0.4: Microsoft's typed actor framework
- Cognition AI (Devin): reference product
- Factory Droids: alternate reference product
- Google A2A protocol: inter-agent messaging spec
- git worktree documentation: the isolation substrate
- SWE-bench Pro: the evaluation target
Code
- main.py (python, 231 lines)
- ts/package.json (json, 18 lines)
- ts/README.md (markdown, 41 lines)
- ts/src/agent.ts (typescript, 124 lines)
- ts/src/coordinator.ts (typescript, 68 lines)
- ts/src/index.ts (typescript, 75 lines)
- ts/src/runtime.ts (typescript, 97 lines)
- ts/src/types.ts (typescript, 31 lines)
- ts/src/workspace.ts (typescript, 46 lines)
- ts/tests/coordinator.test.ts (typescript, 107 lines)
- ts/tests/runtime.test.ts (typescript, 80 lines)
- ts/tsconfig.json (json, 18 lines)