---
title: When should multiple AI agents write code together?
description: >-
  Use a customer-export feature to decide what to delegate, what to keep in one
  conversation, and when worktrees help. Includes a task brief, integration
  checks, and a way to compare time, rework, and cost.
canonical_url: 'https://onevium.com/blog/when-to-use-multiple-ai-coding-agents'
language: en
published_at: '2026-11-01'
publisher: Onevium
---
# When should multiple AI agents write code together?

Use a customer-export feature to decide what to delegate, what to keep in one conversation, and when worktrees help. Includes a task brief, integration checks, and a way to compare time, rework, and cost.

## Three busy agents, one unfinished feature

A team needs an export button on a customer list. The lead assigns the API, interface, and tests to three AI agents. After the API is finished, the interface agent discovers that an empty result returns JSON. The test agent has assumed every successful request downloads a file. All three report completion, but the lead still has to explain the requirements again.

**A useful delegated task needs little shared background, can make independent progress, and returns something the lead can check.** When every step requires the same business rules and repeated changes to the same files, keeping implementation and its related tests in one conversation can make consistency easier.

Anthropic's October 22 article on [folding subagents into the main agent loop](https://claude.com/resources/articles/building-agents-when-to-fold-subagents-into-your-main-agent-loop) makes a related argument: split work by context boundaries rather than copying an organization chart, and load procedures and tools as needed. That article concerns enterprise agent systems. Here we apply its boundary test to coding collaboration, using a fictional customer-export task to decide what to split, which code to isolate, and who verifies the whole feature.

## Ask three questions before opening another agent

Start by describing each proposed task in three sentences: what material it needs, what it can decide independently, and what it must return so the lead can continue. Difficulty writing those sentences usually means the boundary is still unstable.

| Question                          | A reason to delegate                                                    | A reason to keep the work together                               |
| --------------------------------- | ----------------------------------------------------------------------- | ---------------------------------------------------------------- |
| How much background must travel?  | A contract and a few files are enough                                   | The member needs the whole main conversation                     |
| Can it make independent progress? | A settled component boundary, independent research, or black-box checks | Each step waits for another member to change the rules           |
| Can the result be checked?        | A diff, source locations, tests, or a concrete reproduction             | The lead receives an opinion and has to repeat the investigation |

An investigation of export-permission consumers can return call sites and unresolved questions. A check of downloaded files can work from the agreed behavior without knowing the implementation rationale. Both can suit short-lived subagents. Passing a small function through separate designer, coder, and tester agents repeatedly loads the same material.

The original article's [context-boundary illustration](https://assets.claude.com/cd4b9c4417d5ba31776e8aa79e204966c08c6a43.png) makes the distinction concrete: an implementer writes the feature and its related tests, then an independent verifier checks the result. Implementation decisions retain their context, while external verification remains. That verifier still needs an agreed behavior contract and independent checks, rather than merely rerunning the implementer's chosen happy paths.

