opencode-active-context
v0.1.0
Published
Active Context Manager — model-driven context compression for OpenCode (MIT)
Maintainers
Readme
opencode-active-context
Active Context Manager for OpenCode — model-driven context compression with a clean MIT implementation.
The model decides when and what to compress — not a hard limit.
Install
opencode plugin opencode-active-context@latest --globalOr add to your opencode config:
{
"plugin": ["opencode-active-context@latest"]
}Important: Disable OpenCode's built-in auto-compaction — ACM handles context management itself.
{ "compaction": { "auto": false } }
How It Works
ACM gives the model a compress tool. When context grows, the model compresses consumed ranges into summaries. The model is 100% responsible for deciding when and what to compress.
Tools
| Tool | Description |
|------|-------------|
| compress | Replace a contiguous message range with a summary block |
| decompress | Restore a compressed block's original content |
| search_context | Search compressed block summaries by keyword |
| acm_status | Inspect context usage, compressible ranges, and block details |
| acm_context_recap | System tool — injects compression summaries as tool-results |
Nudge System
When context grows beyond the threshold, ACM injects a nudge showing:
- Context usage breakdown (tool / summaries / text / code)
- Compressible ranges grouped by conversation turn
- Compression philosophy and HOW TO COMPRESS rules
The nudge frequency adapts to the model's context window (5% of limit, halved after first nudge if model doesn't compress).
Configuration
Config file: ~/.config/opencode/acm.jsonc
{
"enabled": true,
"debug": false,
"notification": "detailed",
"compress": {
"permission": "allow",
"maxContextLimit": "55%",
"minContextLimit": "45%",
"nudgeFrequency": 5,
"protectedTools": ["skill"],
"keepEmbedMaxChars": 2000,
"maxSummaryLength": 10000,
"minCompressRange": 2000
},
"gc": {
"promotionThreshold": 5,
"maxBlockAge": 15,
"maxOldGenSummaryLength": 3000
}
}KEEP/REF Markers
Summaries can reference original content without retyping it:
[[KEEP:m00065]]— auto-expanded to original message content inline (truncated tokeepEmbedMaxChars)[[REF:m00065|description]]— compact link[→ m00065: description]
Commands
ACM provides an /acm slash command:
| Command | Description |
|---------|-------------|
| /acm context | Token usage breakdown |
| /acm stats | Cumulative compression statistics |
Storage
| What | Path |
|------|------|
| State | $XDG_DATA_HOME/opencode/storage/plugin/acm/{sessionId}.json |
| Config | ~/.config/opencode/acm.jsonc |
| Logs | ~/.config/opencode/logs/acm/ |
License
MIT — see LICENSE.
