r/PiCodingAgent • u/zaph0d • 16d ago
Plugin pi-percy: Automatic compaction extension for long running sessions
It makes the context smaller before the context window is full. The agent does the compaction itself, in the same session. I have been using it for a while and my experience has been stellar with this extension. The core algorithm is based on the automatic compaction algorithm in Shelley by exe.dev team.
How it works
- When the context gets to 200k tokens, pi-percy sends a nudge to the agent. The nudge has an index of the old messages. pi-percy sends one more nudge for each 50k tokens after that.
- The agent selects the old items that it does not need. It replaces old tool outputs with short pointers. It replaces old message ranges with short notes.
- pi-percy checks the request. If the request is not correct, pi-percy rejects it and gives the agent a list of the problems. The agent then sends a correct request.
- pi-percy writes the changes as Pi context edits. The session keeps all of the original messages.
What you get
- The agent that knows the work decides what to keep. There is no second model and no extra cost.
- With the
recalltool, the agent can search the original messages and read them again. - Idle compaction. If the session is idle for 8 minutes, the agent compacts the context. At that time the provider cache has probably expired, so the cost is low.
- The prompt cache stays valid. pi-percy does not change the tools or the system prompt, and the agent does one large compaction, not many small ones.
- Pi's own compaction stays on as a safety net.
- All of these threshold are configurable and has sane defaults.
Install
pi install npm:pi-percy
You need Pi 1.4 or later.
11
Upvotes
8
u/Zya1re-V 16d ago
"We like compaction so much, we add a little bit more compaction on top of your compaction so the compaction can compact compactly." type of stuffs.
3
u/random_user-1234 15d ago
You need to run some long agentic benchmarks so you can actually prove that it increases performance or at the very least has no degradation and you can get numbers on how much the cost increase is because this will break the cache more frequently causing higher read costs, and those frequent breaks might also increase the time it takes to finish a task as well. Nvidia ran agent loops to find agent optimizations they came up with Sol-Pi which this is very similar to and their own benchmarks gave mixed results. One thing I realized from making my own extensions is that we might think we have a genius solution but if the model was not trained on it during RL it won't be used to it causing worse performance. The frontier models are just so good that they can generally just power through any brain damage my extensions gave them without me noticing that they were doing worse because they still worked.
2
u/Agreeable-Pirate-886 15d ago edited 15d ago
I gave it a try for 3 hours of heavy lifting. I had high hopes. I was using pi-blackhole.
My previously superb agent (DS41F max) quickly began deteriorating, hallucinating data points, forgetting basic instructions in agents.md, and writing code only vaguely related to the assigned task that didn't work and it couldn't fix.
I had no idea how strongly compaction affects your results.
1
u/Conscious-Expert-455 16d ago
Can the context be configured? My maximum context size is 131 k. Tnks
1
u/alexis_moscow 16d ago
how it's different from built-in auto-compaction?
1
u/khaleelu 15d ago
how does your solution differ from this one https://www.reddit.com/r/PiCodingAgent/s/8TmUBxyb9q
1
u/archiblad 15d ago
Check pi-condense with summary capabilities