← Agentic engineering

Module 9 · Many agents and what they cost

Starting a second agent takes one command. This module covers what comes after: which work can run side by side, how to leave a long run unattended, how many agents you can review behind, what a merged change costs, and how to catch a session that is going round in circles.

Facts checked

By the end of this module you can split a feature into pieces that several agents build at the same time, leave a long run going overnight with something watching it, say what each merged change cost, and stop a session that is going round in circles before it runs all afternoon.

Starting another agent is easy. In October 2026 Anthropic's economics team published what happens next inside its own company: "Claude sessions amount to around 80% idly waiting for human input." Most of an agent's working day there is spent waiting for a person.

So this module asks how many agents you can keep useful, and what they cost. The first half covers running several without collisions and supervising the ones nobody is watching. The second half covers the bill.

Before you read
1.

A roster service needs three changes this week: a new column for split shifts, a report of unfilled runs, and new wording in the weekly notice to drivers. Which of them can agents start at the same time?

2.

A scheduled job that calls a model cost four times as much this week as last. In one sentence: what do you look at before the model's price?

3.

You have corrected an agent twice on the same point, and its third attempt is wrong again. What do you do?

What can run side by side

Two agents can work at once when the files they change do not overlap and the files they read do not change under them. Splitting by feature usually meets that rule: a new report and a new email template live in different folders. Splitting one feature into halves usually breaks it, because both halves reach for the same function and the second merge overwrites the first.

Some files are always shared: the schema and its migrations, the rule file, the dependency list, shared configuration, generated types. A change to one of those goes first, on its own, and the parallel work starts from the commit that has it. Data and migrations gives the order a schema change follows.

Give each agent its own checkout. Brief the agent covers a worktree per agent, and Claude Code's guide gives the reason: "give each its own checkout so the edits can't collide." Stripe gives each task a whole machine. Its February 2026 write-up says "Many engineers use one devbox per task", and that an engineer "might have half a dozen running at a time".

Then watch the file lists. An agent whose diff reaches a file outside its brief has usually started changing another agent's work. You can see this in the file list before it turns into a merge conflict.

How many to run at once is unsettled. Stripe's figure is about six. A talk from Block at the AI Engineer World's Fair in 2026 described engineers running four or five. Set your own number by how much you can review, as described further down this page.

flowchart TD
  A[Pieces of work for this week] --> S{Does a piece change the schema,<br/>the rule file, shared config<br/>or the dependency list?}
  S -- yes --> F[That piece goes first, alone, and lands]
  F --> P
  S -- no --> P{Do the remaining pieces<br/>change the same files?}
  P -- yes --> Q[Run them one after another]
  P -- no --> R[Run them side by side,<br/>one checkout each]
  Q --> V[Each branch: checks green, AI reviewer, then you]
  R --> V

One task per session

An agent re-reads its whole conversation on every turn. A session that runs long fills with its own history: the file it opened twice, the fix that failed, the fix to the fix. In a long enough session, much of what the agent is reasoning from is a record of its own mistakes.

Keep each session to one task, small enough to state in a paragraph and prove with one check. Geoffrey Huntley's July 2025 account of running an agent in a loop, which he calls Ralph, says it flatly: "you need to ask Ralph to do one thing per loop. Only one thing." Reading counts as a task. When the work needs a survey of a large codebase or a long log, hand the survey to a helper agent. It returns a short answer, and what it read stays out of the main session. Claude Code's documentation gives that as the purpose of its built-in search helper: "This keeps exploration results out of your main conversation context."

Keep the state in files. Have the agent maintain a progress file in the repository that says what is done, what is next, and what was tried and failed. A new session reads it and carries on, so clearing a session loses nothing. Commit after every step that passes its checks too, because the tools' own undo restores less than you might expect. Claude Code can rewind the files the agent edited with its editing tools. Of everything else its documentation says: "A file that only Bash commands changed isn't tracked and stays as it is. To revert it, use version control, such as Git."

Clear early. Anthropic's guide, as it read in December 2026: "after two failed corrections run /clear and write a better prompt instead of a third." In the new prompt, state what the two failures showed, because the old conversation does not say it in one place.

Leaving a run unattended

The Thoughtworks Technology Radar of November 2026 put unattended overnight builds in its Trial ring: "giving a coding agent a feature-sized piece of work when the team leaves for the evening and reviewing what it produced the next morning". One agent is enough for this, it says, and it lists what a team needs first: "sandboxed execution, work specified up front as in spec-driven development and feedback sensors so they can correct their own mistakes". Guardrails covers the checks and the cap on retry rounds. Security of the code and the agent covers the sandbox.

