Back to News
RSS feedwww.oreilly.com

Why AI Agents Lose Context and How to Prevent It

Summary

AI tools can silently lose information when a conversation exceeds its fixed-size context window. In the article, Andrew Stellman describes a Gemini mobile session in which earlier notes remained visible in the chat history but were no longer available to the model after the conversation was compacted. Context can be truncated, compressed into a summary, or handled inconsistently, and the system may continue producing confident answers without indicating what it has forgotten. Stellman argues that this problem affects both developers building agents and people using general chatbots. He identifies four practices for preserving important information: separate discovery from polished documentation; create handoff documents before ending a stale session; specify acceptance criteria instead of relying on long procedures; and use specification documents as the shared source of truth between AI tools. In his Quality Playbook, separating behavioral-contract discovery from requirements generation made omissions visible and enabled a later verification pass. Handoff files let independent phases start without relying on prior chat history, while acceptance criteria give an agent a state-based way to determine whether work is complete. Shared specifications reduce drift when different tools handle design, coding, review, or project management, especially when the rationale behind decisions is recorded. Stellman also applies the approach to managing an article backlog with AGENTS.md and CONTEXT.md. The article concludes that externalized files make AI behavior easier to inspect and verify; the open-source Quality Playbook works with GitHub Copilot, Cursor, and Claude Code.