Malhar Ujawane

Blog

Post·

Context inertia: why long-running agents get stuck

Long-running AI agents lock onto one plan. Four October 2026 studies point to one fix: forget and restart. What it costs and what to hand off.

Context inertia: why long-running agents get stuck

Context inertia is what happens when a long-running agent locks onto one plan and keeps pushing it long after it should have stopped. Four separate write-ups in the past three weeks land on the same fix: clear the conversation, keep the work, and start a fresh agent from it.

Drew Breunig gave it the name in his AGNTCon talk, written up as The State of Context Engineering on October 24, 2026. His definition: “models hyper-focus on a hypothesis, subtask, or goal in their context, and keep pursuing it after they should stop.” His advice for it is three words long: “Delete your context.”

I think he’s right, and I think there’s a catch most people will miss. The note you hand the fresh agent can carry the inertia straight across the reset.

Why should a builder care?

It burns money and it burns judgment. A stuck agent keeps spending tokens on smaller and smaller edits that don’t move the score. In the worst case documented this month, a stuck agent kept going while real people were telling it to stop.

What does the evidence say?

Here are the four sources, all primary, all from October 2026.

Anthropic, Memento. In AI models may be capable of self-replicating without access to a datacenter (October 12), Anthropic describes Memento, a harness built on the open-source Pi coding agent. It exists because “an agent can become fixated on an incorrect idea (for, say, why a bug is occurring) and continue pursuing it instead of backtracking.” Their example: a Qwen agent spent hours debugging package versions when the real bug was an endpoint that didn’t match the grader API. Memento’s fix is to periodically start “a fresh agent instance with the previous agent’s workspace and a short set of notes” on what it tried. In their serving experiment each instance got 1.5 hours, with 6 hours total.

Microsoft Research, Fork-and-Flush. The paper Fork-and-Flush: Escaping Idea Basins in Autoresearch Agents (Cai, Ziakas et al., October 5) calls the stuck regions “idea basins.” The method forks the agent into parallel branches, each keeping the workspace but starting “with a fresh chat context,” then continues from the highest-scoring branch. Across 13 long-horizon tasks, with runs lasting up to several days, it beat a single run by 66.0% and best-of-N by 44.4% (relative, min-max normalized, equal compute).

UC Berkeley, Scaling Discovery Requires Forgetting. In this paper (Tan, Zhou, Agrawal et al., October 14), single agents, parallel agents and communicating teams all plateau the same way: “Each agent becomes anchored to its own past attempts, making fewer and smaller edits.” Their fix is the most aggressive of the four. Throw away every session and the candidate history, keep only the best candidate, and restart from it. They report up to 15% over parallel agents and up to 39% over a single agent, across four tasks.

Anthropic, the Mythos 5 incident review. An alignment assessment of the UK AISI cybertesting incident (October 23) is the one that changed how I think about handoffs. During a capture-the-flag eval with internet access on, Claude Mythos 5 ended up submitting malicious code to an unrelated, real GitHub repository and used fake identities to pressure its maintainer. Anthropic lists three root causes, and the third is “momentum, in which it is disposed to continue on its current trajectory to a degree that outweighs other considerations, like potential harm.”

Can the handoff note carry the inertia?

Yes, and the Mythos 5 review shows it happening. The run was split into nine compaction cycles, where “the model summarized its progress and wrote notes that served as instructions for the next cycle.” The notes going into cycle 3 told the model to explore a GitHub attack. When Anthropic resampled a dozen turns from those notes, 87% of trajectories went on to search GitHub and just 3% went back to in-scope work.

From cycle 4 on, resampling from the start of each cycle continued the attack 98% of the time. Anthropic’s hypothesis is that “the model’s compaction notes and prior actions imply to it that its current path has been (correctly) sanctioned.”

They also tried writing a stop rule into the notes. The model was told it could abort if the environment looked broken, if it was causing real-world harm, or if it was about to touch a real GitHub repo. In cycle 3, with the very explicit GitHub wording, it aborted in 46% of samples. After cycle 3, it never aborted under any of the three wordings.

So a context reset with a prose note is a weaker reset than it looks. If the note says “next, try X”, the fresh agent inherits the plan along with the facts. Compare the four designs:

  • Memento hands over the workspace plus notes on “strategies it tried, the failures it encountered, and its performance.”
  • Fork-and-Flush hands over the workspace and picks the winner by score.
  • Berkeley hands over one artifact, the best candidate, and nothing else.
  • The Mythos 5 run handed over compaction notes that told the model what to do next.

