r/PiCodingAgent • u/voxvoxboy • Oct 06 '26
Plugin pi-optchat: never compact again - endless chat as a memory tree
I built a Pi extension that implements Victor Taelin's OptChat recipe: instead of compacting, every message is logged and summarized into a binary tree. Each turn starts from a fresh context with a bounded memory view (128 KB), and the agent uses zoom/date to read the originals when it needs them. One endless chat per profile, no fork, no separate launcher.
Install with pi install npm:pi-optchat
What's in it:
- Profiles — separate memories and instructions (I run work and personal).
- Subagents — spawn background agents, watch them live, send guidance, interrupt with Ctrl+C, resume finished ones with tell. Reports from one spawn arrive grouped.
- Import — bring in your history from Claude Code (sessions and auto-memories), Codex, or a ChatGPT export.
- Connected windows — open a second Pi on the same profile and it becomes a subagent you talk to directly, with a handoff when you /complete.
Repo: https://github.com/jonaslsaa/pi-optchat
Video credit goes to https://github.com/aaaxn
206
Upvotes
34
u/startassets Oct 07 '26
With such extensions I always wonder why they should do more than they declare in the name? New memory system is great, but why another implementation for sub agents? It limits the combined usage with other extensions and in general makes the package more bloated.
24
u/theholewizard Oct 06 '26
Seems like it would completely invalidate the cache every turn?
6
u/mephinet Oct 07 '26
Thanks for implementing the gist! What I am wondering: at work, I constantly switch between many different projects, often working in parallel. Without the concept of "project/repo", completely unrelated lines will be merged - I cannot imagine the summary to stay meaningful. Did you observe this when importing your work history?
4
u/stellar-- Oct 06 '26
Really intrigued by this, so in your own use right now do you stay in one never ending session??
3
u/slypheed Oct 06 '26
Curious how this is different/better than https://github.com/elpapi42/pi-observational-memory
3
u/m3umax Oct 07 '26
So a bit like RLM right?
3
u/paca-vaca Oct 07 '26
With this nested recursive compression (summary of the summaries on previous level) with long enough session older history might lose it's original meaning and hallucinate into something, making it useless, isn't it? Also, what happens when decision fact changes between levels, how such collisions handled when it's summarized but previous fact contradict the recent one?
3
u/alexeyche_17 Oct 07 '26
Looks super interesting! Conflicted though with pi-interactive-subagents, created an issue: https://github.com/jonaslsaa/pi-optchat/issues/86
3
u/National-Canary6452 Oct 07 '26
The more I use an agent like a dot or grok bot the more disorganised having a single window feels. I like to compartmentalise my work and be able to close digital boxes. Dunno, maybe it's just getting used to long running chats but something about this feels... Dirty
2
u/Dsphar Oct 06 '26
Interesting concept. Is the tree only traversed based on date? I am having a hard time seeing how it can split and binary-indexed based on subject matter...?
2
u/repolevedd Oct 06 '26
Looks interesting, but a few things aren't quite clear to me. Sorry if this was in the description and I missed it:
2
u/nutcrook Oct 08 '26
There seems to be a new version with some fixes: https://x.com/victortaelin/status/2108015066528297398?s=46&t=fac655ZoFO7HR3sBtDEbtg
2
u/therealpaulgg Oct 08 '26
Is there a way to get this *without* subagents? I have my own subagent implementation (using Herdr) and I would rather not bring someone else's in.
otherwise..looks really slick
3
u/raccoonportfolio Oct 07 '26
Just want to say thanks to OP for being so responsive and writing responses yourself. I don't normally try these 'yet another context management' plugins but I'll try this one
16
u/Turbulent-Hat6046 Oct 07 '26
Would like to see some benchmarking here to proof that this is better than compact or other memory augmentation approaches
10
u/ECrispy Oct 07 '26
there's so many options now - external db, markdown, wiki, long term memory, compaction, dreaming etc etc, it just goes on and on.
My gut feeling, which could very well be wrong, is that all these memory approaches are highly dependent on usage patters, total context, and intelligence of model + harness, and would yield wildly different results in different scenarios.
have you looked at facebook's new CLM? at least something by them is bound to be more experimentally verified.
1
u/voxvoxboy Oct 06 '26
I've moved all my work (tens of thousands of messages, hundreds of sessions) to this and works quite well!
1
u/voxvoxboy Oct 06 '26
I'd also like to mention this isn't really anything revolutionary but the newest generation of models have become very good at organizing information making this work so well. Haven't really tried other models than Opus 5.5 and Fable though (sonnet as compactor). I've moved all my work (tens of thousands of messages, hundreds of sessions) to this and works amazingly
1
u/Jungibungi Oct 06 '26
Did you do any benchmarks?
1
u/onebit Oct 07 '26
On windows I get
Error: listen EACCES: permission denied C:\Users\user.optchat\profiles\project\lock.sock
Error: EPERM: operation not permitted, fsync
1
u/DiamondGeeezer Oct 07 '26
how do you keep track of concurrent work if you're only using one session? can this be used with many concurrent sessions?
1
u/External_March1921 Oct 07 '26
is there something like that for CC?
1
u/cosmicnag Oct 09 '26
I can see this being quite useful for usecases like chat,etc which dont involve coding. For coding, though it could work, it seems like it could get inefficient fast as the last turn also gets folded immediately? I am using billion context currently which atleast keeps the working set verbatim (model decides what is consumed , for folding). Here, the (main) model doesnt decide what to fold. Do correct me if I am wrong.
1
u/jesperordrup Oct 10 '26 edited Oct 10 '26
Can u use same memory on several machines?
1
u/Pyros-SD-Models Oct 07 '26
So basically, the same trick as https://arxiv.org/abs/2512.24601, and just like RLM, it will lead to nothing because, in the end, you're simply replacing the "context problem" with a "search problem." All the important information gets lost in a sea of fuzziness.
And RLM is infinitely better than your implementation, so if that already fails, I have bad news for you.
Not hating, just saving you all the time. This has obviously been tried before in the literature, and there's a reason it never became a thing.
2
u/maskedthick Oct 07 '26
I'm gonna try this! Thanks for sharing it, seems what I need for my low vram
2
u/qaf23 Oct 07 '26
I'm curious how this stacks up against pi-blackhole.
2
u/LordMoridin84 Oct 07 '26
Oh, it seems pretty similar to https://github.com/ranxianglei/billion-context
Although I've never used that either.
2
u/Master-Reception9062 Oct 11 '26
Similar: infinite context via folding
https://github.com/fdietze/pi-infinite-context/
1
u/aparamonov Oct 07 '26
How does it stack against pi-vcc?
1
u/alexwwang Oct 08 '26
How is the effect of this recipe?
0
u/lordekeen Oct 07 '26
Sounds like a cache hit killer
2
u/[deleted] Oct 07 '26
[removed] — view removed comment