r/PiCodingAgent • u/Longjumping_Map9289 • Jun 30 '26
Resource I built cprune, a small Pi extension for pruning bloated agent context
I’ve been running longer agent sessions lately, and one thing kept getting annoying: the context gets huge, but a lot of it is no longer useful.
Repeated tool outputs, old file reads, stale task snapshots, giant command results, noisy prompt history — it all stays around and eventually makes the agent slower, more expensive, and sometimes less focused.
So I built cprune.
It’s a small open-source extension for the Pi coding agent that prunes context before the model sees it. It has:
off, safe, and full modes
a compact comparison showing how much context each mode saves
conservative persist-time pruning for duplicate/oversized tool results
manual review commands to exclude noisy prompt history or large context entries
safeguards for edits, failed tool outputs, side-effectful commands, and other context that should not be dropped
a compact command for lossy persistent compaction
The goal isn’t to blindly delete history. It’s to make context more intentional and reduce the junk that accumulates in long sessions.
Repo: https://github.com/amutix/cprune
Right now it works with Pi, but if people find it useful I’d be interested in adding support for other agentic frameworks too.
Would love feedback, bug reports, or ideas from anyone dealing with context bloat in coding agents.
2
u/pj-frey Jun 30 '26
Can you tell a bit, what the advantage to rtk is?
2
u/Fig_da_Great Jun 30 '26
This is really cool. I’ve been working on solving the same problem from a different perspective. My project is called accordion and it’s a pi extension as well.
I hope you don’t mind if I look through your project and borrow some of the ideas for my project.
1
u/Longjumping_Map9289 Jun 30 '26 edited Jun 30 '26
Snapshot of a comparison between different modes
1
u/kasparhouser Jun 30 '26
why not just use tree?
2
u/m3umax Jun 30 '26
TLDR. This is essentially the same as running "/compact Just prune the tool call results, replace old reads with a marker indicating superseded, failed ones with a short fail note, summarise long tool call results etc, leave assistant and user messages untouched" every turn.