Autocompact circuit breaker

From ychampion/cskill-agents · View interactive version

Autocompact circuit breaker is an AI agent skill from the GitHub repository ychampion/cskill-agents. Break the autocompact retry loop after several consecutive failures to avoid hammering shared APIs.

How to use this skill

Skill file

SKILL: Autocompact Circuit Breaker

Domain: context-management

Trigger: Apply when autocompact failures repeat and the service must stop retrying to avoid API storms.

Source Pattern: Distilled from reviewed session memory, compaction, and context-budgeting implementations.

Core Method

Track consecutive autocompact failures via the caller-provided auto compact tracking state. After each failure, increment the counter, log a warning once the configured limit is reached, and return the updated count instead of throwing. The loop uses this counter to skip further auto-compact attempts as long as the limit is exceeded, effectively acting as a circuit breaker that keeps doomed sessions from flooding the service.

Key Rules

Example Application

After three consecutive failures hitting the context limit, auto compact if needed stops retrying, logs circuit breaker tripped, and the tracker causes the next turn to skip compaction until a successful run resets the counter.

Anti-Patterns (What NOT to do)

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.