State, Continuity & Memory Compaction
A typical production engineering task requires 15 to 40 distinct tool invocations across multiple hours. If an agent process crashes, restarts, or switches context, how does it know what was already done and what remains?
In naked model architectures, a restarted session begins with total amnesia. The agent inspects files it already edited, re-implements already finished modules, or accidentally reverts its own work.
Imagine working on a multi-day construction project. If you wake up every morning with total memory loss and have to guess what was built by wandering around the site, you'll end up tearing down finished walls and forgetting the plumbing.
Instead, the foreman leaves a waterproof clipboard on the job site: a checklist of completed rooms, pending tasks, and architectural blueprints (feature_list.json). No matter who starts the shift, they check the clipboard and get straight to work.
1. The Context Compaction Pipeline
Inspect how a harness compresses tens of thousands of tokens of accumulated logs while preserving 100% of the active task state:
2. Anthropic's State-Externalization Pattern: feature_list.json
In Anthropic's research on long-running application development, agents that rely on conversational memory inevitably suffer from amnesia or context anxiety.
The solution is the State-Externalization Pattern: keeping task state outside the volatile LLM context window in structured on-disk files.
Observe how externalized state guides coordination across agent roles:
Planner ingests the user request, inspects repository state, and writes an atomic work order to feature_list.json.
3. Python Compaction Algorithm: Live Interactive Runner
Below is a production compaction engine in Python. Run this live in-browser demo to see how old, verbose tool outputs are pruned while keeping recent turns and state checklists completely intact:
Treat the filesystem as the source of truth, not the context window. Always write task status to feature_list.json and human milestones to progress.txt. When context is cleared or refreshed, reloading these two files restores full autonomous momentum.
Learn how autonomous agents govern multi-step execution in Autonomous Loops & Supervisors.