@jc4649/pi-autocompact
pi coding-agent extension: proactive auto-compaction with a configurable, cheap summarization model (formerly deepseek-compact)
Package details
Install @jc4649/pi-autocompact from npm and Pi will load the resources declared by the package manifest.
$ pi install npm:@jc4649/pi-autocompact- Package
@jc4649/pi-autocompact- Version
0.1.0- Published
- Jun 26, 2026
- Downloads
- 105/mo · 7/wk
- Author
- jimmyc4649
- License
- MIT
- Types
- extension
- Size
- 16.7 KB
- Dependencies
- 0 dependencies · 1 peer
Pi manifest JSON
{
"extensions": [
"./index.ts"
]
}Security note
Pi packages can execute code and influence agent behavior. Review the source before installing third-party packages.
README
@jc4649/pi-autocompact
Formerly deepseek-compact.
Proactive, low-cost context compaction for the pi coding agent.
Three lightweight but effective parts:
- Early trigger — compacts at 50% of the context window (capped at 256K tokens), far sooner than pi's default (
window − 16K), so you rarely hit a hard wall mid-task. - Configurable summarizer — summarizes with a cheap model instead of your expensive conversation model. Default DeepSeek V4 Flash; override with
PI_AUTOCOMPACT_MODEL. Falls back to the live session model if the configured one isn't available. - Tool-result stripping — before summarizing, elides bulky non-error tool results from the middle of the compact zone (head/tail, tool calls, and errors are preserved), shrinking what the summarizer has to read.
After an auto-triggered compaction it injects a follow-up turn so the agent resumes the task instead of stalling idle.
Configure the summarizer model
PI_AUTOCOMPACT_MODEL="provider/model" # e.g. anthropic/claude-haiku-4-5
Everything after the first / is the model id (so openrouter/meta/llama-3 works). Unset or malformed → DeepSeek V4 Flash.
Setup
Disable pi's built-in auto-compaction so the two don't double-trigger, in ~/.pi/agent/settings.json (or <project>/.pi/settings.json):
{ "compaction": { "enabled": false } }
Install
pi install @jc4649/pi-autocompact
Part of the pich harness.
License
MIT © 2026 jc4649