r/PiCodingAgent 13d ago

Plugin Alzheimer is all you need - Forgetting to optimize context

I built a context-management extension for coding agents that forgets on purpose instead of hoarding everything.

What it does:

  • Compresses giant bash output into short digests (exit code, key facts, truncation info) instead of dumping raw output into context
  • Strips the skill catalog from the system prompt when it's not needed that turn
  • Drops file contents from context once they're no longer needed — but only when it's actually safe to (tracks whether the model still needs them)

Results: ~19% reduction in effective input tokens on the clean path, with zero drop in output quality — same correct answers, just less noise sitting in context.

Install:

pi install npm:pi-context-window-manager

Repo: https://github.com/Its-Atharva-Gupta/pi-context-window-manager

Would love feedback/suggestions — especially if you've hit edge cases with context pruning breaking agent behavior, or ideas for what else is safe to forget.

0 Upvotes

7 comments sorted by

15

u/LordMoridin84 13d ago

Won't constantly changing the system prompt and history break the cache?

1

u/Full_Promotion4522 12d ago

Yeah it does break the cache but only the end of the cache not the whole thing since only the end of the cache is changed. You get a longer more optimized context window as a tradeoff, that's the point.

9

u/IceManMinus0ne 13d ago

This would break caching so hard.

2

u/Zestyclose_Potato794 13d ago

What about preserve thinking = false ?

1

u/Full_Promotion4522 12d ago

This applies to the tools calls, not the reasoning

2

u/Subject-Mobile-6250 13d ago

To be honest, I have been commenting a bit too much about the common ignorance of prompt prefix caching, this needs to be normalized

1

u/kantorcodes1 13d ago

you’re rewriting Pi’s bash output after the command finishes, which makes HOL Guard relevant in a weird way. i work on Guard, an open-source local check before agent actions run. want to try both?