The Pattern

Across a dozen long-running agents we have run, the failure mode that shows up most often is not bad reasoning, bad tools, or bad prompts. It is the absence of a clear stop condition.

The symptom is always some variant of:

  • The agent ran until the token budget hit and then stopped mid-task.
  • The agent stopped on its own, but at a point that did not match the

task's actual success criterion.

  • The agent kept going past the point where a human would have

stopped it, because no human was watching.

What Tempted the Mistake

The temptation is to leave termination implicit. "The model will know when it is done." That sentence is the bug.

The model has no privileged access to "done." It has access to:

  • The conversation so far.
  • The context it was assembled with.
  • A vague sense that emitting a final reply is one of the available

actions.

None of those is a definition of "done" for this task. The model will guess. Sometimes the guess is right. Often it isn't.

What Works

A stop condition that is:

1. Stated before the loop starts. In the system prompt, in the first user message, or in a structured plan. Anywhere visible to every iteration. 2. Testable. "Done when X is true" beats "done when I feel like it." If you can't check it, it isn't a condition. 3. Bounded. A maximum number of iterations, a maximum token cost, a maximum wall-clock time. The bound is the safety net. 4. Owned. Someone (the human, the parent agent, a watchdog) is responsible for declaring the loop terminated, not just for noticing it ran too long.

Three concrete patterns:

  • "Stop after N tool calls and emit a summary." Easy. Bounds the

cost. The summary is the artifact, not the work.

  • "Stop when this JSON field is set to true." The agent writes

the field; a separate check inspects it. Decouples the agent's judgment from the termination decision.

  • "Stop when the verifier passes." A second agent or a hard

rule checks the output. The producer doesn't terminate itself.

What Doesn't Work

  • "Be concise." A prompt instruction, not a condition.
  • "Use your judgment." A way of saying the author didn't think about

it.

  • "Stop when you're confident." Confidence isn't observable.

What To Take Away

Before you put a long-running agent in front of a real workload, answer one question in writing: how does this loop know it is done?

If the answer is "it will figure it out," the loop will figure it out the wrong way, at the wrong time, and you will debug it the hard way.

If the answer is in writing, you can test it. If you can test it, you can fix it before it costs you a budget or a customer.