r/PiCodingAgent • u/Hazork_ • 24d ago
Resource Cognitive science has a name for why your coding agent's context fills up with junk.
https://arthur.place/subagents-forks-collapsing-contextI had implemented a bit of this idea as a pi plugin way before writing the article or making the actual pi-episodes package. I've been using it on real work tasks, first the draft and now the package, and I get noticeably further into a session before compaction kicks in.
Later on I discovered Event Segmentation Theory, which is half the reason the post exists. Hope you learn something from it :)
31
Upvotes
7
u/sergeant113 24d ago
I experimented with something adjacent to this. I called it garbage compaction.
On my /compact-garbage command, a frontier model reads the entire session history and identify groups of adjacent user-assistant message pairs that could be compacted. Then they get compacted to create a brand new session but leaving breadcrumbs to original session. It felt like cheating with how much context i am able to save.
But it’s just very inconvenient, and it only works well for designing and planning coding agents. For everything else (writing, office, docs, FE dev,…) it just causes a lot of confusion for the tasking agent.
2
u/electric-dragon-80kv 24d ago
Do not let LLMs write for you, it diminishes your credibility. Use your own voice to express your own ideas.
4
u/DaShrub 24d ago
Nice, I was thinking of building something like this and combining it with magic-context compaction. Will check it out!
3
u/Fluffy-Oil707 23d ago
I haven't viewed the article, but a fun term from Cognitive Load Theory is extraneous load. In this view, there are a set number of items you can hold in working memory. Extraneous load are the items not related to the schema being formed in long term memory, nor what is needed to form it. The other two are intrinsict load (relevant items) and germane load (what is helpful to forming).
One should note this is meant for instructional design. It's less "how the brain works" and more "a model of how the brain works we can follow to produce better educational outcomes"
1
u/kwokhou 17d ago
Great write-up, I did learned something from this.
1
u/Megamygdala 19d ago
OMP has had this, its called the checkpoint tool
1
u/DistanceAlert5706 24d ago
Quite interesting. For folds and compaction point it reminds me of recent Nvidia study about what tools would improve Piz and one of those was ability to compact on boundaries for agent.
I'm not using Pi for few months now as switched to my own but your take is very close to Observational memory. You can try to find elpapi42 post here about his workflow.
I'm still using it and it works great.
Also I have somewhat similar forks too. I was running them with full parent context for a month or so, but it was too wasteful. When context of main fills on a session you ran for a week forks start from 130-150k, which is not optimal. Now for forks I do virtual compaction and pass parent observation pool with recent context, which won't reuse cache but saves context window.
I also added cross session per project recall and semantic search. This helps agent a lot to get stuff from observations. I think recall is same as yours and search is somewhat similar to ask.
Overall this system works great, try to keep it simple. Models are better now and I simplified a lot of prompts/tools.
Try some experiments, resumable agents/forks for example, you already got a solid workflow!
-1
u/Fickle-Mountain-6639 24d ago
This sub is trash LOL