Open Standard · v1.0 · 2026

COLLAPSE.md

// AI Agent Context Collapse Prevention

A plain-text file convention for detecting and preventing context window exhaustion, model drift, and coherence degradation in AI agents. Define summarization checkpoints, drift thresholds, and recovery protocols — before your agent loses the thread entirely.

COLLAPSE.md
# COLLAPSE   > Context collapse prevention. > Spec: https://collapse.md   ## TRIGGERS   context_window_exhaustion:   threshold_pct: 0.85   action: summarize_and_rotate   model_drift:   drift_threshold: 0.30   action: reset_and_checkpoint   repetition_loops:   max_repeated_tokens_pct: 0.20   action: interrupt_and_log   ## PREVENTION   summarization_checkpoints:   enabled: true   interval_tokens: 40000   preserve_last_n_turns: 5   context_rotation:   strategy: sliding_window   window_size_tokens: 80000
85%
context utilisation threshold: collapse prevention triggers at 85% of window
40K
tokens between automatic summarization checkpoints (configurable)
0.30
drift threshold: cosine distance triggering model re-anchoring
5
most recent conversation turns always preserved verbatim during compression

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.

The problem it solves

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 it works

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.

The regulatory context

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 to use it

Copy the template from GitHub and place it in your project root:

your-project/
├── AGENTS.md
├── COMPRESSION.md
├── COLLAPSE.md ← add this
├── README.md
└── src/

What it replaces

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 reads it

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.

Operational Control
01 / 12
THROTTLE.md
→ Control the speed
Define rate limits, cost ceilings, and concurrency caps. Agent slows down automatically before it hits a hard limit.
02 / 12
ESCALATE.md
→ Raise the alarm
Define which actions require human approval. Configure notification channels. Set approval timeouts and fallback behaviour.
03 / 12
FAILSAFE.md
→ Fall back safely
Define what safe state means for your project. Configure auto-snapshots. Specify the revert protocol when things go wrong.
04 / 12
KILLSWITCH.md
→ Emergency stop
The nuclear option. Define triggers, forbidden actions, and a three-level escalation path from throttle to full shutdown.
05 / 12
TERMINATE.md
→ Permanent shutdown
No restart without human intervention. Preserve evidence. Revoke credentials. For security incidents and end-of-life.
Data Security
06 / 12
ENCRYPT.md
→ Secure everything
Define data classification, encryption requirements, secrets handling rules, and forbidden transmission patterns.
07 / 12
ENCRYPTION.md
→ Implement the standards
Algorithms, key lengths, TLS configuration, certificate management, and FIPS/SOC2/ISO compliance mapping.
Output Quality
08 / 12
SYCOPHANCY.md
→ Prevent bias
Detect agreement without evidence. Require citations. Enforce disagreement protocol for honest, unbiased AI outputs.
09 / 12
COMPRESSION.md
→ Compress context
Define summarization rules, what to preserve, what to discard, and post-compression coherence verification checks.
Accountability
11 / 12
FAILURE.md
→ Define failure modes
Map graceful degradation, cascading failure, and silent failure. Specify health checks and per-mode response procedures.
12 / 12
LEADERBOARD.md
→ Benchmark agents
Track task completion, accuracy, cost efficiency, and safety scores across sessions. Alert on performance regression.

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.

// Domain Acquisition

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 Acquisition

Or email directly: info@collapse.md

COLLAPSE.md is an open specification for AI agent context collapse prevention. Defines TRIGGERS (context window exhaustion at 85%, model drift above 0.30 cosine distance, repetition loops exceeding 20% of output), PREVENTION (40,000-token summarization checkpoints, sliding window context rotation, drift detection every 5 turns), and RECOVERY (checkpoint → summarize → notify → pause → await human approval). Part of the AI safety and quality stack: THROTTLE → ESCALATE → FAILSAFE → KILLSWITCH → TERMINATE → ENCRYPT → ENCRYPTION → SYCOPHANCY → COMPRESSION → COLLAPSE → FAILURE → LEADERBOARD. MIT licence.
Last Updated
11 March 2026