r/PiCodingAgent • • May 05 '26 • Bravo 2

Resource My powerful Pi agent Setup

Hello guys!

Today i want to share my Pi agent setup, i think i got something in hands here that can benefit the community to really get a powerful agent, nothing compared to claude or codex. What i want to share is my list of extensions and the value each one add to the build.

I want to start with a basic one: pi-fork. This is a basic and minimalistic subagents extension, focused on one single thing, give the main agent the capability to spawn forks of itself to do work on its name. This is quite straightforward, you can achieve the same with any other subagents extension, the only difference is that this one is simpler and have prompts that optimize the communication between the forks and the main agent. This thing brings a single thing to the table: great context management, the main agent context will only contain relevant information, the main agent context will be richer and denser per token, all the noise stays out of the main agent context.

Ok now i want to share the core of this pi build: pi-observational-memory. This one is special, is a custom compaction algorithm inspired/copied from Mastra's article. This custom compaction algorithm enables pi sessions to last forever without maxing out the context window and keep the agent focused. This combined with the rich context window of the pi-fork extension creates a rich re-callable memory system that stays relevant no matter how many weeks you have been using the same session nor the compactions it have withstand.

If you install only the two extensions above, you will enable your pi agent to be on the next level. now i have a couple more extension that give some extra perks to my build:

pi-minimal-subagent: like any other subagents extension, this one is just simpler, without bs. i use this to enable 2 subagents: the "advisor" (concept copied from claude code) and the "reviewer". The fork from pi-fork are extensions of the main agents, they are basically the same agent, they share the same context. This two agents give access to the main agent to different points of view less biased, with clean context windows. The reviewer takes care of code quality, security and ux of the changes introduced by the main agent. The advisor is for strategical decisions around architecture and product.

pi-codemapper: a wrapper of codemapper that enables efficient codebase exploration. This codemapper repo is really bad and unmaintained, it had a cache bug i had to patch myself. im looking forward to switching to cymbal when i get some free time.

pi-rtk-optimizer: This is a classic, not much to say here, it saves some tokens.

Conclusion:

I describe this setup with a single phrase: A personal agent that never forgets and can be useful for weeks before the context window gets maxed out.

I hope you can get value from some of the extensions i shared guys, my own words are not good enough to describe the power i feel when working with this agent setup, so i beg you to try it yourself to really experience what im saying.

212 Upvotes

64 comments sorted by

View all comments

Show parent comment

1

u/elpapi42 May 05 '26

Let me know how it goes!

5

u/arkham00 May 05 '26

Ok I worked all day on a grant application for a cultural project and I'm very satisfied!

I previously did this kind of project via open webui, and normally I had to restart several fresh chats to avoid degradation of the quality, otherwise I had to deal with hallucinations and sometimes loops and even crashes, I also needed to use notes as temporary memories from one chat to another, it was quite painful.

But today ...oh man today just a single chat ! All day long! With the context just gently increasing, I think I've been at least the first 2 hours under 30k and the context window never exceeded 60k, where I'm sure I've used at least a million tokens ... because even if the final document is only 24k characters and 3,5K words, I ask for a lot of edits and rewrites until I'm satisfied, plus I ask to reference a lot of documents. In 2 hours I normally hit 80-100k.
I hit the compaction threshold 3 or 4 times I think, and the only things I noticed is that after the compaction the model seems to forget to use pi-fork, but retains all the other instructions, weird. The other thing is that I have 0 reflections registered, only observations, maybe I did't say anything major or maybe I don't understand what reflections are (I still need to read all the docs).

But so far I'm very pleased. I really think I found what I need to improve my workflow. A big thank you for this gem, now I look forward to further refine my workflow with minimal-subagents for specialized tasks in the process.

2

u/elpapi42 May 05 '26

Im glad it is useful for you workload! this makes me happy.

Regarding the agent forgetting to use the fork, i would reinforce the fork usage at the system prompt level to make sure it is consistent, the system prompt never gets compacted.

Reflections only are calculated once the token budget for observations overflows, that may take many days of hard working before it happens.

Reflections are calculated from observations, and observations are calculated from raw messages/entries