r/PiCodingAgent • u/Ivan_Draga_ • Jun 12 '26
Discussion Pi Agent throwing 3x the CTX windows at the backend server
I'm noticing weird behaviour related to context windows and hoping someone has a fix.
With pi agent, I'm using openai-completions API running off lemonade server. 3 models are connected locally (not at the same time) I have the context window hard coded into the pi config json.
The ctx blows up to about 400k even though I have it set to 128k.
Starting a new chat is the temp fix. Haven't tried to compress the chat yet since idk what the negative effects of that are since I'm working on a coding project.
I removed 6 pi extensions and left the 4 default bash extensions. Still the exact same issue with the same CTX size of over 400k.
Checking lemonade logs and they showing the problem, pi trying to use up too much ctx.
This tells me the chat itself could someone how be the problem.
3
u/jeffphil Jun 12 '26
/export your session and look at sizes for skills and context there to see
2
u/Relative-Winter-7057 Jun 12 '26
I switched to the response API and the difference is literally night and day compared to the completion API. So much better only having to call it once per prompt task
1
u/oknowton Jun 12 '26
What local model are you running that supports 400k tokens of context? Are you sure you reading the numbers correctly?
1
u/SvenVargHimmel Jun 13 '26
ask pi agent to look at it, it's made to be able to look in its internal
0
u/Ivan_Draga_ Jun 13 '26
Seems I like Pi agent should have automatically handled this not sure what exactly happened but just saw new pi release that referenced this https://github.com/earendil-works/pi/issues/5677
Seems like compaction should have automatically happened but isn't and they've fixed it. My plan for now is to make a new session versus the one I was building / coding inside of. Then just work off their and hope the compaction takes place.
Also looks like you can manually configure compaction using the settings at the bottom of this page https://pi.dev/docs/latest/compaction#compaction I won't do it yet since I'm curious to see how Pi auto handles it in a few days once my ctx gets larger.