// AI Agent Context Compression Protocol
A plain-text file convention for managing context window utilisation in long-running AI agents. Define what to compress, what to preserve, compression ratio targets, and coherence verification — so your agent stays sharp as context fills.
COMPRESSION.md is a plain-text Markdown file you place in the root of any AI agent repository. It defines the rules for compressing context when token limits approach — what to keep, what to summarize, what to discard, and how to verify the result.
Long-running AI agents fill their context window with conversation history, tool outputs, and intermediate reasoning. As the window fills, the agent loses access to earlier instructions, forgets decisions made earlier in the session, and degrades in quality. Without compression rules, this is either handled ad-hoc (unreliably) or not at all.
Drop COMPRESSION.md in your repo root and define: when to compress (75% context utilisation or token budget exceeded), what always to preserve (system prompt, active task, last 3 turns), what to compress aggressively (brainstorming, redundant information), and what to discard (completed work, redundant acknowledgements). After compression, a coherence check verifies no critical information was lost.
The EU AI Act (effective 2 August 2026) requires AI systems to maintain consistent and reliable behaviour. COMPRESSION.md provides the documented context management controls that long-session reliability requires.
Copy the template from GitHub and place it in your project root:
Before COMPRESSION.md, context compression was either absent (agent silently degraded), hardcoded in the system prompt, or handled by ad-hoc logic no one documented. COMPRESSION.md makes context management version-controlled, auditable, and transparent.
The AI agent reads it on startup. Your engineer reads it during code review. Your compliance team reads it during audits. Your regulator reads it if something goes wrong. One file serves all four audiences.
COMPRESSION.md is one file in a complete 12-part open specification for AI agent safety. Each file addresses a different level of control and recovery.
A plain-text Markdown file defining context compression rules for AI agents. It specifies when to compress (based on context utilisation and token budgets), what to preserve (system prompt, active task, recent exchanges), what to compress or discard (brainstorming, completed work, redundant acknowledgements), and how to verify the result.
Items in the preserve_always list are never summarized or discarded during compression — they are copied verbatim into the compressed context. This includes the system prompt, active task instructions, the last 3 conversation turns, flagged bookmarks, recent error states, and pending actions.
The agent restores the pre-compression checkpoint, notifies the operator, and escalates to COLLAPSE.md for collapse prevention handling. Compression is rolled back rather than silently completing with data loss.
COMPRESSION.md is proactive — compress context before it becomes a problem. COLLAPSE.md is reactive — detect and recover when context health has already degraded. Use both together. Compression prevents collapse; collapse detection catches what compression missed.
Yes — COMPRESSION.md supports adjustable compression_ratio_targets (light, standard, aggressive), configurable preserve_always lists, and scheduled compression intervals. Each agent project maintains its own COMPRESSION.md tuned for its specific context patterns.
Yes — it is framework-agnostic. It defines the policy; your agent implementation enforces it. Works with LangChain, AutoGen, CrewAI, Claude Code, custom agents, or any AI system that can monitor its own token consumption.
This domain is available for acquisition. It is the canonical home of the COMPRESSION.md specification — the context management layer of the AI agent safety stack, essential for any long-running agent deployment.
Inquire About AcquisitionOr email directly: info@compression.md