Essay · Agent Infra · Interactive

The 30-Hour Agent Is an Infrastructure Problem.

Models can run marathons now. Whether they finish is decided by the loop around them — memory management, resource budgets, watchdogs, checkpoints, and an eval pipeline for runs too long to rerun. The systems engineering of long-running agents, end to end.

Series: Building agents that finish (part 6 of 6)
Also in this series: The Marathon · Agent Memory · The Hippocampus · Memory Needs Forgetting · No Undo Button
The short version

A long-running agent is a process, and processes need an operating system. The model supplies intelligence; everything that makes 30 hours of it survivable — scheduling, memory management, resource limits, crash recovery, supervision — lives in the loop you build around it.

Claude Sonnet 4.5’s 30-hour autonomous runs made headlines as a model capability. Look closer at how such runs actually complete and a different story appears: an initializer that sets up the environment, a loop that forces incremental verified progress, a progress file that survives every context wipe, git as the undo stack, and a harness that decides when to compact, when to checkpoint, when to reset, and when to give up. Anthropic’s own engineering write-up on long-running harnesses is not about the model at all — it’s about the machinery. The model runs the marathon; the infrastructure is the course, the aid stations, and the medical tent.

This post is the systems view of that machinery — the part of the stack my earlier posts kept pointing at: the marathon post proved pacing beats speed, the memory post established what must survive the wipe, the eval post defined what to measure. This one is about the loop that has to do all of it, unattended, at 3am, on step 1,847.

01The loop is an operating system

Strip any serious long-running harness — the Claude Agent SDK’s session loop, an OpenHands-style controller, your homegrown one — and the same skeleton appears, and it’s an OS kernel’s skeleton:

The OS analogy is the design doc
OS conceptAgent-loop equivalentThe failure it prevents
SchedulerStep loop with per-step timeouts and a continue/yield decision after each verified incrementOne mega-step that runs forever and dies with everything in flight
Virtual memoryContext compaction + external memory files — RAM (context) backed by disk (filesystem)Context overflow mid-task; the amnesia reset
ulimits / cgroupsToken and cost budgets per step, per task, per day — enforced by the loop, not requested of the modelThe $4,000 weekend nobody noticed
Checkpoint / snapshotPersist progress file + git commit at every verified milestoneA crash at hour 29 costing 29 hours
Watchdog timerProgress monitor: no verified step in K actions → interveneDoom loops and silent stalls
Supervisor (init/systemd)An outer process that restarts crashed runs from the last checkpoint — Erlang’s “let it crash” applied to agentsBabysitting; 3am pages for recoverable failures

Here’s the whole argument at span level. The ideal run checkpoints and finishes once; the uncheckpointed run pays for its first half twice; the unwatched run buys the same failure seven times:

Two traces, one crash — what checkpoints are actually for

The Erlang line deserves emphasis, because it’s the philosophical unlock: don’t build an agent that never fails; build a supervision tree where failure is cheap. Steps are idempotent, state persists at boundaries, and the supervisor’s job is not to prevent crashes but to make them cost one step instead of one run. Every technique in this post is a corollary.

02Memory management: context is RAM

03Resource management: tokens are the meter

04The run console: watch the infrastructure earn its keep

Below is a simulated 30-hour run under your control. Three pieces of infrastructure can be toggled: compaction (manages the context gauge), the watchdog (catches stalls), and checkpoints (bound the cost of the mid-run crash that will happen). Turn things off and watch how the run dies; turn them on and watch the same failures become log lines instead of postmortems.

Progress · context pressure · token spend — one run, hour by hour

The instructive runs: all three off (the demo configuration everyone ships first), and checkpoints-only (survives the crash, still dies of context). Infrastructure is the difference between “failed at hour 22” and “finished; two incidents, both auto-recovered.”

05Evals for runs you can’t afford to rerun

Here’s the infra problem nobody budgets for: your eval suite is now slower than your release cadence. A 30-hour scenario cannot gate a merge. The answer is the same one systems engineering always gives — a pyramid, plus recording:

