compaction
In plain wordsLike replacing a stack of rough notes with a one-page digest: when an AI's conversation grows too long for its memory, the history is condensed into a summary and the work continues from there.
A context engineeringcontext engineering, n.: Managing an AI model's reading material: choosing, trimming and arranging the instructions, documents, tool results and memories it is given on every turn, so that it has what the task needs and little else. technique for work that outgrows the context windowcontext window, n.: How much an AI model can read and keep in view at once: the instructions, the conversation so far and any attached documents. Text that does not fit has to be cut, summarized or left out.: as the accumulated history nears the limit, an agentAI agent, n.: An AI system that does not just answer but acts: given a goal, it decides on steps, uses tools such as a browser or code editor, checks the results and keeps going until the job is done. or its harnessharness, n.: The software around an AI model that gives it instructions and tools, carries out its actions and decides when it stops. The model is the engine; the harness is the rest of the car. has a model write a condensed account of it — goals, decisions taken, open problems and pointers to key files or state — and restarts with that account in place of the full transcript. Choosing what to keep is the hard part: whatever later steps rely on, such as the user's constraints, choices already made and known bugs, must survive, while bulky tool output and superseded drafts can go. Lighter variants simply delete old tool calltool call, n.: A single request from an AI model to use one of its tools — naming the tool and filling in the details — which the surrounding software then carries out and reports back on. results or trim history without summarizing. Compaction can be triggered by the user, automatically at a threshold, or by the model itself, and some models are trained to work across successive compacted windows. Its cost is lossiness: details dropped from a summary are gone unless they were also saved to external memoryagent memory, n.: The ways an AI assistant or agent keeps information — your preferences, past conversations, lessons from earlier tasks — and brings it back later, beyond what fits in a single conversation..
The agent auto-compacted twice during the migration and still remembered which tests were flaky.
Origin
Borrowed from storage and memory management, where compaction reorganizes data to reclaim space. Summarizing chat history to fit a window was common in 2023 frameworks and in MemGPTMemGPT, prop. n.: A 2023 research system that gave a chatbot a computer-style memory hierarchy, letting it move information in and out of its limited working space so it could handle long documents and remember users.; the word attached to the practice in 2025 through coding agents such as Claude Code, which shipped a /compact command at its February 2025 launch and automatic compaction in March, and through Anthropic's September 2025 guide. OpenAI described GPT-5.1-Codex-Max (November 2025) as natively trained to work across multiple context windows through compaction.
Usage note
Not the same as prompt cachingprompt caching, n.: Saving the work a model did reading the start of a prompt, so later requests that begin the same way can skip that reading and come back faster and cheaper., which reuses computation without changing the text, nor as model compressionmodel compression, n.: The family of techniques for making AI models smaller, faster or cheaper to run while keeping almost all of their accuracy.. Because repeated compaction can compound small losses, agents often pair it with notes written to files.
Related
- context engineeringcontext engineering, n.: Managing an AI model's reading material: choosing, trimming and arranging the instructions, documents, tool results and memories it is given on every turn, so that it has what the task needs and little else.
- context windowcontext window, n.: How much an AI model can read and keep in view at once: the instructions, the conversation so far and any attached documents. Text that does not fit has to be cut, summarized or left out.
- context rotcontext rot, n.: The way an AI model becomes less reliable as you give it more and more text to read, even when the answer is in there somewhere.
- agent memoryagent memory, n.: The ways an AI assistant or agent keeps information — your preferences, past conversations, lessons from earlier tasks — and brings it back later, beyond what fits in a single conversation.
- long-horizon tasklong-horizon task, n.: A job that takes many steps and a long time — hours or days of work rather than a single answer — so an AI must stay on track and recover from its own mistakes.
- coding agentcoding agent, n.: An AI agent that writes and fixes software by itself: it reads a codebase, edits files, runs commands and tests, and keeps working until a feature is built or a bug is fixed.
- MemGPTMemGPT, prop. n.: A 2023 research system that gave a chatbot a computer-style memory hierarchy, letting it move information in and out of its limited working space so it could handle long documents and remember users.
- prompt cachingprompt caching, n.: Saving the work a model did reading the start of a prompt, so later requests that begin the same way can skip that reading and come back faster and cheaper.
- model compressionmodel compression, n.: The family of techniques for making AI models smaller, faster or cheaper to run while keeping almost all of their accuracy.
Sources
- Rajasekaran, P., Dixon, E., Ryan, C. & Hadfield, J. (2025). Effective context engineering for AI agents. Anthropic Engineering blog, 29 September 2025. anthropic.com/engineering/effective-context-engineering-for-ai-agents
- OpenAI (2025). GPT-5.1-Codex-Max announcement, 19 November 2025. openai.com/index/gpt-5-1-codex-max
- Anthropic (2025). Managing context on the Claude Developer Platform (context editing and memory tool), 29 September 2025. claude.com/blog/context-management
Mentioned in
context windowcontext window, n.: How much an AI model can read and keep in view at once: the instructions, the conversation so far and any attached documents. Text that does not fit has to be cut, summarized or left out., agent loopagent loop, n.: The repeating cycle at the heart of an AI agent: the model decides what to do next, software carries it out, the result is shown to the model, and the cycle repeats until the task is finished., context engineeringcontext engineering, n.: Managing an AI model's reading material: choosing, trimming and arranging the instructions, documents, tool results and memories it is given on every turn, so that it has what the task needs and little else., context poisoningcontext poisoning, n.: When a mistake or a planted falsehood gets into an AI's working notes or memory and the AI keeps relying on it, so the error grows over later steps., context rotcontext rot, n.: The way an AI model becomes less reliable as you give it more and more text to read, even when the answer is in there somewhere., harnessharness, n.: The software around an AI model that gives it instructions and tools, carries out its actions and decides when it stops. The model is the engine; the harness is the rest of the car., long-horizon tasklong-horizon task, n.: A job that takes many steps and a long time — hours or days of work rather than a single answer — so an AI must stay on track and recover from its own mistakes., scratchpadscratchpad, n.: A space where an AI writes rough working — calculations, plans, notes — before or while producing its answer, much as a person jots on scrap paper., working memoryworking memory, n.: The small amount of information held in mind right now while doing a task. For an AI model, that is roughly whatever currently sits in its context window., Claude Plays PokémonClaude Plays Pokémon, prop. n.: A 2025 livestream in which Anthropic's Claude AI played the classic Game Boy game Pokémon Red by itself, watched by thousands as it struggled and slowly progressed; it inspired similar runs by other models., hookhook, n.: A user-supplied script or check that runs automatically at set moments in an AI agent's work — before a command, after a file edit, when it tries to stop — enforcing rules the AI cannot skip., MemGPTMemGPT, prop. n.: A 2023 research system that gave a chatbot a computer-style memory hierarchy, letting it move information in and out of its limited working space so it could handle long documents and remember users.