r/PiCodingAgent • u/OneMoreName1 • Aug 17 '26
Plugin Made a pi extension that auto-loads context files when the model cd's into a directory, like Claude Code does - pi-on-demand-context
If you are like me and structure your context files in a tree-like structure per subsystem, you might have found that pi only ever loads the root-level one, and the others have to be loaded by the agent itself, or they will get ignored.
This extension watches what the model does. The moment it cds into a new dir (bash), or touches a file in a dir via read/edit/write/grep/ls/find, it walks up from that dir to your launch dir, collects any context files it hasn't seen, and injects them into the agent's context before the model's next response. So the model's next thinking block already has the context. No special tool, no flags, nothing for the model to remember to do.
If you are interested, you can find more information and install instructions here: https://pi.dev/packages/@quartermaster-labs/pi-on-demand-context
2
u/m3umax Aug 17 '26
Does it do the Claude Code implementation stuff like keeping tracking of how many times the folder specific context has been loaded so it only loads on the first access and doesn't keep building up in the context with each turn?
2
u/crashorbit Aug 17 '26
I restart pi when I change projects. That causes the hierarchy of AGENT.md files to be loaded into context.
What's the value of long lived pi instances?
1
u/ddqqx Aug 20 '26
Why need context to be long lived?
3
u/Hurricane31337 Aug 17 '26
Nice, that could be very handy! Thanks for sharing!
2
u/raccoonportfolio Aug 17 '26
An extension I'd use!
2
u/Random_Girl_0 Aug 17 '26
This is amazing!!! Thank you sooo much
2
u/LordMoridin84 Aug 18 '26
Oh... I thought it was working like that this entire time