Building agentsChapter 5 of 5

What it saves

The short answer

Measure what moving the harness out saves with your own numbers, because it depends on how much of each hour your tools spend running. A sandbox holds its vCPUs for the whole session, and a serverless tool call holds compute only while its command runs. This chapter’s calculator prices both, with Archil’s per-call price. Agents that edit their own environment, long-running services, heavy continuous compute, and calls over Archil’s 5-minute limit still belong in a sandbox.

Hunter LeathFounder & CEO, Archil

9 min readChecked November 2026Read as Markdown

Measure what moving an agent’s loop out of its sandbox saves, because the answer depends on how your own agents spend each hour. When I ran 1,000 agent loops multi-tenanted on one server, with each tool call on Archil’s serverless execution, the CPUs needed at peak came to something like 180. Giving each loop its own sandbox would have needed something like 2,000.From What comes after sandboxes, October 14, 2026. Both numbers are rounded, from one demonstration.

A demonstration isn’t a forecast for your agents. This chapter works through the arithmetic behind numbers like those. It covers what each design holds over an hour, a calculator that prices a fleet for a month, where the calculator’s defaults come from, and the cases where a sandbox is still the better home.

· The demonstration, to scaleEach square is 4 vCPUs. Sandboxes hold every square for the whole session. Serverless tool calls light a square only while a call runs.

The demonstration of 1,000 agent loops, drawn to scale with each square standing for 4 vCPUs. With one agent per 2 vCPU sandbox, all 500 squares, about 2,000 vCPUs, are held from the start of the session to its end. With the harness multi-tenanted on one server and each tool call on serverless execution, squares light up while calls run and go dark when they return. At the peak, 45 squares are held, about 180 vCPUs. The numbers are rounded, from one demonstration.

What each design holds§

An agent in a sandbox holds the sandbox’s full size for every hour the sandbox runs. The model writing its next step, a person reading a diff, and a test suite all hold the same vCPUs. For a fleet, this is one line:

vCPUs held = agents × sandbox vCPUs

With the harness outside, two things hold CPU. The harness host runs all the time, but one process carries many agents, because a harness spends nearly all its time waiting on the model. Many agents, one machine runs many pi sessions in one Node process this way. Each tool call holds its compute only until the command returns. On Archil, that’s a microVM with 2 vCPUs and 4 GiB.The per-command size is in Limits. On average:

tool share = tool calls per hour of session × mean seconds per call ÷ 3,600
vCPUs held = harness vCPUs + agents × tool share × vCPUs per call

The tool share is the only usage term, so it decides the answer. When tools run for a small part of each hour, the outside design holds a small fraction of what the sandboxes hold. When they run for most of it, the two designs converge.

An average isn’t a peak, and you size capacity for the peak. Tool calls from independent sessions overlap at random, so at the busiest moment more are in flight than the average suggests. The explorable in How much one host can take models that moment exactly, and this chapter’s calculator uses the same model. The peak depends on two things: the tool share, and the vCPUs each call holds.

That explains the gap between the demonstration and our own measurements. If each call held 2 vCPUs, a peak near 180 across 1,000 sessions means fewer than 90 calls in flight at the busiest moment, which fits a tool share of about 6%. Our engineering team’s agents are busier. At the tool share of our median loop, that explorable puts the busiest moment for 1,000 sessions near 314 vCPUs.

Dollars follow a different meter. A sandbox bills by the vCPU-hour and GiB-hour for as long as it runs. Archil bills a serverless tool call at a flat $0.05 per 1,000 calls with execution included, however long the command takes within its 5-minute limit.See Pricing & Billing. So the outside design’s CPU follows how long your calls run, and on Archil its bill follows how many you make.

· One hour, held two waysThe sandbox holds its vCPUs all hour. Each call holds a microVM only while it runs, and the one long call holds the largest share.

One hour of one agent’s session. A 2 vCPU sandbox holds 120 vCPU-minutes. The hour has 75 tool calls, our measured rate per hour of sandbox time, in an example shaped like our measured loops: 50 of half a second, 23 of 2 to 60 seconds, one of 4 minutes, and one of 10.5 minutes. That’s about 21.5 minutes of tool time, between model turns and three waits on a person. At 2 vCPUs per call, the calls hold 43 vCPU-minutes. About half of that is the 10.5-minute call, which is over the 5-minute limit for a serverless call and has to run in a sandbox.

A fleet, priced§

The calculator runs both designs for a fleet that keeps the same number of sessions open around the clock, and prices a 730-hour month at list prices. Each total has its arithmetic underneath it. It leaves out storage and data transfer; for what the disk costs, see What you pay for.

The fleet and its agents. The defaults are our own coding agents, measured.

1,000
1.3 h
75
17 s

Tool time in calls over 5 minutes

These run in a sandbox, only while they run.

Machines and prices

Sandbox provider

$0.0504 per vCPU-hour, $0.0162 per GiB-hour

Sandbox size, vCPUs · GiB

