Autocompact recursion guards

From ychampion/cskill-agents · View interactive version

Autocompact recursion guards is an AI agent skill from the GitHub repository ychampion/cskill-agents. Block autocompact from running in recursive contexts so forks and helpers don’t deadlock.

How to use this skill

Skill file

SKILL: Autocompact Recursion Guards

Domain: context-management

Trigger: Apply when auto-compacting logic runs inside recursive agents (session memory, compact helpers, context collapse) and must avoid deadlocking by re-entering itself.

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

Core Method

Protect the proactive compaction gate with explicit exclusion rules for forked agents and context-specialized modes. Check whether the caller is already within the session_memory or compact subagent, whether a context-collapse or reactive-only mode is engaged, and whether features that manage their own context already control compaction. If any guard trips, return false so the recursion never fires again and the specialized agent can manage its own compaction cycle.

Key Rules

Example Application

When a forked session-memory compactor would otherwise trigger auto-compact, the guard sees query source 'session memory' and returns false, letting the fork run its own compaction without conflicting with the main thread.

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.