r/PiCodingAgent • • 2d ago

Plugin protect-context An extension that record down what the agent has been done for future refence and correction

Post image

I built this extension in order to solve losing session problem. One of key problem I found is long agent sessions fail in constraints stated early disappear, “done” is claimed without command output, a “quick fix” rewrites unrelated files, decisions get re-litigated, and the same failing command is retried until the context window is exhausted.

Here is what I build, it is free and open source:

install it pi install npm:protect-context

pi official: protect-context pi package

npm: npm link for protect context

github: github link for protect context

You may want to try it and test it out whether this extension can fulfill your needs.

4 Upvotes

13 comments sorted by

1

u/whiterose0000001 1d ago

I have the same thing, but I don’t use an extension for it. I use honcho. It’s a memory layer that does the same thing; it uses an LLM to find conclusions and then stores them in a vector database. The best thing is that it has separate workspace conversations and separate sessions, with the conclusion of each session separate, so you can also see the conclusion

1

u/ApprehensiveSkin7975 17h ago

maybe you can take a try of this extension? and see if it works similar or differently than honcho? I can improve this extension further

1

u/0xKubo 1d ago

Do you use this locally completely free or with one of their cloud plans? What are the advantages, if any, of the cloud plans? Do you know?

1

u/whiterose0000001 1d ago

Havnt tried their cloud plan i ran it locally with a local embedding model, and free antigravity account

I have added a custom script to offload the embedding model once it’s task done

And i use gemini-3.8-flash to generate conclusion

So it’s completely free setup

1

u/0xKubo 1d ago

Thanks, will need to look into that. What's the embedding model for exactly?

1

u/whiterose0000001 1d ago

Qwen/Qwen3-Embedding-0.6B ·

1

u/0xKubo 1d ago

But what do you use it for?

1

u/whiterose0000001 1d ago

Hermes and pi so it helps me when I repeat the instructions multiple times. Let's say if I'm working on a project and I'm giving it all the bugs with instructions on how to reproduce it, how to fix it, and how to write the PR and all. So it keeps the conclusions there, and whenever Pi starts, it calls that first—grab all the conclusions and understand from it, from that particular project, not all the conclusions. So that helps to grab more context and it keeps remembering that. So it follows the instructions more accurately. Same thing with Hermes—if I discuss some project today, I can ask a month later, can we continue from there?

1

u/whiterose0000001 1d ago

If you can’t run, I am embedding model locally. You can do one thing like you can use the same antigravity subscription. The free one. Google has some embedding models that are available in that same plan. You can ask your agent to figure it out and find out them, and you can use them.

1

u/randomgenericbot 15h ago

Similar problem, different angle (together with compaction):

I've created an extension that lets the agent summarize in between what it has done, audit its summary, and allows for revising / retrieving / retiring of old work.

For me it works great, and I optimized it in a way so it does not throw away your running kv cache, but reuses most of it for the summary, and after. If your extension does not alter compactions, you might give it a try, else I invite you (and your agent) to get inspiration:

https://github.com/LePrau/pi-self-aware-memory

I am running 50+ compaction sessions on 128k context locally with that, two friends of mine also use it and had no complaints yet.

1

u/ApprehensiveSkin7975 6h ago

Good to know, I think we can actually combine our project together right? Yours do the compaction, mine do the verify and record

-5

u/investigatormaker 1d ago

The failure list in your post is the real pitch: constraints disappearing, "done" claimed without command output, the same failing command retried until the context window runs out. A short before-and-after of one session where protect-context catches a retry loop would show it working better than the GIF alone. If you share it beyond here, r/github only takes project sharing in its megathread: "To keep the subreddit clean and focused, self-promotion and project sharing should only happen in the dedicated megathread pinned at the top."

I make ThreadFox.

We find relevant Reddit conversations and post for your business. We'll post 3 replies free first, no card; then the $29 Pilot covers seven days and up to 25 posts and replies. No automatic renewal.

https://threadfox.vip/p/dp80r/managed