piagent_
← ~/map

$ cat ~/map/pi-rolling-compaction.md

pi-rolling-compaction

Trigger pi's built-in compaction once context hits a configurable threshold (default 50% of the window) so large-context models get a continuously-maintained rolling summary instead of a near-full cliff-edge.

extensions✓ Oct 16

Facts

repository
github.com/chang47/pi-rolling-compaction ↗
GitHub Stars
★ 0
Forks
0
license
MIT
npm / mo
—
last push
Aug 18, 2026

install

cp rolling-compaction.ts ~/.pi/agent/extensions/

## TL;DR

Codex-style rolling summarization for pi — a single-file extension that triggers compaction at a configurable percentage of the context window (default 50%) instead of near-full, keeping a continuously maintained summary on large-context models.

## Key points

## FAQ

Q Why not just use pi's built-in auto-compaction?

The built-in threshold only fires when the context window is nearly full (contextTokens > contextWindow − 16384 by default) — roughly 98% on large-context models, so in practice compaction never fires and you lose the continuously maintained summary.

Q How do I test that it works?

Force the threshold with PI_AUTOCOMPACT_THRESHOLD=0.5 pi --print 'say ok' for a headless end-to-end run, or PI_AUTOCOMPACT_THRESHOLD=1 pi interactively; you should see the rolling-compaction notice and a compaction entry in the newest session file. On a tiny conversation pi may answer that there is nothing to compact, which is correct behavior.

## References

## Related entries

## Guides

Last updated: Aug 31, 2026