Inside an AI Agent Loop: The Only Step That Touches Reality

Onyx breaks down one real pass of an agent loop for the Mycroft project, showing why the observation step is the only one that touches reality.

3:25 video3 min readWatch on YouTube

An agent loop diagram makes the process look tidy: thought, action, observation, repeat. Diagrams are where bugs go to hide, though, and the real story only shows up when you run a single pass for real and read exactly what each step produces. Built around the Mycroft project, this walkthrough breaks down one unabstracted pass of an agent loop to find the part almost every implementation gets wrong, and it isn't the thinking.

Three moves, only one of them real

A thought is the model picking a next step and explaining why. An action is the tool call itself, made once, with arguments. An observation is what actually came back. Two of those three moves are the model talking to itself; only the observation is reality checking in. Printing a real pass instead of relying on the tidy three-arrow diagram makes this split obvious: you can watch a thought and an action get generated with total confidence, and then watch the observation either confirm or contradict everything that came before it.

Why the observation is load-bearing

The core claim is that everything besides the observation is the model reasoning about its own output, something it will do confidently and indefinitely whether or not it's right. The observation is the only place the real world gets to disagree with the model. A good observation carries three things: what was called, arguments included, so the next pass can tell similar calls apart; the actual value that came back, not a summary of it; and, if the call failed, the error message word for word. Leaving out any one of those three deletes the evidence the next pass needs to work with.

The seven-line rule for tool runners

The rule for calling a tool is simple: if it raises an error, return that error as the observation. Don't swallow it, and don't just log it somewhere the model can't see, because the model can't see logs. Otherwise, return the value alongside the call that produced it. Skip that discipline and the loop degrades fast: the model proposes an action, nothing contradicts it, so it proposes again from the same information with the same confidence. That isn't an agent working, it's one guess repeated several times over at several times the cost.

Four ways agent loops die

Even with honest observations in place, loops still end badly, and they die in one of four ways: no progress, where the same call repeats forever; oscillation, where the loop alternates between two actions without resolving; budget exhausted, the only genuinely honest failure of the four; and false completion, where the loop declares itself finished when it isn't.

Writing your own stopping rules

Because a model can't be trusted to end the loop correctly on its own, the stopping rules have to come from outside it: a step budget that bounds the worst case in advance, a no-progress check that catches a repeated call before it gets paid for again, and an explicit done check, something outside the model that independently agrees the goal has actually been met. That third check is the one almost nobody writes first, and it's the one that catches false completion before it ships.

Key takeaways

  • An agent loop pass has three moves, thought, action, observation, but only the observation reflects what actually happened in the world.
  • A good observation includes the call and its arguments, the actual returned value, and the exact error message on failure; summarizing any of these deletes evidence the next pass needs.
  • A tool runner should return errors as observations rather than swallowing or only logging them, since the model can't see logs.
  • Loops die in four ways: no progress, oscillation, budget exhausted, and false completion.
  • Because a model can't reliably self-report that it's finished, stopping rules, a step budget, a no-progress check, and an external done check, have to be written by the developer, not inferred by the model.

Who this is for

This is built for anyone building or debugging tool-calling agents, particularly Humanitarians AI Fellows working on the Mycroft project who need agents that fail loudly instead of quietly repeating the same mistake. It's episode two in a ten-part series on agent design that started by defining what an agent even is, a model inside a loop that can act, and continues next Friday with why the description you write for a tool matters more than the code behind it.

Chapters

  1. 0:00Moving from clean loop diagrams to actual physical runs
  2. 0:45The 3 moves in a single pass: Thought, Action, and Observation
  3. 1:30Why observations are load-bearing and thoughts are just narration
  4. 2:15Writing an honest 7-line tool runner that never swallows errors
  5. 3:00The 4 ways agent loops die (and how to spot them)
Full transcript(auto-generated, with timestamps)

Moving from clean loop diagrams to actual physical runs

[0:00]This is Onyx in for Humanitarians AI. Last week we defined an agent, a model inside a loop that can act. This week we go inside a single pass of that loop and find the part that is actually holding the whole thing up. It is not the thinking, it is the part almost everybody implements badly. Last week the loop was a diagram, three arrows very tidy. Diagrams are where bugs go to hide, so this week we are running it. One real pass printed out, no abstraction, and we read exactly what each step produces. One pass, three moves. A thought, the model picks a next step and says why. An action, the tool I'll call it once with arguments. An observation, what actually came back. Two of those three are the model talking to itself. Only one of them is reality. Here is a real pass printed by the file that ships with this episode. The

The 3 moves in a single pass: Thought, Action, and Observation

[0:45]Thought, the action with its arguments, then the observation, the same failed call recorded two ways. One of them tells the next pass what happened. The other one lies to it. So here is the claim, the observation is load-bearing. Everything else in that loop is the model reasoning about its own output, which it will do happily, confidently, forever. The observation is the only place the world gets to disagree with it. A good observation carries three things. What was called, arguments included, so the next pass can tell two similar calls apart. The value that actually came back, not a summary of it. And when it failed, the error word for word. Summarize any one of these and you have deleted the evidence. That is seven lines called a tool. If it raises, return the error as the observation, do not swallow it, do not log it somewhere

Why observations are load-bearing and thoughts are just narration

[1:30]The model cannot see. Otherwise, return the value alongside the call that produced it. The comment on line five is the entire episode. Take that honest observation away and watch what the loop becomes. The model proposes, nothing contradicts it, so it proposes again from the same information with the same confidence. That is not an agent working, that is one guess repeated eight times at eight times the price. Even with honest observations, loops die and they die in four ways. No progress, the same call forever. Oscillation, A then B then again. Budget exhausted, which is the only honest death of the four, and false completion, it declared itself finished and it was not. Which means you write the stopping rules, not the model. A step budget, so the worst case is bounded in advance. A no progress check, so a repeat gets

Writing an honest 7-line tool runner that never swallows errors

[2:16]Caught instead of paid for. And an explicit done check, something outside the model that agrees the goal is met. Nobody writes that third one first. So, the verdict, one pass of an agent loop is three moves and only one of them touches reality. The thought and the action are the model reasoning about its own output. The observation is the evidence, and it is only evidence if it carries the call, the value, and the error verbatim. Swallow an error and the loop stops iterating and starts repeating. And because a model cannot reliably tell you it is finished, the stopping rules are yours to write. A budget, a no progress check, and something outside the model that agrees the goal is met. Your turn. Here is the prompt. Here is a tool my agent calls. Write the observation string it should return on success and on failure. Then show me the three worst observations a lazy

The 4 ways agent loops die (and how to spot them)

[3:00]Implementation would return instead and what each one costs the next pass. Run that against the tool you actually use. The second half is the useful half. You are asking it to write the bad versions on purpose, and the bad versions are the ones that sail straight through a code review. That was the agent loop episode two of 10. Next Friday, the thing the loop actually calls, tools, and why the description you write matters more than the code you write. Onex in for humanitarian's AI.

More from Humanitarians AI Fellows

Humanitarians AI Lyrical Literacy Project