← Catalog

@jc4649/pi-autocompact

pi coding-agent extension: proactive auto-compaction with a configurable, cheap summarization model (formerly deepseek-compact)

Extension

Install

Install with PiG

pig install npm:@jc4649/pi-autocompact

Install with Pi

pi install npm:@jc4649/pi-autocompact
Review before installing

Packages run code with your permissions and influence agent behavior. Catalog inclusion is not a security audit. Review the source before installing a third-party package.

Pi manifest JSON

The pi field of package.json.

{
  "extensions": [
    "./index.ts"
  ]
}

README

Written by the package's publisher, shown as published in version 0.1.0 (README.md). PiG does not review it.

@jc4649/pi-autocompact

Formerly deepseek-compact.

Proactive, low-cost context compaction for the pi coding agent.

Three lightweight but effective parts:

  1. 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.
  2. 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.
  3. 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