Skip to content
Amila

Palahepitiya Gamage Amila · Weekly Learnings

Why my stall check failed a working AI agent

· Palahepitiya Gamage Amila

On 4 November my agent setup failed one of my AI agents three times in a row. The agent was doing its job. It had read a comment in the code that happened to contain the number 403, and a rule I wrote took that as a sign the agent was stuck.

The short answer. A stall check that looks for error text on an agent's screen can't tell an error the agent hit from an error the agent is reading. Mine failed a working agent three times because a code comment contained "403". The fix was to treat error text as a failure only once the agent has gone idle or finished, and to test that with a planted error line.

Some context. I work as a fractional CTO, and since September I've been building a setup where several AI agents work on one client project together. A plan gets split into pieces, agents build the pieces side by side, and one agent's whole job is to challenge the others' work before anything is merged.

What happened on the first real run?

At the start of November the setup gained the ability to run on a Mac mini as well as my PC. Before switching a real project over, I ran a free test with fake agents. It passed, with one check needing a retry (source: the setup's acceptance notes, 4 Nov).

Then the first real piece of project work started on the mini on 4 November, and it hit two faults the free test could never have caught.

The first was a terminal window that opened in the wrong folder. When the setup opens a new window for an agent, it types a command to move into the right folder. That command got lost, so the window stayed in an older copy of the code. A launch then failed there, while the setup still believed the stage was working.

The second was the 403.

Why did a stall rule fail a working agent?

My setup watches each agent's window for signs it's stuck. One rule looked for a provider error, the kind of 4xx response you get when a model service refuses a request. If that text showed up in an agent's first 15 minutes, the rule failed the agent.

The challenger agent was reading product code at the time, and one comment in that code contained a status like 403. The rule saw it on screen and failed the agent. Three times. The run was blocked until I looked.

Nothing was wrong with the agent or the model service. The rule only checked what text was on screen, never whether the agent was still busy.

How did I fix it?

Both fixes went in the same day, by about 6:30pm UK time on 4 November:

  • Error text like a 4xx or a bad-key message now fails an agent only when the agent is idle or done, never while its window says it's working. A real error that then sits idle still fails straight away.
  • Every new window now starts with its folder set explicitly. After moving in, the setup reads the folder back. If it's wrong, it warns and tries once more. If it's still wrong, it stops with an error naming both folders and won't start the agent.

On the mini after the fix, the stall checks ran 101 tests with none wrong, and the full suite ran 1,036 checks with none wrong (source: test runs on 4 Nov).

Why didn't the free test catch it?

The free test used fake agents and a quiet setup. Fake agents don't read real code full of real comments, and a quiet setup doesn't open windows the way a live run does. So the test proved the plumbing worked. It couldn't prove my rules would behave around real text.

I still think the free test was worth it. It caught a wrong Python version on the first attempt, before any real work was at stake. But I now treat it as a check that things start, and the first real run as the real test.

I don't have speed numbers for the Mac mini yet, and that first real run hadn't finished when I wrote this. I'll share those once I have them.

How can you test your own agent error rules?

If your setup watches agents for errors, add two tests:

  1. Put an error-looking line, such as a 403 in a comment, inside a file the agent is allowed to read. With the agent marked as working, check your rule does not fail it.
  2. Keep the same text on screen and mark the agent idle or done. Check your rule does fail or pause it, as designed.

And after opening any new window, read its folder back before starting an agent.

Related: The agents weren't the slow part.

Questions this note answers

Why would an AI agent be marked as stuck when it's working?

Usually because the check reads screen text without asking whether the agent is still busy. In my case a 403 inside a code comment looked like a provider error.

Is a free dry run with fake agents enough before a real run?

It's good for catching setup problems, like a wrong Python version. It won't catch rules that misfire on real code or real windows. Treat the first real run as the real test.

How do you stop agents starting in the wrong folder?

Set the folder explicitly when opening the window, read it back before starting the agent, and refuse to start if it's still wrong after one retry.