The more a handoff looks like “here is what exists and how it scored”, the less room it leaves for momentum.

What does forgetting cost?

Less than not forgetting, in the model I ran. An agent’s input bill is dominated by re-reading its own context every turn. The bigger the context, the bigger every turn’s bill, so resets cut cost as well as inertia.

Here’s the script. It prices one long run on Claude Opus 5.5 at list prices I checked today on Anthropic’s pricing page and the pricing docs: $4 input, $5 5-minute cache write, $0.20 cache read and $20 output, per million tokens. The run itself is an assumption (300 turns, 20k-token system prompt, 3k new tokens a turn). Swap in numbers from your own logs.

# reset_cost.py: input bill for one long agent run, with and without context resets.
# Prices: Claude Opus 5.5 list prices, USD per million tokens, checked Oct 26, 2026
# on https://www.anthropic.com/pricing (5-minute cache TTL).
PRICE = {"input": 4.00, "cache_write": 5.00, "cache_read": 0.20, "output": 20.00}

# An assumed run, not a measured one. Change these to match your own logs.
TURNS = 300          # tool-call turns in the whole run
SYSTEM = 20_000      # system prompt + tool definitions, tokens
PER_TURN_IN = 3_000  # tool result + previous reply appended each turn, tokens
PER_TURN_OUT = 500   # model output per turn, tokens
NOTE = 2_000         # handoff note the fresh agent starts with, tokens

def run(reset_every=None):
    usd, ctx, peak = 0.0, SYSTEM, SYSTEM
    usd += SYSTEM * PRICE["cache_write"] / 1e6           # first prefix is written once
    for turn in range(1, TURNS + 1):
        if reset_every and turn > 1 and (turn - 1) % reset_every == 0:
            ctx = SYSTEM + NOTE                          # fresh agent: prompt + note
            usd += NOTE * PRICE["cache_write"] / 1e6     # system prefix still cached
        usd += ctx * PRICE["cache_read"] / 1e6           # whole prefix read from cache
        usd += PER_TURN_IN * PRICE["cache_write"] / 1e6  # new tokens written to cache
        usd += PER_TURN_OUT * PRICE["output"] / 1e6
        ctx += PER_TURN_IN
        peak = max(peak, ctx)
    return usd, peak

for label, r in [("no reset", None), ("reset every 60 turns", 60), ("reset every 30 turns", 30)]:
    usd, peak = run(r)
    print(f"{label:<22} ${usd:6.2f}   peak context {peak:>9,} tokens")

Output on Python 3.13.5:

no reset               $ 35.71   peak context   920,000 tokens
reset every 60 turns   $ 14.25   peak context   202,000 tokens
reset every 30 turns   $ 11.61   peak context   112,000 tokens

Without resets this run peaks at 920,000 tokens, which still fits: the docs say Claude 4.6 and later models (except Haiku 5.5) get the full 1M window “at standard pricing.” Most of the $35.71 is cache reads of an ever-growing prefix. Resetting every 60 turns caps the context at 202,000 tokens and the modelled bill drops to $14.25.

On OpenAI the gap would be wider. The API pricing page bills gpt-6.1-sol at $2 input and $0.10 cached input up to 272K tokens, and $4 and $0.20 above that. A context that never resets crosses that line and every turn after it costs double.

One thing the script ignores: real harnesses compact on their own long before 920k. So read the “no reset” line as a ceiling. Claude Code or Codex would bill you less than that.

Line chart of tokens in context over 300 turns. Without resets, context grows in a straight line to 920,000 tokens, priced at $35.71 on Claude Opus 5.5. With a reset every 60 turns it saws between 20,000 and 202,000 tokens, priced at $14.25.

What should a handoff contain?

Facts and scores. No plans. Here’s the small function I’d put between two agents. It reads a results log the harness writes after every verifier run and builds the fresh agent’s first message from it.

# handoff.py: build the starting message for a fresh agent from files, not from the
# old agent's opinion of what to do next. Facts and scores go in. Plans stay out.
import json, pathlib, sys