$0.1656 an hour

Harness host, vCPUs · GiB

$0.76 an hour at Archil's sandbox rates

Agents per harness host

An assumption: measure your own harness.

$0.05

Enterprise pricing is custom.

Agent in a sandbox

vCPU-hours a month1,460,000
Dollars a month$120,888

2,000 vCPUs held all the time · $0.215 per 1.3 h session

vCPUs held:
1,000 sandboxes × 2 vCPU = 2,000
vCPU-hours:
2,000 × 730 h = 1,460,000
Sandboxes:
1,000 × 730 h × (2 × $0.0504 + 4 × $0.0162) = $120,888

Harness outside, serverless tool calls

vCPU-hours a month522,680
Dollars a month$24,700

716 vCPUs held on average, 810 at the busiest moment · $0.044 per 1.3 h session

Tool time:
75 calls/h × 17 s ÷ 3,600 s = 35.4% of each hour
vCPUs held:
1 host × 8 + 1,000 × 35.4% × (50% × 2 + 50% × 2) = 716
Busiest moment:
1 × 8 + 401 calls in flight × 2 vCPU = 810
vCPU-hours:
716 × 730 h = 522,680
Tool calls:
1,000 × 75 × 730 h = 54,750,000 × $0.00005 = $2,738
Long calls:
1,000 × 730 h × 17.7% × $0.1656 = $21,407
Harness:
1 × 730 h × $0.76 = $555

With the harness outside: 2.8 times fewer vCPUs held on average, and 4.9 times less a month.

With the harness outside, the fleet holds 716 vCPUs on average and 810 at its busiest moment in 1,000, against 2,000 for agents in sandboxes all the time: 2.8 times fewer vCPUs held on average. It costs $24,700 a month against $120,888, 4.9 times less a month.

Assumptions: the fleet keeps this many sessions open around the clock, for a 730-hour month. The busiest moment is the one that 999 moments in 1,000 stay under, with sessions independent, as in Many agents, one machine; real traffic bunches up, so watch your own peaks. Each serverless call gets 2 vCPUs. Calls over 5 minutes run in a sandbox of the size chosen, started for the call and stopped after, and every call is also billed per call. Harness hosts are priced at Archil's sandbox rates; any server works. List prices, before storage, network, plan minimums, and free credits.

· Price your fleetSet the fleet, its usage, and the prices. The arithmetic under each total shows where it comes from.

A calculator for a fleet’s month under two designs. At its defaults, 1,000 agents run at once in 1.3-hour sessions, with 75 tool calls per hour of session, 17 seconds each on average, and half of tool time in calls over 5 minutes. The sandboxes are E2B’s 2 vCPU, 4 GiB size at list price, and one 8 vCPU, 16 GiB harness host, priced at Archil’s sandbox rates, carries all 1,000 agents. Agents in sandboxes hold 2,000 vCPUs all the time, 1,460,000 vCPU-hours a month, and cost $120,888, or $0.215 per session. With the harness outside, a tool runs for 35.4% of each hour. The fleet holds 716 vCPUs on average and 810 at its busiest moment in 1,000, 522,680 vCPU-hours a month, and costs $24,700, or $0.044 per session: $2,738 for 54,750,000 tool calls, $21,407 for the long calls’ sandbox time, and $555 for the harness host. That’s 2.8 times fewer vCPUs held on average and 4.9 times less a month. With no calls over 5 minutes, the month costs $3,292, 36.7 times less. The inputs are agents running at once, session length, tool calls per hour, mean tool-call duration, the share of tool time in calls over 5 minutes, the sandbox provider (E2B, Daytona, Modal, or Archil) and size, the harness host’s size, agents per host, and Archil’s price per 1,000 tool calls.

Three of its choices are worth knowing before you trust a number from it:

  • The busiest moment assumes independent sessions. Real traffic bunches up, as when a team starts work at nine, so watch your own peaks before you size a host.
  • Long calls run in a sandbox. The share of tool time you put in calls over 5 minutes runs in a sandbox of the size you chose, started for the call and stopped after it. Those calls are also billed per call, which errs high.
  • The harness host is an assumption. Its price uses our sandbox rates, and its size matches the host in Many agents, one machine. How many agents one host carries depends on what your harness does between model calls, so measure it under load.

Not every sandbox bills a waiting agent’s full size. Vercel Sandbox bills memory for as long as a sandbox is provisioned but CPU only while it’s actively used, and Fly.io Sprites bill only the CPU and memory actually used. Both bill an idle agent far less than a reserved sandbox does. The calculator leaves them out because their meters don’t reduce to a rate per vCPU-hour.From What does an idle agent sandbox cost per hour?, which links each provider’s pricing page.

Where the defaults come from§