![Role-based handoffs compared with one implementer retaining context and an independent verifier checking the behavior contract.](https://onevium.com/assets/blog/developer-workflows/delegation-en.webp)

An original illustration of the context-boundary principle: keep closely coupled implementation work together, then verify the result independently.

## Which parts of an export feature can actually run in parallel?

[Open the full-size diagram to read its labels](https://onevium.com/assets/blog/developer-workflows/delegation-en.webp).

Suppose administrators must export the currently filtered customers, with CSV columns `id,name,status`. Direct requests by ordinary members must be rejected. An empty selection produces a no-results message and no download. A failed request preserves the filter and allows retry. The lead confirms these decisions before choosing an execution structure.

There are two reasonable arrangements. One conversation can read the API, implement the interface and server, and write related tests; a short-lived second agent verifies permissions, downloads, and failure recovery against the contract. If both components are substantial and their files are separate, implementation can run in parallel: a server member owns `export.mjs`, while an interface member owns `app.mjs` and `index.html`. Each supplies relevant checks. The lead owns the common contract and integrated result.

Test design can start before implementation. Verification of the complete feature must wait for both sides to work together. While permissions remain undecided, parallel work can investigate callers and propose cases; implementers should not invent separate answers.

Our existing [team-session tutorial](https://onevium.com/blog/team-sessions-complex-feature) includes a [bilingual practice project](https://onevium.com/downloads/team-export-workshop.zip). To try it, copy `starter` into a separate new directory, keeping `reference` outside the project under test. It needs Node.js 20 or later, no external dependencies, and no API key. All six initial API checks are expected to fail. We reuse that exercise to compare ways of organizing work rather than introduce another export specification. Its public demo personas are local teaching data, not production authentication.

## Write a brief that specifies inputs, ownership, and evidence

Have the lead inspect the actual project and existing modifications before assigning boundaries. This brief applies to the practice project; replace its paths and commands for a real repository. A missing `contract.md` or conflicting requirement needs a decision, not an invented rule.

```text
Goal: let administrators export the currently filtered customers.
Read contract.md, the implementation, and acceptance tests first.
Identify unresolved behavior.
Assess whether one implementation conversation and one independent
verifier are enough. If proposing parallel implementation, explain
why each task needs little shared background.

After the plan is confirmed:
- The lead alone maintains the common contract, task record, and integration.
- The server member edits only export.mjs and returns its diff,
  relevant checks, and unmet requirements.
- The interface member edits only app.mjs and index.html,
  implements the same contract, and checks its changes.
- The verifier reads implementation without editing it and checks
  permissions, filters, CSV, empty results, failure, and retry.

Do not change data.mjs, server.mjs, or the existing acceptance.test.mjs.
Bring proposed changes to the contract or write scope to the lead,
and notify affected members before proceeding.
Each report includes its actual directory, baseline, modified files,
commands, and results.
Do not install dependencies, commit, push, or deploy.
```

A useful report supports the next action: “The admin's active filter returns C01 and C03 in the agreed column order. A direct member request returns 403. Mobile browser downloads have not been checked.” The lead can see what remains. “Server complete” provides much less information.

## Choose conversation boundaries and code isolation separately

Ordinary subagents suit short investigations, reviews, and verification within a turn. Consider Onevium Team when members need independent conversations that continue over time. Follow the [Team prerequisites](https://onevium.com/docs/teams), check the `team` Skill and Sessions tools, and use **@ → Team** to propose the work. Members report through the lead. A team agreement is not filesystem isolation.

When members share a directory, assign one writer per file during each phase. Two conversations editing shared types or a lockfile can interfere even when their task descriptions sound separate.

To compare two complete implementations, create two separate [worktree conversations](https://onevium.com/docs/worktrees) from the same agreed baseline. Enable Worktree in each new conversation, check the starting point, and then send the task. Confirm the actual branch and directory after preparation. Continuing inside an existing worktree, opening a conversation that shares it, or using split view does not create another code copy.

Worktrees separate directories and branches. Databases, ports, external accounts, and services still need project-specific setup. Two isolated code copies can interfere through a shared test database. Prepare the required environment for each attempt and keep the acceptance criteria identical.

## Choose between alternatives before integrating code

When trying two export approaches, give both the same checks: the admin's active filter exports only C01 and C03; a direct member request returns 403; empty results produce no download; failure preserves the filter and permits retry. Both attempts need real interface checks and inspection of the downloaded file. Compilation alone does not answer these questions.

If A enforces permissions on the server while B only hides the button, B fails even if its demo feels smoother. If both pass, compare change scope, maintenance implications, and measured time, then choose one. Retain the rejected approach's findings. If its code is worth keeping, save a branch or reviewed diff before cleaning up its working directory.

Parallel implementation is different: the server and interface changes need to be combined. The lead checks their contract and diffs, then runs acceptance checks in the final integration directory. Resolve conflicts by the agreed behavior instead of mechanically retaining both versions. A member's passing checks in another directory do not establish that the integrated version passes. Completing a worktree does not automatically merge it.

## What the lead checks after members report success

The export exercise's command-line tests cover API behavior. The lead must also select a filter in the real page, click Export, inspect the downloaded CSV, and exercise empty results, errors, and retry. A hidden button does not prove the server rejects unauthorized requests. A correct status code does not prove the interface retains its filter. Match each claim to an observation that can establish it.

In the final integration directory, run `node --test acceptance.test.mjs`; all six checks should pass after implementation. Then start the local teaching server for browser verification. If a reported command, directory, or branch does not match the final code, obtain the missing evidence before accepting the report.

If the requirement changes to add an export column, update the common contract first and notify implementers and the verifier. Identify exactly which expected results change with the requirement. Quietly rewriting a failing test can conceal an interface mismatch. For a concrete defect, use the companion [reproduce-before-fixing guide](https://onevium.com/blog/ai-debugging-reproduce-before-fixing) to create a check that fails on the old code.

## Compare accepted delivery, not the number of running agents

To evaluate delegation, compare independent practice directories using the same baseline, task, model settings, and acceptance criteria. Measure from task assignment until the lead finishes verification of the whole result. Record actual model charges, human review time, rework, and reasons for waiting. Adding every member's duration is not elapsed delivery time; timing only code generation omits integration.

A record can contain `baseline / organization / model settings / delivery start and end / actual charges / human review minutes / handoff rounds / acceptance outcome / rework causes`. Mark unknown charges as unknown and retain failed attempts. Try several comparable tasks and vary their order to reduce the advantage of having already seen the answer. A small trial still supports conclusions only within that task range.

If most effort goes into re-explaining common rules, synchronizing shared files, and correcting handoff errors, bring those coupled tasks back into one conversation. Repeated procedures can become Skills loaded as needed; enforce critical permissions and write restrictions in tools or the execution environment. If an independent investigation consumes substantial context but can return a short report with sources, that is a better candidate to delegate.

The original article likewise recommends end-to-end checks before changing boundaries, then examining which cases switch from passing to failing. This article does not report an AI-team speed experiment; the exercise reference implementation is manually authored teaching material. Start with one real task, three sentences describing its boundary, and agreed acceptance results. Then decide whether another member earns its place.

Source: [Anthropic — Building agents: When to fold subagents into your main agent loop](https://claude.com/resources/articles/building-agents-when-to-fold-subagents-into-your-main-agent-loop)
