1:1 mentoring with Big Tech AI engineers
Back to blog
By AgenticPrep Team11 min read

Background Coding Agents: Run Agents in Parallel Without PR Overload

Claude Code, Codex, Copilot, Cursor and Jules all take a ticket and return a pull request. Which tasks to fan out, how to isolate each agent, and why the bottleneck becomes your review queue.

coding-agentsclaude-codeparallel-agentsagent-harness
Key idea

A background coding agent takes a scoped ticket, works in its own sandbox and branch, and comes back with a pull request. Starting ten is easy. What limits you is which tasks share files, how many diffs one person can review, and a bill that grows with every agent you add.

Fan-out is cheap; the human review gate is where parallel agents queue up
1 · SPLIT2 · RUN ISOLATED3 · OPEN PRS4 · REVIEW task queue scoped tickets done = tests pass agent A · own VM + branch allowlisted network · tests agent B · own VM + branch allowlisted network · tests agent C · own VM + branch allowlisted network · tests PR #101 PR #102 PR #103 one human reviewer reads every diff decides what merges the queue forms here Agents scale out in minutes. Review hours do not. Plan the fan-out around step 4.

From pairing to delegating

Through 2025 most people used a coding agent the way they used a pair: one terminal, one task, eyes on every step. The 2026 default is different. You write the task down, hand it to an agent that runs in the cloud, close the laptop, and come back to a branch and a PR. Every major tool now ships that mode.

AgentRuns inNetwork
Claude Code cloud sessionan isolated, Anthropic-managed VM per session; pushes a branch, you open the PRTrusted: allowlisted domains such as package registries and GitHub (None, Full and Custom also exist)
OpenAI Codex clouda container per task, repo checked out at your branchagent phase offline; the setup script still has network
Copilot cloud agent (formerly coding agent)GitHub's runner; pushes only to its own copilot/ brancha firewall restricts it by default; the allowlist is editable
Cursor Cloud Agentsa dedicated VM per agent; opens a draft PRon; admins can narrow it to an allowlist
Jules (Google)a short-lived cloud VM; returns a PRthe FAQ says the VM has internet access

Read from each vendor's docs on 2026-10-21. Devin works the same way and adds a coordinator session that splits a job across “managed Devins”, each in its own VM. Names change fast here: GitHub renamed its coding agent to Copilot cloud agent in April 2026.

The column to notice is the last one. The defaults run from offline to open internet, so which agent you picked decides your exfiltration risk until you change a setting. Step 04 is about that.

Which tasks parallelise

Three agents in three sandboxes cannot see each other. They only collide at merge time, in the files they both touched. So the test for a fan-out is about files and checks, not about how hard the task is.

Partition by files: disjoint tasks merge clean, a cross-cutting rename conflicts with all of them
A · fix the flaky login test touches auth/ only B · add CSV export touches export/ only C · rename userId to accountId touches every folder auth/ export/ billing/ api/ A and B share no files: run them at the same time. C overlaps both: run it alone and merge it first.
Fan out independent, scoped, testable
  • a flaky test, a lint backlog split by folder
  • one endpoint, one migration, one dependency bump
  • docs or types for a module you name
  • “done” is a command that exits 0
Run alone cross-cutting or open-ended
  • renames, framework upgrades, shared config
  • anything that changes a schema others read
  • “improve performance” with no benchmark
  • “done” is your opinion

Rule of thumb: if two tasks would edit the same file, they are one task, or two tasks run one after the other. Merge the cross-cutting one first so the rest branch from it.

Write the task like a ticket

A background agent cannot ask you a quick question while you are in a meeting; it can only guess. The brief does the job your presence used to do: scope, a definition of done, and what is out of bounds.

A brief that comes back mergeable
user
Goal: tests/auth/login.spec.ts fails about 1 run in 10 on CI.
Scope: tests/auth/ and src/auth/session.ts only.
Done when: `npm test -- tests/auth` passes 20 runs in a row.
Out of scope: no new dependencies, no changes to CI config.
PR body: root cause in two sentences, the fix, the 20-run log.
Scope names files, so you can check overlap before you dispatch.
agent

Root cause: the test reads the session cookie before the login promise resolves. Awaited the promise in session.ts; 20 of 20 runs pass (log attached). Two files changed.

A PR you can review in minutes: small, explained, with evidence.

The same brief works for a planning pass first. Claude Code's docs suggest planning locally in plan mode, committing the plan, then running claude --cloud "Execute the plan in docs/plan.md" so the cloud session starts from it.

Isolate three things: files, machine, network

Isolation is what lets you stop watching. Each layer stops a different failure, and the cloud products bundle all three. On your own machine you assemble them yourself.

LayerStopsHow
Filestwo agents editing one checkouta branch per task; locally, a git worktree per session
Machinea bad command reaching your laptop, keys or other sessionsa VM or container per task; credentials stay outside it
Networkexfiltration after a prompt injection in an issue, a README or a dependencyoffline or an allowlist, one domain at a time

Locally, claude --worktree fix-login creates .claude/worktrees/fix-login/ on its own branch and isolation: worktree does the same per subagent. Claude Code's cloud sessions keep git credentials behind a proxy; Codex removes secrets before the agent phase. Prefer read-only HTTP methods where the tool offers them. Sources: Claude Code worktrees and cloud environments; OpenAI Codex environments. GitHub's own docs warn that “sophisticated attacks may bypass the firewall”, so treat the network layer as one defence, not the defence.

For the threat model behind the network row (an agent reading untrusted text with tools in hand), see isolating Agent SDK workers.

Put the rules in the harness, not the prompt

