r/PiCodingAgent • u/whiterose0000001 • Oct 16 '26
Plugin I built a Pi extension so my agent doesn’t fall into the dumb zone.
I'm very much inspired by Dexter Horthy and Matt Pocock on this. Dex says a model gets worse once the context window is about 65% to 70% full, which he calls the dumb zone, and Matt keeps sessions around 60% to 70% and hands off past that line, so I use the same limit for my work and my startup.
I set the threshold with /context-threshold, usually 60 or 70, and on a long task I tell the agent to call context_window and watch the used percent. The report shows the window size, how much is used, how much is left, and the percent still left under my line, so when it says threshold reached the agent stops and writes a handoff, which I pass to a new session and continue from there. The handoff I use is Matt Pocock's handoff skill: https://github.com/mattpocock/skills/blob/main/docs/productivity/handoff.md
The extension does not compact the session, and it does not write the handoff by itself, so Pi's compaction settings stay as they are. I still tell the agent what to do when the line is hit.
Install it with:
pi install npm:@utpalsinghdev/pi-context-window
GitHub: https://github.com/utpalsinghdev/pi-extensions/tree/main/packages/pi-context-window
npm: https://www.npmjs.com/package/@utpalsinghdev/pi-context-window
I'm just open-sourcing the Pi extensions I use for work and my startup. They've helped me a lot, and I want other people to be able to use them too.
If it deserves a star, the repo is https://github.com/utpalsinghdev/pi-extensions
DEMO

14
u/mechkbfan Oct 16 '26
60-70% of a specific context? e.g. 60% of 1m is 600k, which is quite different if you have 256k...
Anecdotally I'd be reading that 256k is about the limit before things start heading off in wrong direction, which is about 50% of 500k.
I always like the advice of in your agent.md to have a "Always start with a "Hi <name>". That way if it's not there, it makes you wonder what else it's "forgotten" due to context size.
6
u/Drugba Oct 16 '26 edited Oct 16 '26
Just an FYI, both Matt and Dex have said context window size doesn’t matter for dumb zone. It’s just about raw number of tokens. It’s not an exact science, but both have said between 100k and 200k is where the dumb zone starts.
Here’s a quote from Matt on the Pragmatic Engineer podcast from just a few weeks ago
> Matt: […] you have the smart zone, which is currently, I would say, about the first 150,000 tokens of frontier models.
> Host: Of a one million token window.
> Matt: Yep. Of any size token window.
> Matt: It doesn't matter the context window size. It's all about raw amounts of tokens, raw amount of attention relationships.
(Quote is around the 40 minute mark)
And Dex on the same podcast in July:
> Host: What is a smart zone and what is a dumb zone?
> Dex: I think in November we talked about the first 40% of the context window, but then we had million-token context windows.
> Dex: So then I changed it to like the first 100,000 tokens. If it's a really like Claude 3.5 Sonnet, I usually will go up to like 200k.
(Quote is about an hour and ten minutes in)
3
u/Diacred Oct 16 '26
Is that still the case though? It was painfully obvious with the models from 6 months ago but lately I haven't felt that at all, my models are as sharp at 150k that they were at 30k context. I was big on always starting fresh conversation and compacting at the right time but nowadays it feels inconsequential.
1
u/KangaBro Oct 16 '26
Thanks for sharing. Interested to know what other extensions you have found useful and use personally.
1
u/rednix Oct 16 '26
Do you have actual benchmarks on this?
2
u/FollowKryst Oct 17 '26
A model with 1mil+ context, I NEVER let it pass 130K tokens… even with a local model with 262K, I still compact/compress at 100K.
Idk how people be letting it get that far and burning money and tokens a long the way.
2
u/WisdomSky Oct 16 '26
How does this make sense? It's counterintuitive to me. back in the day, context window was so low that you have to summarize the whole conversation from time to time just to maintain some sort of context into your next message.
The problem with it is that the more and more the conversation gets summarize, the overall context could lose some important information which causes the context to drift and become dumb as time goes on. And yes, I was speaking during the time when context window was just 12k tokens.
But today, that should be less of a problem because we have a lot of leg room to fit more information (1 million context). If using more space in the context window can make the whole process dumber, then why increase the context window at all?
Shouldn't we blame how the information is managed and saved into the context rather than blaming the context window size usage itself?
The problem should be the harness, skills, tooling, how the compaction is done, etc.
1
u/zapleirbag 16d ago
I'd be easier if you just compact around the 272k threshold, and you would be saving money also
1
u/GoingOnYourTomb Oct 16 '26
There is an easier way that works for me. No model I use ever goes above 200k but I use a strict orchestration system so 200 is plenty for me.
Pi compacts when you are close to the limit. I set the limit for all models to 200k
Remember tho I don’t have 1 agent doing explore, building and review so it works for me.
I’m a developer so I can start new chats for new/separate tasks.
1
u/tripleshielded Oct 16 '26
Old problem, consider glm max vs high
1
u/funbike Oct 16 '26
I do everything I can to keep context small. I use a lot of small sub-agents and I generate plans that break things into small sub-tasks. I disabled auto-compact.
I wrote an extension that prints and logs an error message when context exceeds 100K. To me, it's an error because it's something I actively try to prevent.
0
u/zebedeolo Oct 16 '26
interesting concept, I'll check it out at work today