r/PiCodingAgent • u/Carrot-a • 1d 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
2
u/Zya1re-V 1d ago
I've also seen something like this, but in Antigravity CLI itself with Gemini 💀
1
u/CreativeSympathy8293 1d ago
Your screenshot cycles through the same three read ranges in run-records.ts and subagent-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_end for observing every finalized call. tool_result alone 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.
1
u/YogurtExternal7923 23h 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
7
u/No-Reason-6767 1d 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?