pi-tuck

Deterministic compaction for Pi with no model call, plus exact recall of earlier history.

Packages

Package details

extension

Install pi-tuck from npm and Pi will load the resources declared by the package manifest.

$ pi install npm:pi-tuck
Package
pi-tuck
Version
1.16.1
Published
Dec 4, 2026
Downloads
12.4K/mo · 3,535/wk
Author
galyavin
License
MIT
Types
extension
Size
1.1 MB
Dependencies
0 dependencies · 4 peers
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

pi-tuck

Compaction for Pi that calls no model. When the context fills, Pi's own compaction asks a model to write a summary. On a local model that takes minutes, and it can fail. pi-tuck builds the summary from the saved session in a fraction of a second. After the cut, the agent can look up anything the cut removed.

pi install npm:pi-tuck

Results

Each result names the pi-tuck version it measured. Plans and full results are in benchmark/.

Cuts in a fraction of a second

The median cut took 0.081 s. Pi's compaction took 235 s with a local model writing the summary, and 53 s with GPT-6.1 Terra (pi-tuck 1.0.1, 128k window). Every version since still cuts without a model call. Results

Agents solve as many tasks or more

  • SWE-bench Pro, 300 tasks, hosted Nemotron: 207 solved against 191 with Pi's compaction, ahead with 95% confidence (pi-tuck 1.2.0). Results
  • 32k window, 150 tasks: 120 solved against 94, ahead with 95% confidence (pi-tuck 1.0.5). Results

Built for long sessions

Three agents worked for 72 hours on one local model with a 272k window (later 230k): 4,877 requests and 23 cuts. Every agent kept working after every cut. Case study

Now measuring

Long sessions on pi-tuck 1.12, including tokens per solved task. Results will appear here.

Use

Needs Pi 1.2.0 or later and Node.js 22.19.0 or later, on macOS, Linux or Windows. Start a new Pi process after you install or update. No settings are needed: pi-tuck reads the window and limits from Pi's model configuration.

  • Pi's automatic compaction and /compact use pi-tuck.
  • /tuck shows the loaded version, past cuts and where the next cut will happen.
  • After a cut, the agent gets a tuck_recall tool. It finds and reads the original text and tool output, for example { "query": "retry token refresh" }.
  • pi-tuck replaces Pi's footer with a bar that fills toward the next cut. Set "footer": false in pi-tuck.json to keep Pi's footer.
  • /tuck-incident next records the next cut for a bug report.

To pin a release, add its version: pi install npm:pi-tuck@<version> (see Releases). To uninstall, run pi remove npm:pi-tuck. To turn it off without uninstalling, set "compaction": { "enabled": false } in Pi's settings.

How it works

  • A cut replaces older turns in the model's context with a summary. The full session stays saved.
  • The summary keeps the current prompt, the first prompt, recent turns, the newest output of commands a prompt told the agent to run, and pointers to files and tool actions.
  • Files the agent read more than once ride whole after the summary, if the file on disk still matches.
  • At large windows, pi-tuck trims earlier and smaller when that costs less overall. Each summary starts with the previous summary's dialogue unchanged, so a provider's prompt cache can serve that part again.
  • When a reply spends its whole output on thinking, pi-tuck makes room and asks the model to act.
  • On a llama.cpp server that usually serves the prompt from its cache, a large request that finds the cache cold is stopped and resent after a trim, so the server processes the summary instead of the whole context.

Settings, recall options, the footer, small windows and use from code: reference.

Limits

  • Results so far come from SWE-bench-style tasks and one long research run, on Qwen3.8 Flash Next (local, 128k window), DeepSeek V4.1 Flash (32k window), hosted Nemotron (16k room) and a local model (272k and 230k windows). Other models and windows are not measured yet.
  • pi-tuck uses the context window set in Pi's model configuration. If your server's real limit is smaller, set it there.

Development

npm ci && npm run build && npm run check && npm test

See Contributing and the changelog.

Author

Rustem Galyavin · galyavin.com

Credits and license

MIT. pi-tuck grew out of pi-vcc and includes code from pi-blackhole and Pi. See NOTICE.