Skip to content

actx compact

Run the CTX-ACCE (Agent Context Compaction Engine) to compress, deduplicate, and optimize context entries. Uses the Rust N-API sidecar bridge for native-speed compaction with zone-based pressure strategies.

Terminal window
actx compact --input <path> [options]
OptionDefaultDescription
--input <path>(Required) JSON file containing context entries
--output <path>stdoutOutput path for the compacted result
--model <string>autoModel identifier for pressure calculation (e.g., gpt-4, claude-3)
--level <level>autoCompaction level: none, conservative, moderate, aggressive, emergency, auto
--statsShow before/after token statistics instead of raw entries
--dry-runCalculate pressure and strategies without actually compacting
LevelBehavior
noneNo compaction applied
conservativeDedup and prune only
moderateDedup, prune, delta compression
aggressiveAll strategies including schema collapse and summarization
emergencyMaximum compression — summarize, reorder, and evict aggressively
autoDetermine level automatically based on context pressure zone

The compactor evaluates your context against the model’s effective ceiling (context window × headroom factor):

ZoneStrategies Applied
GreenNone — context fits comfortably
YellowDedup, prune
OrangeDedup, prune, delta, collapse, schema
Red / CriticalAll strategies including summarize and reorder
Terminal window
# Dry run — see what would happen
$ actx compact --input context.json --dry-run
{
"ok": true,
"pressure": 0.72,
"zone": "Yellow",
"strategies_would_apply": ["dedup", "prune"],
"model": "gpt-4",
"effective_ceiling": 57344
}
# Full compaction with stats
$ actx compact --input context.json --stats
{
"ok": true,
"zone": "Yellow",
"tokens_before": 24000,
"tokens_after": 18200,
"savings_pct": 24,
"strategies_applied": ["dedup", "prune"],
"pressure_before": 0.72,
"pressure_after": 0.55
}
CodeMeaning
NAPI_UNAVAILABLERust compactor native addon not compiled
INPUT_NOT_FOUNDInput file does not exist or cannot be read
PRESSURE_FAILEDPressure calculation failed
COMPACT_FAILEDCompaction engine encountered an error