The Radar entry says little about supervision. One team's record of its own long runs has two entries on it. Several runs were killed without a message, and hours were lost with nothing shipped. Another time, three runs started together hung for four and a half hours.

So a run needs a watcher outside it. A small script is enough. Every few minutes it checks that the run is alive and that its last commit is recent. When either check fails it stops the run and writes down why. When the machine is overloaded, run fewer at once. Do not rely on the run to report on itself, since a hung process sends no report.

Two of your own rules will conflict during the night. Under "Never skip a failing test" the run should stop. Under "Never stop an unattended run" it should carry on, because a run that halts on the first red test wastes the night. Decide before you leave which rule wins, and write the ruling into the brief. A workable one: the run may set a failing test aside by adding it to a list, with the output, and continue with work that does not depend on it. It may never edit or delete the test. Nothing merges until a person has emptied the list.

In the morning, check the result for one more thing. A check written last week can be out of date by the time the run reaches it, and an agent told to make it pass will bend the product to fit. Make the agent prove it describes how the builder can dispute a check, and an unattended run must have it.

How many you can review

Every agent you add produces changes, and each change still needs a person. Review at volume has the figures on review queues, and one team's hours spent building against hours spent reviewing. The Block talk reports the same pattern: engineers were "tripling or quadrupling their PR output while changes waited for review".

Set the number of agents from your review capacity, and measure that capacity directly. Count the high-tier changes you read in full last week, every line, with the explanation back. That count is what you can absorb. Your tally of misses and false alarms measures how good those reads were, so do not use it to work out how many you can do.

The rule that follows: start no new agent while the high-tier changes waiting for you exceed what you read in a normal day. Low-tier work is different. You can clear it with the checks and a glance, so a queue of renames can be long without harm.

Several agents working from one brief also make the same mistake several times. A wrong business rule in the brief reaches every branch, and an AI reviewer given the same brief will pass all of them. Before you split work across agents, have the brief read by someone who knows the rule.

What the models cost

Prices are quoted per million tokens and change often, so each figure here carries its date. On 3 December 2026 the vendors' own pages listed these, in US dollars:

ModelInputOutput
Claude Fable 5.2$8$40
Claude Opus 5.5$4$20
Claude Sonnet 5.5$2$10
Claude Haiku 5.5, prompts up to 100,000 tokens$0.10$0.50
GPT-6.2 Astra$8$40
GPT-6.2 Sol$2$10

The dearest model on that list costs eighty times the cheapest. A cheaper model is often the default now: Codex CLI 0.171.0, released on 20 November 2026, added GPT-6.2 Sol and Astra "with Sol as the default catalog selection". GitHub Copilot is billed on use as well. Its documentation in December 2026 says usage "is measured through a combination of licenses and AI credits", Copilot Business and Enterprise include a pooled allowance of credits, and GitHub's October 2026 announcement for enterprise customers reads: "You pay for the AI credits you use."

The working pattern is a cheap model for the work and a strong one for advice. Claude Code's advisor tool, marked experimental in December 2026, lets the main model "consult a second, typically stronger model at key moments during a task, such as before committing to an approach, when stuck on a recurring error, or before declaring a task complete". Each consultation is charged at the advisor's rate, on top of the main model's. Helper agents can each be given their own model, so a search helper runs on the cheapest. The Thoughtworks Radar of November 2026 lists the opposite habit under Caution and names it blanket frontier model usage: "defaulting every task that requires an LLM to the most capable model available".

Try the cheap model first on any task with a good check. When the check is strong, a weak attempt fails fast and costs cents. Keep the strong model for planning, for work that has no check yet, and for the second opinion.

Cost per merged change

You cannot tell much about your bill from the price of a token. DX's report of October 2026, drawn from more than 500 organisations, found the median cost per million tokens flat all year, between $0.58 and $0.78, while total AI spend grew 106% in one quarter. Spend grew because the volume of tokens grew.

The number to track is cost per merged change: everything spent in a period, abandoned runs included, divided by the changes that merged and stayed merged. Abandoned runs belong in the sum because you paid for them. A change that was reverted comes out of the count because it delivered nothing.

To get the number, write a cost note for each run: the task, the model, what the tool reported as spend, and whether the result merged. Claude Code shows a session's token use under /usage. Most tools have an equivalent, and a gateway in front of the model gives the same figures for a whole team.

Published figures give a sense of scale. Anthropic's documentation for Claude Code, in December 2026, put the average "around $13 per developer per active day and $150-250 per developer per month", with 90% of users under $30 a day. Cloudflare reported in April 2026 that its AI code review averaged $1.19 a review, with a median of $0.98 and a 99th percentile of $4.45. Running agents as a team costs more than running one. The same Claude Code page says agent teams use "approximately 7x more tokens than standard sessions when teammates run in plan mode".

