Compact

SkillAI & models

Compact is a skill that lets an agent check how much of the context window is used and schedule compaction, which replaces older conversation history with a dense summary. It is the kernel-side interface to the host's compaction implementation, called from the Python REPL. Use it when context is filling up and substantial work remains, so the session is summarized and the agent keeps working instead of stopping early.

Then ask your AI: use the Compact skill

Details

Instructions available. Your AI can read the instructions. Execution depends on the setup they require.

Have a host that provides compaction and exposes the compact skill.

What your AI can do with it

  • Check current context usage with compact.status()
  • Schedule compaction with compact.run()
  • Pass optional instructions to focus the summary
  • Keep Python variables, imports, and helpers through compaction
  • Resume automatically with the summary plus recent messages

Getting started

  1. Have a host that provides compaction and exposes the compact skill.
  2. Open the Python REPL where the skill is available.
  3. Call await compact.status() to see tokens, context_window, percent, and scheduled.
  4. Call await compact.run() to schedule compaction, optionally with instructions.
  5. Continue the task after the turn ends and the harness resumes you with the summary.

What this skill tells your AI

The instructions your AI receives, as published by primeintellect-ai/prime-agent in skills/compact/SKILL.md and read by Ahel’s review.

Compaction replaces older conversation history with a dense summary, freeing context so long-running work can continue. The implementation lives in the host (the same one behind the user's /compact command); this skill is the kernel-side interface to it. Call it directly from the Python REPL:

await compact.status()
await compact.run()
await compact.run("keep the failing test names and the migration checklist")

API

  • await compact.status() — current context usage as a dict: tokens, context_window, and percent (None right after a compaction until the next model response), plus scheduled (whether a requested compaction is already pending).
  • await compact.run(instructions=None) — schedule compaction. Returns {"scheduled": True}, or {"scheduled": False, "reason": ...} when there is nothing to compact yet. Optional instructions focus the summary on what matters for the remaining work.

Rules

  • Compaction never runs mid-cell. A scheduled compaction runs when the current turn ends; the harness then resumes you automatically with the summary plus recent messages, and you continue the task.
  • The Python kernel persists through compaction — variables, imports, and helpers you defined all remain available.
  • Compact at a natural boundary when context usage is high and substantial work remains, instead of becoming terse or returning to the user early. Check await compact.status() when unsure.
  • One request per turn is enough; calling run again before the turn ends only updates the instructions.

Signals

GitHub stars
22k
Forks
2k
Last commit
Oct 2026

Questions

When should I use compact?
Use it when context usage is high and substantial work remains, at a natural boundary, instead of becoming terse or returning to the user early. Check await compact.status() when unsure.
Does compaction run immediately?
No. Compaction never runs mid-cell. A scheduled compaction runs when the current turn ends, then the harness resumes you automatically with the summary plus recent messages.
What happens to my Python variables and imports?
The Python kernel persists through compaction, so variables, imports, and helpers you defined all remain available.
Advanced
Item type
skill
Key
compact-primeintellect-ai
Source
github.com/primeintellect-ai/prime-agent