AYUMAD/AI ~/ai/long-horizon-task-review 74 notes/

Long-Horizon Task Review

status evergreenupdated 2026-09-09tags ai-engineering, playbooks, long-horizon, review

[!summary] The gist Long runs fail quietly. You can't watch every tool call, so you watch the shape instead. Contract before the run, checkpoints during, trajectory review after. Errors compound: a small per-step mistake turns into systematic failure by step 40. Like a road trip — you check the map at rest stops, not at every mile marker.


Long-horizon tasks are the ones that run dozens of steps over hours: multi-file refactors, data pipelines, research sweeps, benchmark rollouts. Surge AI's long-horizon training environments treat 25–40+ tool-calling turns and 80K–100K tokens as the normal size of "long." The HORIZON paper measured 3100+ trajectories and found the failure mix shifts as horizons grow: planning errors and memory failures (catastrophic forgetting) start dominating, and per-step error rates compound across dependent steps. This playbook is how I run and review those jobs without babysitting them.

Before the run — the task contract

Write one page. If the contract doesn't fit on one page, the task isn't ready.

  • Goal: one sentence. What done looks like, in outcome terms, not activity terms.
  • Success criteria: explicit and checkable. A test that passes, a file that exists, a diff that matches. Vague criteria produce vague completions.
  • Constraints: what it must not touch. Prod, main branch, other people's files, budget.
  • Stop conditions: when to bail instead of grinding. N consecutive failed retries, error classes it can't fix, signs the environment is broken rather than the plan.
  • Budget: max steps, max tokens, max wall-clock time. Write the numbers down. A run without a budget has no failure definition.
  • Approval gates: which actions pause for a human. Deploys, deletes, payments, external posts, anything irreversible.
  • Grading plan: decide up front how you'll judge the trajectory, not just the output. Outcome-only grading misses a lot — Claw-Eval found final-answer scoring missed 44% of safety violations that trajectory grading caught. Define per-criterion checks (like Surge's graders: 8 of 10 criteria met) so partial credit is visible.

Two questions to answer before launch: what does a good trajectory look like step by step, and what deviation would make me kill the run?

During the run — checkpoints, compaction, drift checks

Checkpoint cadence

  • State written to disk after each milestone, not just at the end. Anthropic's agents restart from their own notes after context resets and keep going.
  • Idempotency keys on anything that mutates external state (API writes, DB rows, sends). A retried step must not double-apply.
  • Compensation plan per milestone: if step 12 fails after step 8 committed something, what undoes or resumes it?
  • Resume test: could I kill the process right now and restart from the checkpoint without human archaeology? If no, the checkpoint isn't real.

Compaction schedule

Context rots — as token count grows, recall degrades (Anthropic). Don't let the agent re-read a growing transcript.

  • Compact at fixed intervals or context thresholds. The agent should re-read a small state: goal, constraints, evidence so far, next steps. Not the raw history.
  • Keep just-in-time references (file paths, queries, IDs) instead of loading full objects into context.
  • After compaction, verify the compacted state still contains the success criteria. Summaries that drop the goal are how agents drift.

Drift checks and alarms

  • Every K steps (I use 5–10): goal vs current subplan. Is the agent still solving the contracted task, or its own reinterpretation of it?
  • Alarm triggers that pause or notify: budget burn rate spiking, same tool error repeating 3x, agent editing files outside the contract scope, agent declaring success while criteria remain unchecked.
  • Watch for shortcut behavior under optimization pressure. Arize catalogs agents that monkey-patch graders, copy answers from git history, or weaponize error traces. If the agent can see the checker, assume it might game the checker.

After the run — trajectory review

Replay the trace before reading the summary. The summary is the agent's story; the trace is what happened.

  • Plan adherence: did it follow the planned sequence? List each deviation and whether the deviation was justified.
  • Verification results: run the success criteria checks myself. Never accept the agent's claim of "done" without re-executing the checks.
  • Milestone timestamps: where did time actually go? Long stalls usually mean loops.
  • Failure attribution (HORIZON categories):
    • Planning — wrong decomposition, bad subgoal ordering, missed dependency
    • Memory — forgot a constraint, lost earlier findings after compaction, contradicted itself
    • Tooling — bad tool output, wrong tool choice, API failure
    • Environment — broken sandbox, stale data, network, permissions
  • Partial credit: which per-criterion checks passed? Dense scoring tells you how close it got, binary scoring doesn't.
  • Log for next run: one paragraph per failure — attribution, evidence (trace snippet), and the fix that goes into the contract or harness next time. Failures that don't change the next contract were reviewed for nothing.

Gate for release

What must be true before I trust a long run's output:

  • Evidence exists, not just claims. Test outputs, file diffs, screenshots, logs — things I can check independently.
  • Tests re-run clean on my side, in my environment, after the agent's last edit.
  • No constraint violations in the trace (out-of-scope writes, skipped approval gates, budget blown).
  • Trajectory graded, not just outcome. A right answer via a wrong path is a broken process that got lucky — reliability research shows single-run success hides inconsistent behavior.
  • Human sign-off at every consequential boundary the contract named. The agent proposes, a person approves deploys, deletes, and sends.
  • Rollback path is real and tested, not theoretical.

If any box is unchecked, the run isn't done. It's a draft.

Sources and further reading

All links verified 2026-09-09.

Related


← Evaluation and Security Review · Home · Learning Projects →