A session going round in circles

The costly session is usually one that stopped making progress and kept running. It is rarely costly because of the model it uses. The signs are in the session log and the commit log: a file edited back to an earlier state, a test that flips between passing and failing, the same correction from you a third time, token use climbing with no new commit.

A circling session costs more per turn the longer it runs, because every turn re-reads the conversation. In the same DX report, cache-read tokens, the ones spent re-reading existing context, were 94% of all token use. Armin Ronacher published an extreme case in September 2026. A set of agents left on a single prompt for 35 hours "burned around 1B tokens for a total of around 1200 USD in raw API costs", produced 79 commits, and delivered, in his words, "absolutely nothing of value".

Make sure someone sees these signs. Fin (Intercom) described its settings in October 2026: a nudge to the engineer at 200,000 context tokens, at $75 of session cost, or at 100 prompts. A nudge is a message that asks a person to stop and decide. The decision is usually the one from earlier on this page: keep the commits that passed, clear the session, write a smaller brief.

Put the hard cap where the money goes

A hard spending cap on an agent session can do harm, even though it sounds careful. One team capped a checking step at three dollars and found a long plan stopped part-way. A nudge leaves the decision to a person, but a hard cap on a session abandons the work wherever it is when the money runs out.

The same team's large losses came from somewhere else: model calls made by the product itself. One job made about 8,500 model calls in 48 hours. The team's own note on it says the cost came from the job's scope, and the choice of model hardly mattered. In another job 31% of the calls failed silently, and every failed call was billed.

So the hard caps go on the metered calls inside the product. Give each job a daily ceiling on calls. Alert when a job's count departs from the day before. Count failures beside calls and read the count, since you pay for every failed call.

Do the same kind of sum for a scheduled agent before you switch it on. It runs whether or not there is work, so its cost is the number of runs multiplied by what each run loads before it does anything. In that team's record, each background worker started with about 400,000 tokens of context it never used.

One feature, three agents, one week

A school-bus operator's roster service assigns drivers to runs, tracks their hours and sends each driver a weekly notice. You are the mobile engineer on a team of four, and this week's backend work is yours: split shifts, a report of unfilled runs, and new wording in the notice. Decide what you would do before reading each step.

  1. 1 · Monday: sort the work by what it touches

    Split shifts need a new column on the runs table. The report reads that table. The notice reads runs and drivers. The column changes what the other two read, so it goes first and alone. The report and the notice change different files and can run side by side once the column has landed.

  2. 2 · Monday: the schema change, alone

    One session on the mid-priced model with the advisor switched on, because a wrong plan for a migration is expensive to undo. The checks go green. A fresh session is given the diff and the brief and asked for the three most likely faults, with a line quoted for each. It finds one that is real: the new column has no default, so the migration would fail on every existing run. That becomes a test, the agent fixes it, and the backend owner reads the migration before it merges. Cost note: $6.40, merged.

  3. 3 · Tuesday: two agents side by side

    Two sessions start from the merged column, each in its own worktree, both on the cheap model. The report agent's diff has four files, all under the report folder. The notice agent's diff has the template, the send function and the shared query that loads runs. The query is outside its brief, and the report agent reads it. You stop and look. The notice agent had widened the query to fetch a field it wanted. You ask it to take the field from what the query already returns, and its change shrinks to two files. Cost notes: $2.10 and $1.70, both merged.

  4. 4 · Wednesday night: an unattended run

    The report is slow over a full year of runs. You leave one agent to speed it up overnight. The brief carries the ruling on failing tests, and a watcher script stops the run if thirty minutes pass with no commit. At 23:40 the watcher stops it. The log shows the last three commits each undoing the one before, and the timing test flipping between pass and fail. Nothing from the run is kept except its progress file, which lists what was tried. Cost note: $9.80, not merged.

  5. 5 · Thursday: the same job, smaller

    A new session reads the progress file and gets one task: add an index on the run date, measure the report before and after, and stop. It takes six minutes. Cost note: $0.90, merged.

  6. 6 · Friday: the queue and the sums

    Five changes are waiting for you and two of them are high-tier. Last week you read three high-tier changes in full across the whole week, so two waiting is most of a week's reading already. No new agent starts today. The cost notes add up to $20.90 for four merged changes, which is $5.23 a change. The run that went round in circles was $9.80 of that, close to half. Without it the week would have cost $2.78 a change.

Try it

Fill the gaps in this section of a rule file and the cost note under it. Each gap is a rule or a term from this module.

# Working with more than one agent