The long-running eval pyramid
LayerRuns inWhat it checksGate
Step evalssecondsSingle decisions against golden traces: tool choice, compaction summaries, escalation callsevery commit
Replay scenariosminutesRecorded runs re-executed with recorded tool responses (VCR-style) — deterministic, cheap, offlineevery merge
Checkpoint resumes~an hourBoot from a stored hour-N checkpoint and run one phase live — tests the changed leg, not the whole racedaily
Full marathonshours–days3–5 seeded end-to-end runs; trace metrics (progress-AUC, loop rate, verified pass) plus costnightly / weekly + canary

Two details carry the whole scheme. Recording: every production and eval run persists its full trace and tool I/O, so any failure becomes a deterministic replay test forever — the eval set grows by incident, like the domain-agent golden set. Checkpoint fixtures: stored mid-run states are the long-horizon equivalent of database fixtures — without them, every eval of hour 20 costs 20 hours; with them it costs one. And measure the suite itself: flakiness budgets per layer, because a marathon eval that fails 20% of the time on infrastructure noise will train your team to ignore it — the rubber-stamp problem, again.

The framing I’d push

Stop asking “is the model good enough to run for 30 hours?” It is. Ask “is my loop good enough to be trusted with 30 hours of model?” — enough checkpoints that a crash is boring, enough budget enforcement that a runaway is impossible, enough recorded evals that a regression is caught at the step layer for pennies.

06Where the infrastructure doesn’t save you

· Compaction is lossy, and the loss compounds. Every summary discards something; thirty compactions in, the agent can hold a confident, internally-consistent, subtly wrong picture of its own past. Anchor compaction against ground truth that never compacts — the progress file, the git log, the tests.

· Checkpoints capture state, not the world. Resume an hour-20 checkpoint after the staging database moved on and the agent wakes into a world that contradicts its memory. Checkpoint the environment’s contract (versions, schemas, fixtures) alongside the agent’s state, or resumes become their own failure mode.

· Watchdogs can kill healthy runs. Some legitimate work looks like a stall (long builds, big migrations). Watch verified progress against the plan’s own estimates, not wall-clock silence — and make the watchdog’s first action a checkpoint-and-ask, not a kill.

Takeaways

  1. Build the OS, not just the agent: scheduler, virtual memory, ulimits, snapshots, watchdog, supervisor — every long-running loop needs all six.
  2. Let it crash — cheaply. Idempotent steps + checkpoints at verified milestones turn crashes from postmortems into log lines.
  3. Compact early, spill to disk, keep the prefix stable. Context is RAM; the KV-cache hit rate is the production metric that prices every decision.
  4. Budget tokens like cgroups: per-step ceilings, planner-visible task budgets, daily circuit breakers that yield instead of dying.
  5. Watch verified progress, not activity. Tokens flowing is not work happening — the watchdog triggers on the absence of verification.
  6. Evals are a pyramid on recordings: step evals per commit, VCR replays per merge, checkpoint resumes daily, full marathons nightly — and every incident becomes a replay test forever.
  7. Budget the flakiness of the evals themselves — a noisy marathon suite trains people to ignore it.

The models will keep doubling their horizon. The teams that benefit won’t be the ones with the best prompts — they’ll be the ones whose loop was already built for a run twice as long.

Read next: Your AI Agent Is a Marathoner, Not a Sprinter · Six Agents Finish the Same Task. The Trace Knows Who's Better.

Cite this post
@misc{murugesan2026agent,
  author = {Murugesan, Sugeerth},
  title  = {The 30-Hour Agent Is an Infrastructure Problem.},
  year   = {2026},
  month  = {aug},
  url    = {https://sugeerth.github.io/blog/agent-loop-infra/},
  note   = {Accessed: [date]}
}
SM
Sugeerth Murugesan Staff ML Engineer / Scientist · Intel / Intuit