When Context Collapses: Teaching Agents to Detect and Recover from Lost Memory

AI-generated summary of reporting by Oreilly AI ML Blog. Read the original for the full story.

Why it matters

Agents silently compact their context mid-task and keep working without knowing they've forgotten things; this gives developers a concrete detect-and-recover workflow instead of fragile long sessions.

Read this as

Andrew Stellman, writing on O'Reilly, describes how AI coding agents lose track of work when their 'context window', the model's short-term memory, fills up and old information gets quietly compressed away. He proposes a three-step pattern he calls externalize-recognize-rehydrate: save the agent's progress to files on disk, detect when memory has degraded, and reload from those files. Anyone using tools like Copilot for long, multi-step coding sessions runs into this problem.

Teams building multi-step agentic workflows face silent context loss: when a model's memory window (200K–2M tokens today) fills, it compacts and keeps going without knowing it forgot things, as with a Copilot bug that wiped a session built on Opus 4.6. Stellman's fix, checkpointing state to files so agents can self-recover, reduces rework risk and wasted tokens, costs nothing beyond prompt engineering, and applies to tools teams already run.

Stellman proposes the externalize-recognize-rehydrate (ERR) pattern: periodically write two state layers to disk, 'execution continuity' (current step, cursor, timestamped progress file updated per record) and 'task continuity' (stable goals and constraints), plus JSONL artifact logs. Recognition is the hard part since compaction is silent; agents reload both layers after suspected degradation. Drawn from his open-source Quality Playbook code-review skill, which splits ~15M-token reviews into six file-mediated phases. No benchmarks are given.

Read the original

This summary exists to save you time, not to replace the source.

Key terms

Copilot Opus 4.6 Quality Playbook MS-DOS 3.3 PDP-10 O'Reilly

Was this summary useful?

One click, anonymous. It tells us which summaries to re-run.

Related reading