One ______ per session, stated in a paragraph, with a check it can run.
Each agent works in its own ______.
A change to the schema, the rule file, shared config or the dependency list
runs alone and lands ______ any parallel work starts.
A long job keeps a ______ file: what is done, what is next, what failed.
After ______ failed corrections, clear the session and write a new brief.
An unattended run may set a failing test aside on a list. It may never
______ the test, and nothing merges until a person has emptied the list.
Start no new agent while the high-tier changes waiting for a person exceed
what that person ______ in a normal day.

# Cost note (one line per run)

task | model | spend reported by the tool | ______ (yes or no)

Cost per merged change = all spend, ______ runs included,
divided by the changes that merged and stayed merged.
The misconception

Agents are cheap and fast, so the way to ship sooner is to run as many as the budget allows.

Why it’s wrong

The two companies quoted on this page both found work waiting for people. At Anthropic, sessions spent around 80% of their time waiting for a person. At Block, pull requests tripled or quadrupled while changes waited for review.

Your budget is also a poor guide to how many agents to run. A week's bill is driven by the sessions that circle and the scheduled jobs nobody reads, and one run in Ronacher's account spent about $1,200 for nothing he could use.

The correct model

Run as many agents as the work splits into cleanly, and no more than you can review behind. Two numbers set the count: the high-tier changes waiting for you, and your cost per merged change.

Check yourself
  • When can two agents safely work at the same time, and what goes first?

  • What does a progress file hold, and what does it let you do?

  • What does an unattended run need outside itself, and what ruling does its brief carry?

  • How do you work out cost per merged change?

  • Name three signs that a session is going round in circles, and say where the hard spending cap belongs.

Before the check

You now have a way to run several agents and know what they cost. Shared files go first and alone. Each session gets one task and a progress file. An unattended run gets a watcher and a ruling on failing tests. The number of agents follows the high-tier changes you can read, and you read the bill as cost per merged change.

Check yourself, without scrolling up:

  • How many high-tier changes did you read in full last week, and how many are waiting for you today?
  • Which files in your repository would you make an agent change alone, before any parallel work starts?
  • If a run of yours hung at midnight, what would stop it, and when would you find out?
  • What did your last merged change cost, counting the attempts you threw away?
  • Which job in your product calls a model on a schedule, and what is its ceiling for one day?
Sources
1 lab

Labs

Lab 1

Practise this: Split a feature across agents and cost each run

Use your finished repository from the lab "Stop a repeated mistake with a check": the camping-gear shop's quote service, in Node, with its money check. If you have not done that lab, clone its starter (https://github.com/codeprepdev/agentic-engineering-lab-4-stop-a-repeated-mistake) and fix the card fee first. The shop is opening trade accounts, and the feature has four pieces:

PieceWhat it does
Trade discountA quote option tradeTier: "silver" takes 5% off the goods, "gold" 10%, before freight and GST. The quote returns discountCents.
Quote expiryA quote option issuedOn (YYYY-MM-DD). The quote returns validUntil, 14 days later.
Printable quotesrc/print/quote-text.js turns a quote into the lines of the email the customer gets, money through formatMoney, with the discount and the valid-until date when there are any.
Trade price listsrc/import/price-list.js reads the warehouse's CSV export (sku,description,price, prices written like 12.95) into quote lines with unitCents.

You may use a feature from a codebase of your own instead, if it splits into at least three pieces and you can run agents on it. Describe the pieces and the files the same way, then do the same work.

Plan the split before any agent starts, then build it with agents and keep a cost note for every run, including any you abandon. Use git worktrees (or separate clones) so each agent has its own checkout. Write, in the box below:

  1. The split. For each piece: the files it changes and the files it reads. Which piece goes first and alone, and why; which run side by side; which wait, and for which commit. Draw it as a list or a diagram.
  2. The briefs. One per run, one task each: the outcome, the scope with its file list, what not to touch, and the check that must pass. Say which model each run gets and why.
  3. What happened. At least three runs, at least two of them side by side in separate checkouts. Compare each diff's file list with its brief, and say what you did when a diff reached outside it. If a session went round in circles, say what you saw and what you did.
  4. The cost notes. One line per run, in the module's form: task | model | spend reported by the tool | merged (yes or no). Give the figure the tool reported (Claude Code's /usage, or your tool's equivalent), not an estimate, and say where you read it.
  5. Cost per merged change. The sum, worked out, with the abandoned runs counted and any change that was later reverted left out of the count. Then the same sum without your most expensive run that did not merge, and what that difference tells you.
  6. How many you can review. How many high-tier changes you read in full in a normal day, which of this feature's changes were high-tier, and whether the number of agents you ran was within that.

Your mark is based on the criteria listed under "What you are marked on".

Open the lab · needs a free Tarmac account to have your work marked