Handbooks  /  Long-Horizon Agents
Handbook~14 min readReliabilityworked math + runnable code
Handbook

Long-horizon
agents.

A ten-step task the agent nails every time. A hundred-step version of the same task, and it almost never finishes. Nothing got harder — the steps are identical. What changed is that reliability compounds: a small per-step failure rate, multiplied over a long chain, becomes near-certain failure. The fix isn't a smarter model; it's an engineered one — checkpoint the work, and retry the segment that broke instead of the whole run.

01

The wall: reliability compounds

If each step of a task succeeds with probability p, and the task needs k steps to all go right in a row, the chance of finishing clean is pk. That exponent is brutal. It's the same passk curve that agent evaluation measures — and it means length, not difficulty, is the enemy.

no-checkpoint success = pk  →  p=0.99, k=100 → 37%  ·  p=0.95, k=100 → 0.6%

A 95%-reliable step sounds great until you chain a hundred of them and land under 1%. The math of long horizons is unforgiving to any single-shot run.

The full treatment of measuring this — pass@k versus passk, and how reliability scores over many attempts — lives in the agent-evals handbook. This handbook picks up where measurement ends: given that pk collapses, how do you build an agent that survives it?

02

Checkpointing: don't restart from zero

The first move is to stop treating the task as one indivisible chain. Checkpointing saves the agent's state at intervals — completed subtasks, intermediate artifacts, verified progress — so a failure at step 87 doesn't throw away steps 1 through 86. Without checkpoints, one stumble anywhere means starting over; with them, a stumble costs only the work since the last save.

One long fragile chain vs saved segments
No checkpoint
■■■■✗ → restart ALL
success p^k
vs
Checkpointed
■■│■■✗ → retry last segment
failure is local

A good checkpoint is resumable state: enough that the agent can pick up exactly where it left off, not a vague summary that forces guesswork. The art is choosing what to persist — the durable artifacts and decisions, not the entire scratchpad — so resume is faithful and cheap.

03

Resume + retry: break the exponent

Checkpoints unlock the real win: retry the failed segment, not the whole task. Split the k steps into segments of length c. A segment succeeds with probability pc, and if you can retry a failed segment up to r times, its effective success rises to 1−(1−pc)r. The whole task is then those segments in series:

checkpointed success = [1 − (1 − pc)r]k/c  ≫  pk

Same model, same per-step p. At p=0.95, k=100: the naive run finishes 0.6% of the time; checkpoint every 10 steps with 3 retries per segment and it finishes ~51%. The exponent that was killing you now works segment-by-segment, where retries can beat it.

The key idea

You can't make pk survivable by nudging p — you'd need near-perfection. You make it survivable by shortening the chain that has to hold: small segments, cheap resume, and retries where a failure is local and recoverable. Reliability engineering, not model improvement.

Two dials fall out of the formula. Shorter segments (frequent checkpoints) make each segment more likely to pass on the first try; more retries per segment raise each segment's effective reliability. Both cost overhead, so you tune them against the horizon. The runnable model below lets you turn each dial.

04

The time horizon — and how engineering extends it

The field now tracks an agent's time horizon: the length of task it can complete at some success rate (say, the duration it finishes half the time). It's a headline number because it's been climbing fast — roughly doubling on a regular cadence — and it captures what "more capable agent" actually means in practice: it can carry a longer task before reliability decay wins.

The lesson of this handbook is that horizon isn't only a property of the model. Raw per-step reliability sets a baseline horizon; checkpointing, retries, and verification extend it. An agent that saves progress and retries locally has a longer usable horizon than its bare p would predict. So when the METR-style curve doubles, part of that is better models — and part is better harnesses doing exactly what's above.

05

Why it matters

The agents that will run for hours — refactoring a codebase, conducting deep research, driving a multi-stage workflow — don't win by having a magically reliable model. They win on reliability engineering: checkpoint often, make state resumable, verify between steps, retry the smallest failing unit. It's the same discipline distributed systems learned decades ago (idempotency, retries, checkpoints), now applied to an agent's step chain.

For a builder the takeaway is liberating: you don't have to wait for a perfect model to ship a long-running agent. You have to engineer around imperfect steps. Measure the decay with agent-evals, guard each step with the patterns in agent patterns, and structure the whole loop with a harness that checkpoints and resumes. The horizon you can reach is mostly up to you.

Read next

The measurement half: Agent Evals. The per-step guardrails: Agent Patterns. The loop that runs it: Harness Engineering.

RUN IT YOURSELF

Break the p^k collapse with checkpoints

Long-horizon reliability is one formula and its rescue. A single-shot run of k steps succeeds with probability pk — which collapses as the horizon grows. Checkpoint into segments of c steps and retry a failed segment up to r times, and each segment's success climbs to 1−(1−pc)r, with the whole task their product over k/c segments. Watch a 0.6% success become 51% at the same per-step reliability, and turn the segment-length and retry dials.

CPython · WebAssembly
Frequently asked

Quick answers

Why do long agent tasks fail?

Reliability compounds: a k-step task succeeds with probability p^k. At 95% per step, a 100-step task lands under 1%. The steps aren't hard — the length is, because one failure anywhere derails the whole run.

How does checkpointing help?

It saves progress so a failure doesn't restart from zero. Combined with resume, you break the p^k chain into segments and retry only the failed one — a c-step segment retried r times succeeds 1−(1−p^c)^r.

What is an agent's time horizon?

The task length it can complete at a given success rate (e.g. 50%). It's been doubling on a regular cadence. Reliability engineering — checkpoints, retries, verification — extends the usable horizon beyond raw per-step reliability.

How is this different from agent evals?

Agent-evals measures the decay (pass@k vs pass^k). This handbook engineers around it: checkpointing, resumable state, segment retries, and verification between steps.

Finished this one? 0 / 160 Handbooks done

Explore the topic

See this alongside everything else on the same subject — handbooks, system designs, challenges and tools, in one place.