published · 6 min read
When Your Coding Agent Gets Stuck, It Starts Guessing
Six hours of parameter search, ended by measuring other people's work.

An AI agent drafted this from my projects, and another agent checked the draft claim by claim against the code and the run records or briefs that were kept. The projects and opinions are mine.
Give a coding agent a failing check and a set of knobs, and it will turn the knobs. I've been building Kubet Mono, a monospace font for code and terminals, with an agent loop. Its Italic kept failing a check that keeps similar characters apart, and for about six hours the builder agent searched slant, width, weight and five more knobs. Then another agent measured the open reference fonts: the slash through their ø had a median angle of 56.4°, and Kubet's was 39.9°, so at 9 and 10 pixels Kubet's ø read as an e. Slash angle was never one of the knobs.
Most failing checks have a nearby fix, and trying a few values is a reasonable way to find it. Trouble starts when the fix isn't nearby: the agent keeps turning knobs, each attempt fixes one thing and breaks another, and the log fills with reasonable-looking work that isn't going anywhere. Not every run looks like this. Anthropic's usage data has Claude Code stopping to ask for clarification more than twice as often as people interrupt it on the most complex tasks, though the report warns it may not be stopping at the right moments. That data is from interactive Claude Code sessions; the agent in this story ran unattended.
The task
The builder was a Codex model running unattended in pi-ralph-loop. A glyph is a Python
program, and builds were scored against a set of reference fonts that grew to 16, at real terminal
sizes. A check makes sure similar-looking characters stay distinguishable: 0 against O,
1 against l, ø against o.
When the Italic kept failing that check on a handful of pairs, the builder agent did what agents do.
It started with 40 trial profiles of slant, width and weight, then ran three grids over detail, bearing, comma reach, ring size and corner radius. One grid's best result cleared the target list and added four
new flagged pairs, and the next cleared three of those and left one. In all it took about six hours.
A separate supervisor agent reviewed the repo hourly and noticed, in a note saying the item "has
consumed over five hours". That was accurate, and it changed nothing. Right before the outside diagnosis, the loop's last WIP commit says Eight registered serial trials yield no keeper, then registers one more experiment.

Diagnosis from outside the loop
Claude Code, running on my laptop as my proxy, stepped out of the builder's search and did five things:
- Find the worst condition: not "this pair fails" but "this pair fails at 10 px with light hinting".
- Render that exact condition large (16x) and look at it.
- Measure the same feature in the reference fonts: median and spread, plus where Kubet sits.
- Find the construction in the code: which function draws it, and which line.
- Write a single instruction with those numbers and a prediction of what should change.
Step 3 gave the answer. In Kubet the slash through ø was a 39.9° chord sitting inside the bowl. Across the
open reference fonts the median was 56.4°, with the slash running past the bowl. At 9 and 10 pixels,
Kubet's ø read as an e. The grid had never searched that, because the slash angle wasn't
among the five knobs.
In the first stage after the directive with those numbers, the last failing pair, e against ø,
passed. That directive landed 23 minutes after the last WIP commit, though nothing records when the diagnosis began, and the item took about eight more hours of construction fixes to close, including the Ø correction below. Directives like it carry the label "Owner", and my proxy often wrote them.

A side effect on the capital Ø
After that there was a further step, and my proxy skipped it the first time. Applying the new rule for the slash pushed
the capital Ø slightly outside its cell in the Italic, and no check caught it, because none
measured that. My proxy caught it only by checking every glyph the rule touched; it measured Ø
separately and sent a correction the same day. In the Italic, Ø's ink sat 16-35 units outside the cell. That correction gave Ø the genre's own slash, 60.2° with a .046 cap, and kept the ink inside.
So the recipe has a sixth step: after the fix, inspect everything it changed, including what the
checks don't cover.
Measured directives and vague ones
Over eight days, Claude Code on my laptop (acting as my proxy) and I wrote about 125 directives to
the build loop, and most of the measuring was the proxy's work.
A directive with measurements tended to land quickly: "the reference median is X, the spread is Y, Kubet is at Z, the cause is in this function". A vague directive (imagine "make the Italic slash feel more natural") got grid-searched. Nobody counted how many of the 125 carried measurements or how each fared, so this is an impression, not a rate, and it isn't absolute: the slash directive itself needed the Ø correction, and a later measured package failed through five rounds and was rejected.
A vague instruction leaves the search space open, and searching is a sensible response to an open
space. A measured instruction closes the space.
A budget for parameter search
After about two hours on a single item, or two rejected experiments in a row, stop the parameter search. Switch to diagnosis: worst condition, look, measure the references, locate the code, one instruction with numbers. Whoever does the diagnosis doesn't have to be human, but needs time to measure instead of try. Here it also had the authority to stop the search: my supervisor was outside the loop too, noticed the stall, and could only comment. And the diagnosis came from a different agent, Claude Code acting as my proxy, so one case can't say whether the authority, the outside view or the other model mattered. The two hours aren't a magic number, but without some budget a stuck agent looks exactly like a busy agent, and the log keeps filling with commits. In a study of agent trajectories, failed RepairAgent runs averaged 40 steps (RepairAgent's iteration cap) against 22 for successful ones. AutoCodeRover's failed and successful runs had similar average lengths. The same study found that repeated actions, particularly in RepairAgent and AutoCodeRover, strongly correlated with failure. OpenHands' stuck detector, on by default, looks for that (the same action and observation four times running), but a grid that changes its values every trial wouldn't trip it.
Next time it gets stuck
Next time an agent has been on the same failing check for a while, don't add another instruction. Ask it to stop and answer three questions instead:
- What is the single worst case, exactly?
- What do working examples (other libraries, other files, reference outputs) do at that point?
- Which line of our code produces the difference?
If it can answer all three, the fix is usually a step away, and if it can't, that's the problem to work on.