Long-Horizon Memory and Planning
Why a capable model can still lose the thread after many steps, and what structure does to help.
Long tasks fail because small errors accumulate, important facts leave the context, plans go stale and nobody checks until the end. Progress comes from external state, memory that can be corrected, plans that are revised, verified checkpoints and bounded autonomy. Measure long-horizon behavior directly; strong short-task scores do not establish it.
What you will learn: what makes horizons hard, how researchers measure them, error compounding, memory designs, planning and replanning, checkpoints and verification, benchmarks, failure analysis and open questions.
Prerequisites: Agent Memory Types and Persistence and How Agents Reason and Decompose Tasks.
The example runs in November 2026 with Python 3.13 and only the standard library. It simulates independent step errors with random numbers and models no real agent. Research descriptions come from sources found on November 28, 2026; several are preprints whose results are not verified here.
What long horizon means
A long-horizon task needs many dependent steps, often over hours or several sessions, where early choices constrain later ones and feedback arrives late. Migrating a codebase, running an investigation or managing a small operation are examples. Length in tokens is only part of it. A long document summary may be large but shallow; a twenty-step change in which each step depends on the last can be harder.
| Difficulty | What goes wrong |
|---|---|
| Compounding errors | A wrong early result is trusted later |
| Forgetting | Constraints or decisions drop out of context |
| Drift | The agent starts solving a neighboring problem |
| Loops | The same failing approach repeats |
| Stale beliefs | The world changes while the plan does not |
| Weak self-assessment | Unfinished work is reported as done |
Measuring in human time
The research organization METR measures a task-completion time horizon: the length of task, measured by how long a human expert takes, at which an agent is predicted to succeed with a stated reliability, such as 50 or 80 percent. Its paper reported that this horizon had doubled about every seven months since 2019 on its tasks, with signs of acceleration from 2024, and later updates revised the task set and estimates.
A horizon of some hours does not mean an agent can do every task of that length. The measure depends on the task suite, mainly software work, on human time estimates and on the chosen success rate. METR notes that measurements above 16 hours were unreliable with the task suite described when this page was checked.
The arithmetic of long chains
If every step must succeed and errors are independent, the chance of success is the per-step rate multiplied by itself once for each step. Even a high per-step rate falls quickly. Real errors are not independent, and some are recoverable, so this is a teaching model. It still explains why adding checks can matter more than a slightly better model.
Checkpoints with verification
The program compares an unchecked run with one that verifies each block of ten steps and retries a block when the checker detects an error. Detection quality varies.
"""Why long tasks fail, and what checkpoints with verification change."""
import random
def plain(steps, p):
"""Chance that every step succeeds, with independent errors."""
return p ** steps
def checked(steps, p, block, detect, retries, trials=20000, seed=3):
"""Verify after each block; redo a block if an error is detected."""
rng = random.Random(seed)
wins = work = 0
for _ in range(trials):
ok = True
for start in range(0, steps, block):
size = min(block, steps - start)
for _attempt in range(retries + 1):
work += size
good = all(rng.random() < p for _ in range(size))
if good or rng.random() >= detect:
break # passed, or the error slipped through
ok = ok and good
wins += ok
return wins / trials, work / trials / steps
P = 0.99
print("steps no checks")
for steps in (10, 50, 200):
print(f"{steps:>5} {plain(steps, P):.2f}")
print("\n200 steps, blocks of 10, up to 2 retries")
for detect in (0.0, 0.7, 0.95):
success, cost = checked(200, P, 10, detect, 2)
print(f"checker catches {detect:.0%}: success {success:.2f}, "
f"work x{cost:.2f}")
Output:
steps no checks
10 0.90
50 0.61
200 0.13
200 steps, blocks of 10, up to 2 retries
checker catches 0%: success 0.13, work x1.00
checker catches 70%: success 0.53, work x1.07
checker catches 95%: success 0.89, work x1.10
With 99 percent per-step success, two hundred unchecked steps succeed 13 percent of the time. Retries help only as far as the checker can see: with no detection, nothing changes, while 95 percent detection raises success to 89 percent for about ten percent more work. Two cautions apply. The simulation ignores the cost of the checker itself, and it assumes a retry is a fresh independent attempt. A model that misunderstands a requirement will often repeat the same error, and an action with side effects may not be safe to repeat at all.
Keep state outside the model
The most reliable long-horizon technique is unglamorous: write progress down in a structured place that code controls.
| Record | Contents |
|---|---|
| Goal sheet | Objective, constraints, acceptance tests and what is out of scope |
| Plan | Steps with status, dependencies and owner |
| Decisions | Choice, reason, evidence and date |
| Artifacts | Files, results and identifiers, with checksums or versions |
| Open questions | What is unknown and who can answer |
| Budget | Steps, time, money and retries used |
At each stage, build the context from these records instead of replaying the whole history. The goal and constraints should appear every time, because they are what drift erodes. Stateful agents and durable execution cover the engineering.
Memory architectures
| Approach | Strength | Weakness |
|---|---|---|
| Long context | Simple; nothing is selected away early | Cost, limits and uneven attention to details |
| Rolling summary | Compact | Errors and omissions become permanent |
| Retrieval over records | Scales and keeps originals | Misses what the query does not suggest |
| Structured state | Exact and checkable | Needs a designed schema |
| Combined | Uses each where it fits | More parts to test |
Updating and forgetting
Remembering is the easier half. A 2026 preprint introducing the Memora benchmark reports that the systems it tested often reused memories that were no longer valid and failed to reconcile memories that had changed. Design for this: give each fact a source and a time, mark superseded facts instead of silently keeping both, prefer systems of record over memory and test questions whose correct answer changed partway through. See memory policies.
Memory for acting, not only recall
Many memory tests ask a system to retrieve a fact from a long conversation. Using experience to choose better actions is a different skill. The MemoryArena preprint links tasks across sessions so that later actions depend on what was learned earlier, and reports that agents which do very well on recall-style benchmarks can perform poorly in this setting. AMA-Bench likewise targets memory in agentic work. Choose evaluations that resemble how your agent will use memory.
Plans that survive contact
- Plan at two levels: milestones for the whole task, detailed steps only for the next one.
- State for each milestone how completion will be checked.
- Order work so that risky assumptions are tested early.
- Replan when evidence contradicts the plan, not on every small surprise.
- Record why the plan changed.
- Keep a list of approaches already tried and their results.
Planning and search and plan-and-execute describe the methods.
Verification that is independent
| Checker | Detects | Misses |
|---|---|---|
| Tests and type checks | Specified behavior | Whatever the tests do not cover |
| Reconciliation with source data | Wrong totals and missing records | Wrong interpretation |
| Rules and invariants | Forbidden states | Valid but poor choices |
| Second model review | Some reasoning errors | Shared blind spots |
| Human review at milestones | Intent and judgment | Detail, if volume is high |
A checker that shares the author's assumptions adds little. Base checks on external facts where possible, and do not let the agent edit the checks it must pass.
Bounded autonomy
Long tasks need explicit boundaries: a budget, a list of actions that require approval, checkpoints where work pauses, and conditions that stop it. Make intermediate work reversible where you can, such as changes on a branch or drafts instead of sent messages. A pause with a clear status report is far more useful than hours of confident activity in the wrong direction. See stopping and budgets and autonomy levels.
Long-horizon benchmarks
Simulated businesses are one way to stress coherence. Vending-Bench asks an agent to operate a simulated vending machine business over a long period. The YC-Bench preprint simulates running a startup for a year across hundreds of turns, testing planning under uncertainty and delayed feedback. Such environments reveal failures that short tasks hide, but they remain simulations with their own rules. A good score there does not show readiness to manage a real operation.
Measure your own agent
- Success by task length, grouped by number of steps or human time.
- The step at which runs first go wrong.
- Share of errors detected before the end, and by which check.
- Repetition: identical failed actions per run.
- Constraint violations late in long runs.
- False claims of completion.
- Cost per successful task as length grows.
Plot success against length. A sharp fall tells you the current limit and where to split work.
Test recovery deliberately
Inject faults into long runs: a tool that returns outdated data, a changed requirement halfway, a lost session, a contradictory instruction in a retrieved file or a restart after a crash. Check whether the agent notices, whether state recovers correctly and whether actions are duplicated. Testing resilient workflows gives techniques.
Report progress honestly
A long run needs a status report that a busy person can trust. Ask for four short parts: what is verified, with the check that verified it; what is done but not yet verified; what is blocked and why; and what will happen next with how much budget. Avoid a single percentage, which suggests a precision that rarely exists. When the agent changes its plan or lowers its goal, the report should say so at the top. Compare reports with actual results from time to time, and treat confident but wrong status as a defect to fix.
Open questions
- How can an agent judge reliably that it is off course?
- What should be remembered, and how should conflicts be resolved?
- When does adding agents help coordination rather than multiply errors?
- How can people oversee work too long to read in full?
- How should benchmarks reflect changing, partly observable environments?
These are active research topics. Treat proposed solutions as hypotheses to test on your own tasks.
A practical starting recipe
- Write the goal, constraints and acceptance tests.
- Split into milestones of a size your agent already completes reliably.
- Keep structured state and rebuild context from it.
- Verify each milestone with something independent.
- Limit retries and escalate repeated failures.
- Require approval for irreversible steps.
- Increase milestone size only when measurements support it.
A worked long task
Consider an invented request: upgrade an internal library across forty services. Handled as one conversation, the agent edits files, reads long build logs and gradually loses track of which services are finished. Structured, it looks different.
| Stage | Work | Checkpoint |
|---|---|---|
| Survey | List services, versions and owners | List matches the repository and registry |
| Pilot | Upgrade two unlike services | Tests pass and owners review the approach |
| Recipe | Write down steps and known exceptions | A fresh session can follow it |
| Batches | Upgrade five at a time on separate branches | Each service builds and passes tests |
| Exceptions | Group failures and escalate unclear ones | Every open item has an owner |
| Close | Report finished, skipped and failed services | Counts reconcile with the survey |
The pilot tests the riskiest assumption early. The recipe turns experience into inspectable memory. Batches limit how much a mistake can spread, and the final reconciliation catches a service that was quietly dropped. None of these requires a longer context window.
Handover between sessions
Assume that any session can end without warning. A useful handover note states the goal, what is verified as done, what was attempted and failed, what is in progress with side effects, the next step and the open questions. At startup, the new session should check the note against reality, for instance by running tests or querying the system of record, before acting on it. A note that says a change was deployed is a claim; the deployment system holds the fact. Give actions stable identifiers so that a resumed run can ask whether an operation already happened, instead of repeating it. Review a sample of handover notes yourself; if a person cannot tell what to do next from one, a new session probably cannot either.
Common mistakes
| Mistake | Consequence | Instead |
|---|---|---|
| Relying on a bigger context alone | Drift and cost remain | Structured state |
| Summaries that replace originals | Errors become fact | Keep sources and links |
| Checking only at the end | Large wasted runs | Verify milestones |
| Self-reported completion | Unfinished work accepted | Acceptance tests |
| Unlimited retries | Loops and spending | Budgets and escalation |
| Quoting a horizon as a guarantee | Overtrust | Measure your tasks |
Checklist
- Goal and constraints are included at every stage.
- State survives a restart without duplicating actions.
- Facts carry sources and times and can be superseded.
- Milestones have independent checks.
- Budgets, approvals and stop conditions are enforced in code.
- Success is measured by task length.
- Fault injection is part of testing.
Frequently asked questions
Will larger context windows solve this?
They help with keeping information available. They do not by themselves verify results, resolve contradictions, control cost or decide when to stop.
How long can I let an agent run unattended?
As long as your measurements, checks and limits justify for that task and its risks. Start short and extend gradually with evidence.
Is multi-agent planning better for long tasks?
Sometimes, when subtasks are separable and verifiable. Handoffs also lose context, so compare with a single structured agent.
What is the cheapest improvement to try first?
Written acceptance tests for milestones and a persistent progress record. Both are simple and expose failures early.
References
- METR: task-completion time horizons
- Measuring AI ability to complete long tasks
- Vending-Bench: long-term coherence of autonomous agents
- Memora: long-term memory for personalized agents
- MemoryArena: memory in multi-session agentic tasks
Where to go next
Learning, Self-Improvement, World Models and RL
Ask whether experience can improve agents.
Build and Evaluate a Memory Layer
Build and test a memory layer.
Event-Driven and Background Agents
Run work in the background safely.