SuperAPI AI Directory

context-rot-detection

Monitors agent context health: token utilization, context quality degradation and session fatigue, with 0-100 health scores and recovery recommendations.

Open website

About this tool

Context Rot Detection is an MCP (Model Context Protocol) service designed to give AI agents self-awareness of their own cognitive state. According to the project description, every long-running AI agent encounters "context rot," a measurable performance degradation that occurs as the context window fills up. Research from Chroma, Stanford ("lost-in-the-middle"), and Redis all confirm that this is the primary practical failure mode in production-grade agent systems. An agent in context rot does not know it is degrading; it simply starts making worse decisions. This tool gives agents real-time visibility into their own cognitive health.

Main capabilities include:

  • Health score (0–100), calculated based on token utilization, retrieval accuracy, and session fatigue.
  • Model-specific degradation curves for 15+ curated models (Claude, GPT, Gemini, o-series).
  • Automatic resolution of any HuggingFace model: pass in a repository ID like meta-llama/Llama-3.1-70B, and the context window is automatically detected, with results cached in SQLite.
  • "Lost in the middle" risk scoring based on Stanford research.
  • Tool-call burden and session fatigue analysis.
  • Actionable recovery recommendations—compress context, offload to memory, set checkpoints, split into subtasks.
  • Per-agent health history tracking (SQLite).
  • Service-level utilization statistics.

Installation and usage: The service supports npx (zero-install) and npm (global install). For MCP client configuration, it can be added to .mcp.json in the project root, or to claude_desktop_config.json. Specific configuration examples are not fully shown in the provided materials.

Available tools include three:

  1. check_my_health: Analyzes the current context window health status. It is recommended to call it periodically during long sessions, or before making critical decisions. Example responses are not fully shown in the materials.
  2. get_health_history: Retrieves the health check history for a specific agent.
  3. get_service_stats: Gets service-level utilization statistics, with no parameters required. Returns total call count, number of unique agents, average health score, model distribution, status distribution, and recent activity (last hour/last 24 hours).

Regarding supported models, any model string containing "/" is treated as a HuggingFace repository ID. The server fetches config.json from the repository, extracts the context window size (max_position_embeddings, n_positions, or max_seq_len), and generates a conservative degradation profile: 65% of max tokens is the degradation onset point, and 80% of max tokens is the danger zone. Results are cached in SQLite, and subsequent queries return instantly. If fetching fails (network error, gated model, missing config), the server silently falls back to conservative defaults. Any unrecognized model string that does not contain "/" also falls back to conservative defaults (128K max, 100K danger zone).

The health score is a weighted combination of four signals, but the specific contents of these four signals are not fully listed in the materials. The degradation curves are derived from empirical research: Chroma's Context Rot indicates that quality declines at approximately 147K–152K tokens on a 200K model; Stanford's Lost in the Middle indicates that information retrieval accuracy declines in the middle of the context window; Redis's Context Rot indicates that long-running agents experience cumulative degradation effects.

Applicable scenarios: Suitable for long-running AI agent systems, helping agents monitor their own health status as the context window fills, and avoid decision quality degradation caused by context rot. Limitations: The materials do not provide specific pricing, cost, platform, effectiveness, or complete usage steps; some example responses and configuration details are not yet provided.