Agentic Swarm Coding: Four Agents, One Merge Request
9 min de lectura
Key takeaways
- Agentic swarm coding means splitting one task into dependent subtasks, dispatching each to a parallel coding agent, and merging the outputs into one reviewable merge request.
- A swarm differs from parallel agents in coordination, not concurrency: subtasks are dependent, state is shared, and handoffs are explicit artifacts.
- Decompose into a swarm only when each subtask has its own acceptance criteria and disjoint file scope; otherwise one agent with a good plan wins.
- Git worktrees give each agent an isolated checkout, and merge conflicts between agents are normal output, not a bug.
- Without tooling, three to four agents is the practical ceiling per developer; a coordination layer tracking per-agent state is what makes larger fleets manageable.
Agentic swarm coding is splitting one task into subtasks, dispatching each to a parallel coding agent, then reconciling their outputs into a single reviewable merge request. This article walks one real task end to end: the written task split, two agents editing the same files, the merge conflict that follows, and the review points you hit as the human in the loop.
What is agentic swarm coding?
Agentic swarm coding means decomposing one task into subtasks, dispatching them to multiple coding agents running in parallel, and merging their outputs back into a single reviewable change. Each agent works in isolation, usually on its own branch or git worktree, while a human or orchestrator tracks state, resolves conflicts, and controls the token budget. The difference from opening a few Cursor Cloud Agents (cursor.com) tabs is the coordination layer: task distribution, retries, and review points are explicit instead of living in your terminal tabs. Teams are already doing this by hand. The Ticksly team runs up to thirty Claude Code and Codex sessions on their own servers, paying roughly $8 per merge request at API prices, and describes the cost as "with that many terminal tabs you lose track fast" (dev.to). The economics of that spend pattern are broken down in our guide to coding agent costs.
How does a swarm of coding agents differ from running one agent in parallel?
Running four agents in parallel means four independent tasks, each scoped and supervised by you. A swarm means one task split into dependent subtasks, where agents share state and hand work to each other. The difference is coordination, not concurrency.
Parallel agents: independent tasks, one coordinator (you)
Each agent gets its own branch, its own repo or worktree, and its own acceptance criteria. Nothing depends on a neighbouring agent, so there is nothing to hand off. You are the task distribution layer: you write the prompts, watch the tabs, and decide what retries. The cost is your attention, which is why a fleet of thirty sessions becomes unmanageable without tooling.
Swarm: dependent subtasks, shared state, explicit handoffs
In a swarm, the subtasks form a graph. One agent's output is another agent's input, so handoffs have to be explicit artifacts, not mental notes. Shared state, like a task split document or a state-tracking file, keeps agents from overwriting each other or duplicating work.
| Parallel agents | Swarm | |
|---|---|---|
| Subtasks | Independent | Dependent |
| Coordination | You, manually | Orchestrator + handoff artifacts |
| Shared state | None | Explicit, tracked |
| Merge | N independent MRs | One composed MR |
The trade: a swarm spends tokens on coordination overhead but removes you from the loop between dispatch and review. Aerunit's stories for coding agents are written for this: each story carries its own acceptance criteria so handoffs stay checkable instead of conversational.
When does a task justify a swarm instead of a single agent?
Decompose when the task splits along clean boundaries: independent modules, separate repositories, or a migration plus its test suite. If subtasks share files or depend on each other's output, one agent with a good plan beats four agents overwriting each other. Running four agents on tangled work means they "overwrite each other's work, duplicate each other, and burn your token budget arguing about who is right," as one developer running four agents in parallel describes it (secondshiftdev on Dev.to).
The test: can you write acceptance criteria and a file scope for each subtask before dispatching anything? If yes, a swarm pays off and you review smaller merge requests in parallel. If no, split the thinking from the doing instead, and hand one agent the doing.
A worked example: one task, four agents, one merge request
Take a concrete task: add rate limiting to an API across three repositories — the gateway, the billing service, and the shared config library. One agent can do this, but slowly and with a long context to keep straight. A swarm splits it instead.
Step 1: the task split
You write the decomposition yourself, because splitting the thinking from the doing is the whole trick. The split becomes four tickets with explicit acceptance criteria: implement the limiter in the gateway, wire it into billing, publish the config schema, and write the integration tests. Each ticket names its repo, its files, and what "done" means. Without that last part, an agent left alone for an hour becomes a chaotic intern: fast, eager, and every so often completely wrong.
Step 2: dispatch and isolation (git worktrees)
Each agent gets its own git worktree, so four agents work on four checkouts of the same repo without touching each other's files. The gateway agent and the test agent both branch from main; neither sees the other's commits until merge. This is what keeps parallel agents from overwriting each other's work mid-run.
Step 3: agent outputs and the first drift
Twenty minutes in, the billing agent hits a question the ticket didn't answer: should rate limits be per-user or per-IP? It guesses, picks per-IP, and keeps going. Meanwhile the config agent has been idle for fifteen minutes waiting on an approval prompt. This is the screen-doesn't-tell-you-which-is-which moment. State tracking per agent — running, blocked, drifted — is what turns thirty terminal tabs back into a fleet you can steer.
Step 4: the merge conflict
The gateway and config agents both edited the middleware registration file. Git flags the conflict at merge time, which is the cheap place to catch it. In single-agent work this file would have been edited once, consistently. In a swarm, conflicting edits are normal output, not a bug.
Step 5: review points and the merged change
You resolve the conflict, reconcile per-user versus per-IP with what billing actually implemented, and merge the four branches into one merge request. Reviewing it differs from reviewing one agent's work: you are checking the seams between four decisions, not one continuous change. The details of that review pass are covered in reviewing agent pull requests.
Who coordinates the swarm: the developer, an orchestrator agent, or both?
Splitting the thinking from the doing
The developer sets direction: task split, acceptance criteria, review points. The orchestrator handles dispatch, state tracking, and retries. Practitioners keep stressing this division. As one writeup puts it, "Splitting the thinking from the doing is the whole trick. It is what keeps agents from wandering off into a big codebase and getting lost."
What an orchestrator actually tracks
An orchestrator holds the fleet state humans cannot: which agent owns which subtask, which branch is stale, which approval prompt is blocking, where the token budget stands. The Ticksly team runs up to thirty Claude Code and Codex sessions with three humans supplying tasks and direction, which only works because tooling absorbs the tab-tracking problem.
Aerunit takes that side of the split: it keeps agents on target across repos while you own the judgment calls. More on our approach at the Aerunit blog.
What does reviewing and merging swarm output actually look like?
A swarm run ends with several branches, not one. Each agent's subtask lands as its own merge request with its own diff, so your review queue looks like four small pull requests instead of one large one. Review them in dependency order: shared interfaces and schemas first, feature code second, because a change to a shared type invalidates every diff downstream of it.
Expect conflicts that single-agent work never produces. Two agents editing adjacent files, or both touching a shared module, will collide at merge time even though each diff looked clean in isolation. Rebase the losing branch against the merged one and re-run its tests before approving.
The review itself differs too. You are checking that each subtask stayed inside its acceptance criteria, not just that the code works. An agent that fixed the bug and refactored three unrelated files passed its own test and failed yours. Reject scope creep the same way you would reject it from a human teammate.
What are the failure modes of agent swarm coding and how do you catch them?
Overwrites and duplicated work
Two agents on the same file is the classic failure: one fixes the bug, the other rewrites the same function from a stale read, and the second merge request silently clobbers the first. The catch is structural, not vigilance. Give each agent its own git worktree and a disjoint file list in the task split, and have the orchestrator diff the worktrees against each other before any merge request opens. Tools built for this, like Vibe Kanban, exist to manage parallel agent tasks through a queue rather than raw terminal tabs.
Token budget burn from agents arguing
Left unsupervised, agents retry each other's work, re-read the repo, and drift. Cap retries and context per subtask, and kill any agent whose diff hasn't changed in N minutes.
The agent that waits silently
The worst mode is the quiet one: an agent blocked on an approval prompt for an hour while you think it's working. A team running thirty Claude Code and Codex sessions describes exactly this: "One agent has been waiting for an answer for a while, another has spent three hours fixing the wrong thing, and the screen doesn't tell you which is which." A dashboard with per-agent state and a stale-agent alert catches it.
How do you start with agentic swarm coding on an existing codebase?
Start with one task, not a fleet. Pick a change you would normally delegate to a strong contractor: well-defined acceptance criteria, contained blast radius, tests that fail loudly. Run two agents on two subtasks using separate git worktrees so they cannot overwrite each other, and merge back yourself. That single run teaches you more about state tracking and review points than any orchestrator comparison.
Next, add a coordination layer before you add agents. A dashboard that shows which agent is waiting, which is drifting, and which finished is what makes three parallel agents manageable; thirty terminal tabs do not. Keep the human as the task distributor at first, writing the split by hand.
Only then automate retries and dispatch. If a subtask fails twice, the split was wrong, not the agent. Scale to a swarm when your review step, not your token budget, is the constraint.
FAQ
How many coding agents can one developer realistically manage at once?
Without tooling, three to four is the practical ceiling, since each agent needs its own state check and conflict resolution. With a coordination layer tracking per-agent state, running sessions is a different story: one team runs up to thirty Claude Code and Codex sessions with three humans supplying tasks and direction.
Do I need a special orchestrator tool or can I run a swarm with terminal tabs and git worktrees?
You can start with git worktrees and a hand-written task split, and that first run teaches you the most. The problem is visibility: terminal tabs do not show which agent is blocked, drifting, or stale. Add a dashboard before you add agents, and only automate dispatch and retries once your review step, not your token budget, becomes the constraint.
What does agentic swarm coding cost in API tokens compared to single-agent runs?
A swarm spends extra tokens on coordination: retries, re-reading the repo, and agents arguing about overlapping work. It is not automatically cheaper per task. One team running many parallel sessions reports roughly $8 per merge request at API prices, which is affordable only because tooling caps the waste from duplicated and drifted work.
Can smaller local models like qwen3-coder handle swarm coordination, or do they fall apart across steps?
The model is often the weak link, not the orchestrator. Developers shopping for multi-repo setups report that whether a small model can maintain context and make good decisions across multiple steps matters more than the tooling around it. For dependent subtasks with explicit handoffs, test the model on one multi-step subtask before trusting it with a whole swarm.