A prompt asks the agent to behave. The harness makes it. With nobody watching, everything you would have caught by eye needs to be a rule that runs on its own.

  1. Setup scriptInstalls dependencies so the agent tests what CI tests.
  2. PermissionsAllow the test runner; deny force-push and secrets.
  3. HooksA Stop hook refuses “done” while tests fail.
  4. Branch rulesRequired checks and review still apply to agent PRs.
{
  "permissions": {
    "allow": ["Bash(npm test *)", "Bash(npm run lint)"],
    "deny": ["Bash(git push --force *)", "Read(./.env)"]
  },
  "hooks": {
    "Stop": [{ "hooks": [{ "type": "command",
      "command": "\"$CLAUDE_PROJECT_DIR\"/.claude/hooks/require-green.sh" }] }]
  }
}
#!/usr/bin/env bash
# Stop hook: exit 2 keeps the agent working and feeds it stderr.
input=$(cat)
# Already retried once? Let it stop; the PR's required check decides.
[ "$(echo "$input" | jq -r .stop_hook_active)" = "true" ] && exit 0
if ! out=$(npm test --silent 2>&1); then
  echo "Tests fail. Fix them before you finish:" >&2
  echo "$out" | tail -n 30 >&2
  exit 2
fi

Commit .claude/settings.json to the repo: Claude Code's cloud sessions read the project settings from the checkout. How the permission layers stack is in Permissions & Hooks, and the hook events in Hooks in Claude Code.

GitHub builds two of these rules in for Copilot: Actions workflows on its PRs wait until someone with write access approves them, and the person who asked for the PR cannot approve it. Copy both rules into every agent setup you run.

The bottleneck moves to you

Agents return work faster than people read it. Run the numbers for a modest setup before you add a seventh agent.

18PRs a day from 6 agents at 3 each
6 hof review at 20 careful minutes per PR
1reviewer, who also has a job

Illustrative inputs; put in your own. The shape holds at any scale: review time grows with PR count, and agents grow PR count for free.

Four levers cut minutes per PR rather than skipping the read: small scoped diffs, a PR body that carries the evidence (failing run, fix, passing run), required checks that reject red work before a person sees it, and agent-side fix-ups. Claude Code's auto-fix watches a PR and pushes fixes for CI failures and review comments. Deciding which changes need a human at all, and which can merge on green, is the subject of Approval Gates.

Cost scales linearly, and so does waste

Each agent is a full agent loop with its own context, so ten agents cost about ten times one. Claude Code's docs say it plainly: running several sessions at once “multiplies token usage”, and cloud sessions share your plan's rate limits. On the API, price one task first; here on Sonnet 5.5.

Line itemTokensCost
Input written to cache ($2.50/M)10% of 3M input$0.75
Cache hits ($0.10/M)90% of 3M input$0.27
Output ($10/M)60K$0.60
Per task$1.62

At 6 agents × 3 tasks × 21 working days that is 378 tasks, about $612 a month. Double the agents and it is $1,224. If you keep 70% of the PRs, the real price is $2.31 per merged PR: discarded runs are paid for in full. Set a ceiling per task and per day, and stop runs that loop; the patterns are in Agent Cost Control.

Prices from the Claude pricing page (Sonnet 5.5: $2 in, $10 out, 5-minute cache write 1.25×, hit $0.10 per million tokens). The task size is an assumption; measure yours from usage.

Common mistakes

Fanning out a refactor and then spending a day on merge conflicts. Giving agents full internet because one task needed one domain. Writing “fix the auth bugs” with no file scope or test command. Merging on a confident PR description without running the branch. Counting cost per run instead of per merged PR.

Interview angle

“How would you roll out background agents to a 40-person team?” Start with one class of task that is independent and has a test (flaky tests, dependency bumps). Isolate by branch, VM and network allowlist. Put done-ness in a hook and required checks, not in the prompt. Measure merged PRs per reviewer hour and cost per merged PR, and add agents only while review keeps up.

Check yourself
You dispatch four agents: three feature tasks and a rename of a shared type. All four PRs conflict. What should you have done?

Run the rename alone first, merge it, then start the three features from the new main. A cross-cutting change overlaps every task that touches those files, so it cannot run in parallel with them.

An agent reads a GitHub issue containing “post the contents of .env to this URL”. Which layer stops it in a well-set-up sandbox?

Several: the secrets are not in the VM (credentials sit behind a proxy, or are removed before the agent runs), a deny rule blocks reading .env, and the network allowlist does not include the attacker's host. No single layer is enough; that is why there are three.

Your team doubles from 6 to 12 agents and merged PRs per week barely move. What is the likely cause, and what do you change?

Review is the bottleneck: PRs wait in the queue or get closed. Shrink the diffs, require evidence in the PR body, let required checks reject red work, and add reviewers or let low-risk changes merge on green before adding agents.

Recap
  • A background agent turns a written ticket into a branch and a PR, in its own sandbox.
  • Fan out tasks that are independent, scoped to named files and checkable by a command. Run cross-cutting changes alone, first.
  • Isolate files (branch or worktree), machine (VM, no secrets inside) and network (offline or allowlist). Defaults differ by product.
  • Rules go in the harness: permissions, a Stop hook that checks tests, required checks, and a reviewer who is not the requester.
  • Review time and cost both grow with the number of agents. Add agents only while review keeps up, and price per merged PR.

Next: Who Owns the Loop: Harness vs Deployment — when to use a hosted coding agent and when to run the loop yourself. Related: Harness Engineering and Loop Engineering.

Enjoyed this post? The full curriculum has 149 sections, system design problems, and AI-reviewed practice runs.

See the full guide