# Context compaction

> Summarizing a long agent session so it fits the context window again, keeping the decisions and dropping the detail.

_Updated November 23, 2026_

When a session grows long, agents such as Claude Code and Codex can compact it: the conversation so far is replaced by a summary, and work continues with room to spare. Many agents do this automatically near the limit, and offer a `/compact` command to do it on purpose.

Compaction loses detail by design, so anything that must survive (a decision, a constraint) belongs in an instructions file rather than in the chat.

## Keep reading

- [Context window](https://envhaven.com/glossary/context-window)
- [CLAUDE.md](https://envhaven.com/glossary/claude-md)
- [AGENTS.md](https://envhaven.com/glossary/agents-md)

Source: https://envhaven.com/glossary/context-compaction