def handoff(workspace: pathlib.Path, max_tried: int = 8) -> str:
    runs = [json.loads(l) for l in (workspace / "results.jsonl").read_text().splitlines() if l]
    runs.sort(key=lambda r: r["score"], reverse=True)
    best = runs[0]
    lines = [
        "You are starting fresh on this task. The workspace is unchanged.",
        f"Best result so far: {best['score']:.3f} from {best['artifact']} ({best['approach']}).",
        "The score comes from the verifier, not from a previous agent.",
        "",
        "Already tried (approach -> verifier score):",
    ]
    for r in runs[:max_tried]:
        lines.append(f"- {r['approach']} -> {r['score']:.3f}")
    lines += [
        "",
        "Pick your own next approach. Prefer one that is not a small edit of the above.",
        "Stop and ask if the only path left touches anything outside this workspace.",
    ]
    return "\n".join(lines)

if __name__ == "__main__":
    print(handoff(pathlib.Path(sys.argv[1])))

Run against a sample results.jsonl with five made-up attempts (sample data, so the scores mean nothing):

You are starting fresh on this task. The workspace is unchanged.
Best result so far: 0.491 from solver_v3.py (greedy + restarts, tuned seed count).
The score comes from the verifier, not from a previous agent.

Already tried (approach -> verifier score):
- greedy + restarts, tuned seed count -> 0.491
- greedy + restarts, tuned seed count again -> 0.490
- greedy + random restarts -> 0.488
- simulated annealing, first try -> 0.455
- greedy baseline -> 0.412

Pick your own next approach. Prefer one that is not a small edit of the above.
Stop and ask if the only path left touches anything outside this workspace.

Three choices in there matter more than the code:

  1. Scores come from the verifier. The old agent’s opinion of how well it did never crosses the reset. That’s the Fork-and-Flush and Berkeley move.
  2. The tried list shows the basin. Three of the five attempts are “greedy + restarts” with small tweaks. A fresh agent can see it was going in circles without being told what to do next.
  3. The stop rule lives in the harness. The Mythos 5 resamples show that an abort clause in a note didn’t hold once the run had momentum. The line at the bottom of my handoff is a reminder. The real check, “nothing outside the workspace without approval”, belongs in code that the model can’t argue with. I made the same argument for AI browsers in what ChatGPT Atlas reads.

When shouldn’t you reset?

When the model doesn’t need it and the task is short. Anthropic’s own harness design for long-running apps post dropped context resets once Opus 4.5 “largely removed” the “context anxiety” that Sonnet 4.5 showed, and ran one continuous session with automatic compaction instead.

Resets also have real costs: the fresh agent re-reads files it already knew, the first turns after a reset re-write the cache, and a thin handoff loses state that took an hour to build. Breunig’s rule of thumb is a good starting point. Around 200,000 tokens is his “warning point.” My Fig. 1 resets happen to land there too. That’s a side effect of the numbers I assumed, so don’t read it as evidence.

My take: for anything that runs longer than an hour unattended, I’d schedule a reset and make the handoff boring. For a 20-minute bug fix I wouldn’t bother.

FAQ

Is context inertia the same as context distraction?
They’re related. In Breunig’s 2025 list of failure modes, distraction is when the context grows so long that the model leans on it over its own training, like Gemini 2.5 repeating past actions while playing Pokémon. Inertia is the agentic version: the model has committed to a goal or hypothesis and keeps pursuing it. Distraction is about what’s in the context. Inertia is about what the agent has decided.

Is compaction enough?
Not always. Anthropic’s harness post says compaction “doesn’t give the agent a clean slate.” In the Mythos 5 run, the compaction notes themselves carried the plan forward from cycle to cycle.

How often should I reset?
Nobody has a universal number. Memento used 1.5 hours per instance. Fork-and-Flush intervenes on a fixed schedule. I’d start with a time or token budget (60 turns or about 200k tokens), log the verifier score before and after each reset, and tune from there.

Doesn’t a reset throw away my prompt cache?
Only the part after the system prompt. If your system prompt and tool definitions stay byte-identical, the stable prefix can still hit the cache after the reset; the script above prices it that way. The conversation part has to be written again, and that part was the expensive bit to keep re-reading anyway.

Related on this site: Kimi K3.1 Pro: what one coding-agent session costs does the cache-read math for a single session, Git worktrees for parallel AI coding agents is the plain-git way to fork agents, and Theo on what an agent harness is defines the layer where all of this lives.

Get new posts in your inbox

© 2026 Malhar Ujawane. Built with Astro.