r/PiCodingAgent • u/elpapi42 • Apr 16 '26
Resource Created Observational Memory extension for Pi
Hello guys, i just want to share with you this extension i developed: https://www.npmjs.com/package/pi-observational-memory. It is quite straigforward, everything i have to say is in the readme.
But i think this can help to basically make pi sessions feel endless, and saving tokens too!
1
u/cosmicnag Apr 16 '26
Question to OP : What settings do you use for the observation and reflection thresholds for which models of what context length? I'm looking at this extension also for a very lean context strategy, so thinking of like 50k or something in both even for a 1M context model, assuming frequent cheap sidecar llm model for frequent compaction.
1
u/elpapi42 Apr 16 '26
im courius what 1m context model are you using in Pi? opus?
1
u/cosmicnag Apr 16 '26
yeah mostly, along with gpt 5.4 high also. These two for planning - for grunt work I'm using various - from sonnet to local gemma4 31b.
1
u/elpapi42 Apr 16 '26
can you share with me how are you using claude models from Pi?
1
u/gandazgul Apr 16 '26
API keys damn expensive. Cheaper alternative that's also very good Gemini 3.1 pro. I have a similar setup to what they described. Plannotator using Gemini or gpt for planning then gemma4-31b from Ollama Cloud for execution. Gemma too do simple tasks like answering questions about the code, commit messages, change logs, etc.
1
u/cosmicnag Apr 16 '26
https://www.npmjs.com/package/pi-claude-bridge
This is a wrapper for the Claude agent SDK, which I think is still a legitimate way of using claude subscriptions.
1
u/lu16151m0nc1n1 Jun 05 '26
ironically I was using that bridge while exploring the web for pi observational memory, started seeing messages from the agent mentioning how it was saving stuff to memory and got puzzled, did i install it with the power of thought?...Nope. Anthropic enabled its memory mechanism by default and it was referring to that. Exactly the kind of surprises you would want to avoid, yet another reason to move to pi
1
u/cosmicnag Jun 05 '26
Yeah pi is in a league of its own, the session tree alone is worth it. If you are into observational memory, also check out pi-blackhole, which combines obs memory with pi-vcc (algorithmic compaction). This combo with instant manual compaction is what I use now.
1
u/elpapi42 Apr 16 '26
tbh i havent landed my ideal settings yet, rn im running 50k observation threshold and 10k Keep recent tokens. the reflection threshold at 30k (so the observations token budget is really high).
But if you really are looking for the most absolute lean context window, i recommend using some subagents strategy, im using subagents for scanning/exploring the code bases, so i dont bloat my context, i you can get away with a cheaper model for those scouters.
0
u/cosmicnag Apr 16 '26
What extension are you using for sub agents? Interesting, I also kind of arrived at very similar threshold numbers.
1
u/elpapi42 Apr 16 '26
initially i was using this one: https://www.npmjs.com/package/@e9n/pi-subagent, it is quite simple.
But then i ended up forking it and modifying it a little bit, the extension as it is, force-injects to the system prompt usage guidance for the tool "subagent" that gets added to pi agent. This was causing me problems with my setup, so i forked it and stripped it.
This is the fork is you are interested: https://github.com/elpapi42/minimal-subagent. but i recommend playing around with the official extension fir before deciding if the system prompt extension is a problem for you, i also suggest to try other subagents extensions and see what fits you better
1
u/cosmicnag Apr 16 '26
I am using this since yesterday now.I have noticed that reflections are still empty even after multiple compactions, observations are working. Is this expected? I am using gpt-5-mini for this compaction and OM (thats free in github copilot plans lol).
1
u/elpapi42 Apr 16 '26
not sure, can you check how many observations tokens are you consuming? if you have a high threshold, for example 30k, that may be hard to reach. Are your observations well above that threshold?
1
u/cosmicnag Apr 17 '26
}$ cat .pi/observational-memory.json { "observationThreshold": 50000, "reflectionThreshold": 30000, "compactionModel": { "provider": "github-copilot", "id": "gpt-5-mini" }1
u/elpapi42 Apr 17 '26
you can run /mo-status to know the token count per memory section.
BTW i introdu ed a braking changes late yesterday that moved the configuration from observational-memory.json to settings.json, so the settings are unified for both pi and the extension
1
u/cosmicnag Apr 17 '26
Yeah, I think I had a high reflection threshold. I'll reduce it to like 5-10k and see what happens.
1
2
1
u/krogel-web-solutions Apr 20 '26
Is it just in-session memory?