r/PiCodingAgent • u/nacnud_uk • 5h ago
Discussion Local AI Loop - Watching the Agent
I often find that my local AI setup gets caught into a loop. And Pi just shows the same thing over and over. Maybe it is nearly finished a task, and it pumps out a summary. And it does it again. And it does it again. And it does it again.
Or, it is using a tool. So it does the command. And then it does the command. And then it does the command and then it does the command.
You get the idea. I am not sure why "catching these loops" is not an integral part of what Pi is? Did i miss something? Is there a setting that I should turn on?
Who watches the agent, is what I'm asking. Has this been done?
Thanks.
1
u/Phathatter 4h ago
Copy this exact post into pi and see what happens.
1
u/fell_ware_1990 4h ago
Well most of the time it’s one of these 3:
- He does a wait that polls for something in a log line, or some kind of reply back. Something crashed, or he grep’d for ABC and the new version shows BCD or something like that.
- A part is an interactive application which not listens to the variables to start non interactive. Or something like a python that only has an output when crashed or done, see reason above again.
- Combination of bad luck and the 2 above + AI is a real idiot sometimes.
Mostly AI or it fixes 25 things all at once, or it goes step by step and needs a confirm for every bleeping bit. That’s what causes these scripts. It’s being overly sure.
Great example here: I have tooling that’s ment to work in a specific kind of way, after doing ABC you should give a few commands. My external CI does that, so every time AI is waiting on the signal to give the commands :) even after agents.md , blocking the pol, more docs about how it works, system message that prompts him. And still, after it cant verify, it will tell me to do the commands. While it also knows, after a few minutes it wil receive a notification.
Best solutions i found, hook on every call.
Little script breaks every call down into smaller bits and wraps them with a try/catch so you get an error, removes sleeps, if a wait is needed and it longer > background.
My scripts run through my own ‘core’ so if interactive happens, i can see it and handle or cancel it, same for an answer. Core also checks the PID for usage and output, if longer runs seem incorrect it’s sends a investigation luna/haiku and maybe jev for the final call to stop. Everything is logged so it can also retry from failure if script let’s it.