r/PiCodingAgent • • 23d ago

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

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.

6 Upvotes

14 comments sorted by

1

u/ApprehensiveSkin7975 18d ago

I updated "verification" process in the MCP, to make verification more robust. If the report says FAIL, follow its fix line. If it says UNTRUSTED, re-run without a pipe or || true before claiming success

1

u/whiterose0000001 23d 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 21d 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 23d 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 22d 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 22d ago

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

1

u/whiterose0000001 22d ago

Qwen/Qwen3-Embedding-0.6B ·

1

u/0xKubo 22d ago

But what do you use it for?

1

u/whiterose0000001 22d 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 22d 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 21d 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 21d ago

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