@adeildo/pi-compact

Keeps a long pi session's context small: hides old tool output, keeping each call so the agent can run it again, and writes pi's compaction summary from the session's board.

Packages

Package details

extension

Install @adeildo/pi-compact from npm and Pi will load the resources declared by the package manifest.

$ pi install npm:@adeildo/pi-compact
Package
@adeildo/pi-compact
Version
6.0.0
Published
Nov 2, 2026
Downloads
2,118/mo · 800/wk
Author
adeildo
License
MIT
Types
extension
Size
36.7 KB
Dependencies
1 dependency · 3 peers
Pi manifest JSON
{
  "extensions": [
    "./src/index.ts"
  ]
}

Security note

Pi packages can execute code and influence agent behavior. Review the source before installing third-party packages.

README

In a long session, every request sends the whole context again, and most of it is old tool output that the agent no longer needs. This package hides that old output and keeps what matters: your words, the agent's words and the decisions. On a week of real sessions, it cut the cost by about a third.

What it does

When a run ends with more than 150k tokens of context, each tool output older than the last 10 turns becomes one line that names its call:

Output hidden to save context, about 4.2k tokens. It came from: read src/view.ts. Run it again if you need it.
  • Your messages, the agent's words, errors and the last 10 turns stay whole.
  • After a prune, the agent gets its board back, so it keeps track of its work.
  • When pi compacts anyway, the board and your last words go on top of the summary unchanged.

Each prune leaves a line in the chat with what it saved, and Ctrl+O lists the calls it hid.

Commands and settings

/prune hides old output when the run ends, whatever the size of the context.

These are on the Compact tab of Alt+S, and stored under compact in ~/.pi/agent/extensions/pi-harness/settings.json.

Setting Default What it does
Hide old tool output on Turns the prune on
On Anthropic's side off On Anthropic models, Anthropic clears old output instead of the prune, and the agent keeps its thinking
Above 150000 How many tokens of context a run must end with to prune
Write it from the board on Puts the board on top of pi's summary, written on the model below. When off, pi uses the session's model
Model auto The model that writes the summary. auto picks the cheapest one of the session's provider

The tab also shows what this session's prunes freed, and how many hidden outputs the agent had to run again. A high share means the prune hides output that the agent still needs.

How it works explains when a prune runs, why it works this way, Anthropic's own clearing, and how it was measured.