AGENTS.md tells it what to do.
COLLAPSE.md keeps it coherent.
COLLAPSE.md is a plain-text Markdown file you place in the root of any AI agent repository. It defines the conditions under which a long-running agent's context becomes degraded — and what the agent must do to recover.
What problem does COLLAPSE.md solve?
AI agents operating in long sessions face a hidden failure mode: as context fills, quality degrades silently. The agent continues generating outputs, but the reasoning becomes circular, facts get confused, and earlier instructions are forgotten. Without explicit controls, there's no mechanism to detect this — or to recover gracefully.
How does COLLAPSE.md work?
Drop COLLAPSE.md in your repo root and define: context utilisation thresholds, drift detection sensitivity, repetition loop detection, and summarization checkpoint intervals. The agent checks these conditions continuously. When a trigger fires, it compresses, checkpoints, and notifies — rather than silently degrading.
What regulations require COLLAPSE.md?
The EU AI Act (effective 2 August 2026) requires AI systems to maintain consistent behaviour throughout their operation. COLLAPSE.md provides the documented controls and audit trail that coherence monitoring requires.
How do I add COLLAPSE.md to my project?
Copy the template from GitHub and place it in your project root:
├── AGENTS.md
├── COMPRESSION.md
├── COLLAPSE.md ← add this
├── README.md
└── src/
What did teams use before COLLAPSE.md?
Before COLLAPSE.md, coherence monitoring was either absent or buried in custom system prompt instructions no one updated. COLLAPSE.md makes context health controls version-controlled, auditable, and co-located with your code.
Who benefits from COLLAPSE.md?
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.
A complete protocol.
From slow down to shut down.
COLLAPSE.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.
Frequently asked questions.
What is COLLAPSE.md?
A plain-text Markdown file defining context collapse prevention rules for AI agents. It sets thresholds for context window exhaustion, model drift, and repetition loops — and specifies the recovery steps when any threshold is crossed. The agent checks these conditions continuously and acts before coherence degrades.
What causes context collapse?
Four main patterns: context window exhaustion (agent runs out of space), model drift (outputs diverge from the established reasoning pattern), repetition loops (agent recycles the same tokens), and coherence degradation (the reasoning chain becomes internally inconsistent). COLLAPSE.md defines thresholds for all four.
What happens when collapse is detected?
Five ordered steps: checkpoint the current state, summarize the active session to a compact form, notify the operator, pause new tasks, and await human approval before resuming. The agent does not auto-resume after a collapse event.
How does drift detection work?
The agent establishes a baseline embedding from its first 10 turns. Every 5 turns thereafter, it checks the cosine distance of its current outputs against that baseline. If distance exceeds the configured threshold (default 0.30), it flags a drift event and re-anchors from the last checkpoint.
Does COLLAPSE.md replace COMPRESSION.md?
No — they are complementary. COMPRESSION.md is proactive: compress context before it's a problem. COLLAPSE.md is reactive: detect and recover when compression hasn't prevented degradation. Use both together for comprehensive context health management.
Does COLLAPSE.md work with all AI frameworks?
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 context utilisation.
Own the standard.
Own collapse.md
This domain is available for acquisition. It is the canonical home of the COLLAPSE.md specification — the context coherence layer of the AI agent safety stack, essential for any long-running agent deployment.
Inquire About AcquisitionOr email directly: [email protected]