omp packages

@tsaokoming/auto-compact0.1.4

Background compaction for Pi using a dedicated model

tsaokoming Published 7 days ago MIT ~409 downloads/mo

Untested on omp

This is a pi package. No one has reported whether it works on omp yet. If you try it, add your result below.

Did it work for you?

Result

One report per person. A new report replaces your old one.

Reports 0

No reports yet.

Readme

auto-compact

npm version

Animated drawing of auto-compact as a machine. Cards stand for context entries in a trough with a percent ruler. At 80%, a gantry reads the older cards and a press makes one summary card while new cards keep arriving. When the turn ends, the summary replaces the old cards and the most recent cards stay.

A Pi package that prepares compaction in the background with a dedicated model. If Pi needs to compact and the prepared result still applies to the active branch, the extension uses it. Otherwise, it runs compaction with the configured model. After compaction succeeds, it reports the model, thinking level, token usage, cost, and elapsed compaction time.

Install

Install from npm:

pi install npm:@tsaokoming/auto-compact

To try it for one session without installing it:

pi -e npm:@tsaokoming/auto-compact

Remove or disable another copy of compact.ts before loading this package so that only one extension handles compaction.

Configure

Add the extension-specific provider, model, and backgroundThreshold fields to the existing compaction object in ~/.pi/agent/settings.json:

{
  "compaction": {
    "enabled": true,
    "reserveTokens": 16384,
    "keepRecentTokens": 16384,
    "provider": "google-vertex",
    "model": "gemini-3.7-flash",
    "thinkingLevel": "high",
    "backgroundThreshold": 80
  }
}
  • provider and model identify the model used for compaction.
  • thinkingLevel controls reasoning effort and defaults to high. Supported values are off, minimal, low, medium, high, xhigh, and max.
  • backgroundThreshold is the context-window percentage at which background compaction begins.
  • enabled toggles this extension. When it is false, the section is missing, or required fields are absent, the extension stays inactive — it notifies once on session start and Pi's standard compaction behavior applies.
  • The remaining fields use Pi's standard compaction behavior.

Pick a model from Pi's model registry. Reload Pi after changing the settings or extension.

Develop

npm install --ignore-scripts
npm run check

License

MIT