The usage defaults are our engineering team’s own coding agents: 30 days of sessions, 384 agent loops, and about 37,000 tool calls, read from timestamps only. We modeled each loop with a sandbox started at its first tool call and stopped after 15 minutes without one, and the calculator’s session is that sandbox time. Those sandboxes would have run for 493 hours, and the tools ran for 174 of them.The method is in Do AI agents need a sandbox running for the whole session?, and the hours are in Where an agent’s hours go. Each default follows from those figures:

  • Session length: 493 hours across 384 loops.
  • Tool calls per hour of session: about 37,000 calls over 493 hours of sandbox time. Counted per hour of activity alone, without the waits on a person that the timer kept the sandbox up through, the rate is about 160.
  • Mean tool-call duration: 174 hours over about 37,000 calls.
  • Tool share: together, those give the share of all loops that the host explorable uses, 35%.
  • Calls over 5 minutes: about half of all tool time, as the next figure shows.
  • Prices: E2B’s default sandbox size at E2B’s list price, and an 8 vCPU harness host carrying 1,000 agents, the count from the demonstration.

The mean sits far higher than the median, because a few long calls hold much of the time:

· Where tool time goesMost calls are short, but the few that run past the serverless cap hold a large share of the time.

How long our agents’ tool calls ran, on a log scale from 0.1 seconds to an hour. The median call took half a second, and 89% finished within 10 seconds. About 1% ran longer than 5 minutes, the limit for a serverless call, and that 1% held about half of all the time tools spent running.

That makes our agents a demanding case. They run builds, test suites, and benchmarks, so their tools stay busy for a good share of each hour, and the calculator’s default saving in CPU is far smaller than the demonstration’s. An agent whose calls look like the median, reading files, searching, and making small edits, spends much less of each hour in tools. Set the mean to a few seconds and the long-call share to zero, and the fleet holds about a tenth of what the sandboxes hold, or less.

To put your own agents in the calculator, measure the two usage inputs where your tools run today. This wrapper goes around whatever function runs a command, in a sandbox or on serverless execution:

TypeScript
type Run<T> = (command: string) => Promise<T>;
 
// Wrap the function your bash tool calls, and record how long each call takes.
// Create it when the sandbox starts, so its hours match what the sandbox bills.
export function measured<T>(run: Run<T>) {
  const started = performance.now();
  const durations: number[] = [];
 
  async function tool(command: string): Promise<T> {
    const t0 = performance.now();
    try {
      return await run(command);
    } finally {
      durations.push((performance.now() - t0) / 1000);
    }
  }
 
  // The calculator's two usage inputs, for the session so far.
  function usage() {
    const hours = (performance.now() - started) / 3_600_000;
    const seconds = durations.reduce((sum, d) => sum + d, 0);
    return { callsPerHour: durations.length / hours, meanSeconds: seconds / durations.length };
  }
 
  return { tool, usage };
}

Collect usage() from many sessions, not one, because a single session’s tool share swings widely.

When the sandbox still wins§

The arithmetic favors the harness outside when tools run for a small part of each hour and every call fits in a short-lived microVM. These cases don’t, and a sandbox is still the right home for them:

  • Agents that edit their own environment. If the agent is meant to change the machine it runs on, its loop and its tools belong together in one sandbox. This is the exception What comes after sandboxes carves out.
  • Long-running services. A dev server, a file watcher, a database, or anything listening on a port has to stay up between calls. A serverless call keeps nothing between calls except what it writes to the disk.
  • Heavy, continuous compute. As the tool share approaches the whole hour, the outside design holds as many vCPUs as the sandbox, and per-call billing loses its edge too. A 2 vCPU, 4 GiB E2B sandbox costs the same as about 3,300 calls an hour, close to one call a second, sustained.From What does an idle agent sandbox cost per hour?
  • Calls over the per-call limit. On Archil, a serverless command that runs past 5 minutes is stopped, and the call returns 504 with Exec timed out.See Serverless execution limits. In our loops, those calls were few but held much of the tool time.
  • Loops where per-call startup matters. Each serverless call starts a microVM, mounts the disk, and begins with an empty client cache, so a search that a warm sandbox answers from memory reads its files again. A model turn hides tens of milliseconds, but a loop of many tiny calls back to back doesn’t. Price and speed has the measurements.

Most agents end up with a split rather than one side. Keep the harness outside, send everyday tool calls to serverless execution, and start a persistent sandbox, with the same disk mounted, only for the step that needs one. A persistent sandbox bills by the vCPU-hour and GiB-hour while it runs and pauses after 30 idle minutes by default, so stop it when the step is done.See Persistent sandboxes and Limits.

· The usual splitEveryday calls go to serverless execution, the step that has to stay up goes to a persistent sandbox, and one disk serves all three.

The harness runs outside any sandbox and carries many agents per process. Everyday tool calls, such as a search, reading a file, running the tests, and a diff, go to serverless execution, one microVM per call, gone when it returns. A dev server goes to a persistent sandbox, which stays up between calls, as would a build longer than 5 minutes. The harness, every call, and the sandbox see the same disk.

Migrating from an in-sandbox agent moves an in-sandbox agent to this shape one step at a time, including what to do with the parts that have to stay up.