liveBook · Manning

Stopping criterion

As explained in AI Agents in Action, Second Edition

A stop condition is a rule that determines when an iterative agent process must terminate.

A stopping criterion is a rule that tells an iterative agent when to terminate instead of starting another sense–plan–act cycle. The agent may stop because it satisfied the goal, reached a safety boundary, met a quality bar, or stopped making meaningful progress. section 9.1.1 section 9.2.4

Layer stopping criteria so success checks and defensive controls work together:

  • Hard limit: stop after a maximum number of iterations or turns; always include this safety net. section 9.2.4 section 11.1.3
  • Budget limit: stop when token or cost spending reaches its ceiling. section 9.2.4
  • Goal satisfaction: stop when the agent declares the goal complete, while recognizing that self-assessment may be biased. section 9.2.4
  • Quality threshold: stop when an evaluator or self-evaluation exceeds the required confidence level. section 9.2.4
  • Stagnation detection: stop when successive outputs remain too similar and the agent is producing diminishing returns. section 9.2.4

A practical termination gate

A research loop can check, in order, whether it has exceeded its iteration cap, exhausted its budget, satisfied the goal, passed a quality threshold, or stagnated. For stagnation, compare consecutive iteration summaries with vector embeddings and cosine similarity; repeated overlap above a chosen threshold can trigger exit. A small planning agent illustrates the hard limit with MAX_TURNS = 3 and a typed Answer model carrying status, checklist, summary, and sources. section 9.2.4 section 11.1.3

Figure 9.1 The core agentic loop. The agent cycles through sense, plan, act, and evaluates the steps until the goal is satisfied or a termination condition is triggered. Internal state accumulates across iterations, giving each cycle more context than the last.

Use the core-loop figure to see where the stopping criterion sits: after sensing, planning, acting, and evaluating, before another iteration begins. section 9.1.1

How AI Agents in Action, Second Edition covers it

How deep it goes
Defines a layered termination gate with hard, budget, goal, quality, and stagnation checks, but does not provide complete implementation code.
Examples
Uses iteration caps, token budgets, goal declarations, evaluator scores, semantic-overlap checks, and a MAX_TURNS = 3 planning example.
What it assumes
Assumes an iterative agent with goals, plans, state, actions, and evaluations; treats the loop’s basic elements as foundational.
What you can do after
Operate/configure iterative agents with layered exits, hard ceilings, cost controls, and safeguards against repeated unproductive work.
How it connects
Connects agentic loops with goals, planning, state, quality thresholds, budget limits, and stagnation detection.

Also explained in

Compare how 11 books explain stopping criterion →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of AI Agents in Action, Second Edition. The section links point to the parts of the book it draws on.