r/PiCodingAgent • u/Carrot-a • 28d ago
Question Custom PI Harness: Gemini 3.8 Flash often stuck in a infinite Loop
Hi folks,
I'm building my own harness for PI and noticed with Gemini 3.8 Flash, my subagent (a worker for simple coding tasks) is often stuck in infinite loops when reading larges file with 1.000 - 2.000 LOC.
I never noticed the same situations with opencode when using the same model and thinking level. So this is quite a disappointing experience while building my own harness based on Pi.
So I'm wondering if these are common situations when building my own custom harness? And what's the recommended strategy how to improve my harness, to avoid similar situations in the future?
I tried to add additional instructions to my sub-agent to avoid these situations, but I still see it happening. And this burns plenty of tokens :(
Best
Carrot
14
u/No-Reason-6767 28d ago
It's not pi. It's Gemini. There are memes on Twitter about Gemini doing this nonsense. How often are you running into this behavior?
3
u/Zya1re-V 28d ago
I've also seen something like this, but in Antigravity CLI itself with Gemini 💀
2
u/CreativeSympathy8293 28d ago
Your screenshot cycles through the same three read ranges in
run-records.tsandsubagent-done.ts. First check the worker's finalized reads: path/offset/limit, success/error/blocked status, result length or hash, and any truncation notice.Pi's current extension docs describe
tool_execution_endfor observing every finalized call.tool_resultalone misses calls that never execute and runs before final message events. Match the hooks to your Pi version, and compare those results with the worker's actual conversation after your wrapper's transformations.If delivery is intact, add a bounded no-progress cutoff for that repeated three-read cycle with unchanged results and no intervening edits. Return the stopped worker's reason to the coordinator instead of automatically restarting it. If results or truncation notices disappear in the wrapper, fix that delivery path first. The screenshot alone doesn't distinguish missing results from rereading content already received.
AI-assisted suggestion from current docs; I haven't inspected your harness.
2
u/YogurtExternal7923 27d ago
Btw even argon works badly with pi. It's somehow better when chatting and asking for code to copy paste rather than agentic stuff
1
u/gwvr77 28d ago
There are extensions that can spot some repetitive behaviour and stop it
1
u/LightH12 27d ago
With oh my pi gemini 3.8 flash works fine for me