Agent
Compaction Discipline
by tokencalculator
Enforces safe context compaction for long-running agents. Use whenever an agent run is expected to exceed roughly 40 turns or 100K tokens.
Skill content
Compact on a token threshold, not a turn count. A run with three enormous tool outputs needs compaction sooner than one with thirty small ones. Rules: 1. Carry the ORIGINAL instruction through every compaction verbatim. Never paraphrase it. Goal drift across compactions is the most common long-run failure and this single rule prevents most of it. 2. Summarise into a fixed schema: goal, decisions made, decisions reversed, files touched, current state, next step, open questions. Free-form prose loses exactly the structured detail you need. 3. Keep the last two turns raw. Do not summarise the state the agent is actively reasoning over. 4. Record reversed decisions explicitly, so the fresh context does not retry a dead end. 5. After compacting, verify the next step is still executable from the record alone. If it is not, the record is incomplete.