← Back to patterns
build

How Anthropic Keeps Agents Coherent Across Context Resets

TRIGGER

Agents performing long-running tasks lost track of progress, dependencies, and strategic decisions across context resets. Even with compaction, subtle context that only became important later was discarded, causing agents to repeat work or make inconsistent decisions.

APPROACH

Claude Code creates to-do lists; custom agents maintain NOTES.md files persisted outside the context window and pulled back in when needed. Claude playing Pokémon demonstrates this at scale—the agent maintains precise tallies across thousands of game steps ('for the last 1,234 steps I've been training my Pokémon in Route 1, Pikachu has gained 8 levels toward the target of 10'), develops maps of explored regions, tracks key achievements, and records combat strategies. After context resets, the agent reads its own notes and continues multi-hour sequences coherently.

PATTERN

Compaction compresses what happened; notes amplify what matters. After context resets, the agent reads its own NOTES.md with tallies, decisions, and next steps. Selective persistence survives resets that automated summarization cannot.

WORKS WHEN

  • Tasks have clear milestones or progress metrics that can be tracked numerically
  • Work spans multiple context windows (hours of continuous operation)
  • Agent can write to persistent storage (files, database, memory API)
  • Strategic decisions made early affect choices much later in the task
  • Task has iterative development pattern where past state informs future direction

FAILS WHEN

  • Tasks complete within a single context window and don't require persistence
  • Agent lacks write access to persistent storage outside the context
  • Notes overhead exceeds their value for short, simple tasks
  • Task context is inherently unstructured and resists summarization into discrete notes
  • Real-time responsiveness is required and note-reading latency is unacceptable

Stage

build

From

September 2025

Want patterns like this in your inbox?

3 patterns weekly. No fluff.