Semantic Early-Stopping for Iterative LLM Agent Loops:
A Judge-Efficient Study of When to Halt
June 25, 2026
Multi-agent large language model (LLM) loops—for example a Writer that drafts and a Critic that revises—are almost always terminated by a fixed iteration cap (max_iterations). This is a syntactic
kill-switch: it is blind to whether the answer is still improving, so it over-spends tokens on easy inputs and truncates hard ones. We study semantic early-stopping: the loop halts when consecutive draft embeddings stop changing in meaning
(cosine-distance with a patience window) and the answer’s measured quality stops improving. Our work makes three contributions. First, an honest theoretical footing: we prove deterministic termination and well-definedness
and we machine-check these claims, while treating the convergence of the distance sequence as an empirically tested conjecture rather than a (previously over-claimed) Banach contraction. Second, a judge-efficient
evaluation protocol: we generate each question’s full trajectory once, replay every stopping policy over the identical drafts, and cache every LLM-judge call, which yields a strictly paired efficiency-versus-quality comparison at low cost; we
further separate operational tokens (charged to a policy) from evaluation tokens (a measurement instrument). Third, an empirical study on multi-hop retrieval-augmented question answering (HotpotQA). On the
\(60\)-question test split, a judge-free semantic stopper reduces operational tokens by 38% relative to max_iterations at parity quality (\(\Delta\mathrm{IS}=-0.004\), \(p=0.81\)), whereas the full quality-gated variant is counter-productive because its per-round judging dominates cost. An oracle that selects the
best round attains \(+0.115\) Information Score over every practical policy (\(p\!\approx\!4\times10^{-11}\)), which reframes the problem from “when to stop” (easy) to
“which round is best” (open).
LLM agents, early stopping, semantic convergence, retrieval-augmented generation, evaluation methodology, multi-agent systems.
Iterative “agentic” patterns are now a standard way to push LLM output quality beyond a single forward pass. The canonical instance is the Writer\(\rightarrow\)Critic loop: a Writer produces an answer, a Critic critiques it, the Writer revises, and the cycle repeats until some stopping rule fires. The quality of the final answer depends not only on the two models but, critically, on when the loop is allowed to stop.
In practice that decision is made by a single integer: max_iterations. The loop runs a fixed number of rounds and then returns whatever it last produced. This is convenient but blunt in two opposite ways. On easy inputs the loop
reaches a good answer in one or two rounds yet keeps spending tokens, latency, and money until the counter expires. On hard inputs the counter may expire before the answer is finished. Worst of all, an integer counter is fundamentally blind to
content: it cannot perceive that rounds four, five, and six all expressed essentially the same thing. The stopping decision is made on the iteration index, never on what was actually written.
We replace the counter with a content-aware rule. We map each draft to a sentence embedding and measure the cosine distance between consecutive drafts. When that distance stays below a small threshold \(\varepsilon\) for \(k\) consecutive rounds, the answer has converged in meaning; additional iteration is churn, and we halt. Because a fast convergence is not the same as a good convergence, we pair this geometric signal with a quality signal—an Information Score (IS) computed from retrieval-augmented generation (RAG) metrics—so the loop only halts when the answer has both stopped changing and stopped improving. Two further conditions, an explicit critic approval and a hard failsafe, complete a four-level priority cascade.
An earlier version of this project asserted that the Writer\(\rightarrow\)Critic update is a Banach contraction with a guaranteed unique fixed point. It is not: LLM generation has no proven Lipschitz constant below one and is not deterministic across API calls, so that theorem was unsupported. Rather than dress an idea in mathematics it does not earn, we kept only the claims we can prove (and machine-check) and demoted the rest to measured conjectures. This honesty is itself a contribution: it is the difference between a result a reviewer can trust and one they reject on sight.
Honest, machine-checked theory (§5): deterministic termination, well-definedness, and halt-priority consistency are proven and verified in code; semantic non-expansiveness is a measured conjecture.
A judge-efficient evaluation protocol (§6): trajectory replay, cached judging, and an operational-versus-evaluation token model that exposes hidden measurement cost.
An empirical study (§8) on HotpotQA against five baselines with paired statistics and non-inferiority testing, including the surprising finding that the full quality-gated policy is counter-productive.
Stopping a process when a monitored quantity plateaus is classical in machine learning (early stopping on a validation curve) and in adaptive-computation networks (early-exit inference). SHP transports the same intuition to the outer loop of an agent system, where the monitored quantity is the semantic change between successive natural-language drafts rather than a scalar loss.
Several lines of work study convergence of iterative operators in embedding space and the termination of multi-agent systems. SHP shares the convergence intuition but differs in two respects: it refuses the unsupported contraction guarantee, proving only termination; and it gates convergence on output quality.
Related efforts quantify cross-model disagreement at a single step, or choose which orchestration topology to use. These are orthogonal to SHP, which decides when to exit a fixed sequential topology based on content.
We use RAGAS-style reference metrics (faithfulness, answer relevancy, context precision, context recall) as the quality signal. A recurring caveat—that these metrics are themselves produced by an LLM and are therefore noisy—motivates our use of a stronger judge on the frozen split and of non-inferiority testing rather than equality testing.
A detailed, per-paper comparison—method extraction, what each work does better, and what SHP does better, following our method/gap/cost protocol—is provided in Appendix 12 (Table 4).
Definition 1 (Scenario). A scenario is a tuple \((q, C, g)\) with question \(q\), retrieved context passages \(C=\{c_1,\dots,c_n\}\), and ground-truth answer \(g\).
The loop produces drafts \(x_1,x_2,\dots\). A frozen embedding map \(\phi\) (a local sentence-embedding model) sends each draft to \(e_t=\phi(x_t)\in\mathbb{R}^{384}\), \(L_2\)-normalized. We define the per-round semantic distance \[d_t \;=\;
1-\cos(e_t,e_{t-1})
\;=\; 1-\frac{\langle e_t,e_{t-1}\rangle}{\lVert e_t\rVert\,\lVert e_{t-1}\rVert}
\in[0,2],\quad t\ge2.
\label{eq:dist}\tag{1}\] A judge assigns four metrics \(m\in\mathcal{M}\), each in \([0,1]\); with weights \(w\) on the probability simplex
\(\Delta=\{w:w_m\ge0,\sum_m w_m=1\}\) the Information Score is \[\mathrm{IS}_t \;=\; \sum_{m\in\mathcal{M}} w_m\,\mathrm{metric}_m(x_t)\in[0,1].
\label{eq:is}\tag{2}\] The halting operator \(H\) maps the round state \(s_t=(t,(d_2,\dots,d_t),(\mathrm{IS}_1,\dots,\mathrm{IS}_t),\text{feedback}_t)\) to a
decision in \(\{\textsf{continue}\}\cup\mathcal{R}\) with reason set \(\mathcal{R}=\{\)critic, entropy, no_gain, failsafe\(\}\). The realized stopping time is \(\tau=\min\{t:H(s_t)\neq\textsf{continue}\}\).
Both agents are conditioned on the retrieved contexts. This is not cosmetic: in an earlier iteration the Writer answered from parametric memory and never read \(C\), yet the judge scored faithfulness to \(C\)—a silent invalidity that would have undermined every quality number. Grounding both agents on \(C\) is the first of several corrections discussed in §4.5.
Equation 1 gives a cheap, API-free measure of how much the answer changed; Equation 2 measures how good it is. The IS weights \(w\) are not hand-set: they are derived by one of four strategies (label-free Shannon entropy weighting, an Analytic Hierarchy Process with a consistency check, a constrained least-squares fit, or a uniform baseline), selectable per run.
The four signals are evaluated in a fixed priority order (Fig. 2). Crucially, the cascade is implemented once as a pure function and reused by (i) the live loop, (ii) the post-hoc reason derivation, and (iii) the
offline policy replay, so they cannot disagree. Listing [lst:halt] shows the core; note that the final failsafe clause is unconditional—it is governed by no signal
flag—which is precisely what makes the termination guarantee (Theorem 1) hold.
Listing lst:halt: The single shared halt decision (simplified).
def shp_should_halt(t, dist_hist, is_hist,
feedback, cfg):
if not dist_hist: # round 1
return CONTINUE
if cfg.critic and feedback.startswith("APPROVED"):
return HALT("critic")
if cfg.entropy and len(dist_hist) >= cfg.k \;
and all(d < cfg.eps for d in dist_hist[-cfg.k:]):
return HALT("entropy")
if cfg.is_gain and t >= cfg.warmup \;
and is_hist[-1] - is_hist[-2] <= 0:
return HALT("no_gain")
if t >= cfg.max_rounds: # never ablatable
return HALT("failsafe")
return CONTINUE
Table 1 traces one real question from our data through the loop. The answer changes substantially in early rounds (the semantic distance is large and the quality rises), then stabilizes: by round 3 the distance has fallen
below \(\varepsilon\), and a second consecutive sub-threshold round at round 4 triggers the entropy halt. The max_iterations baseline would have run all six rounds; SHP stops at round 4, saving a third of the
work while the quality is already at its plateau. This single trace captures the whole thesis: the loop earns its keep early and idles late, and a content signal can tell the difference.
| Round | Words | \(d_t\) | \(\mathrm{IS}_t\) | Decision |
|---|---|---|---|---|
| 1 | 16 | — | 0.54 | continue |
| 2 | 82 | 0.144 | 0.62 | continue (large change) |
| 3 | 110 | 0.027 | 0.64 | continue (\(1^{\text{st}}\) sub-\(\varepsilon\)) |
| 4 | 162 | 0.007 | 0.62 | HALT (entropy, \(k{=}2\)) |
| (baseline would continue:) | ||||
| 5 | 177 | 0.003 | 0.66 | wasted under baseline |
| 6 | — | — | — | wasted under baseline |
5pt
A faithful account of the work includes what broke and how it was fixed; these are not incidental, they shaped the design and the results.
Over-claimed theory. Problem: a Banach-contraction claim with no supporting Lipschitz bound. Fix: prove only termination and well-definedness (§5); measure convergence empirically.
Agents ignored retrieval. Problem: the Writer answered closed-book while the judge scored grounding in \(C\). Fix: condition both agents on \(C\) (§4); quality numbers are now valid.
Duplicated stop logic. Problem: the live cascade and the post-hoc reason derivation used different orderings and could disagree. Fix: one shared pure function (Listing [lst:halt]); consistency is machine-checked (Lemma 2).
Fair, cheap comparison. Problem: re-running the loop per policy confounds generation noise and re-pays the judge. Fix: trajectory replay with cached judging (§6).
Hidden cost of the quality signal. Problem: the information-gain signal silently calls the judge every round. Fix: an operational-versus-evaluation token model, which revealed that full SHP is the most expensive policy (§8).
Compute limits. Problem: a free-tier provider throttled the runs to a crawl. Fix: an OpenAI-compatible high-throughput provider, a resumable on-disk cache, and exponential backoff on rate limits.
We prove only what holds; each proven claim is machine-checked by an executable test suite (theory_checks.py) that a reviewer can rerun.
Theorem 1 (Termination). For any input, any weights, any signal configuration, and any (possibly adversarial) draft sequence, the loop halts in at most \(T_{\max}\) rounds.
Proof. The Critic increments \(t\) by exactly one per round. The failsafe clause of \(H\) returns failsafe whenever \(t\ge
T_{\max}\) and is unconditional—it is not governed by any signal or ablation flag. Hence \(H(s_t)\neq\textsf{continue}\) for all \(t\ge T_{\max}\), so \(\tau\le T_{\max}\). ◻
Lemma 1 (Well-definedness). If \(w\in\Delta\) and each metric lies in \([0,1]\) then \(\mathrm{IS}_t\in[0,1]\). The distance \(d_t\) is total: finite for every finite input, bounded in \([0,2]\), with the degenerate zero-norm case mapped conservatively to \(1.0\) so it cannot cause a false-positive halt.
Lemma 2 (Halt-priority consistency). The reason reported after a run equals the reason that stopped it, because both the live decision and the post-hoc derivation invoke the same function \(H\).
Conjecture 1 (Semantic non-expansiveness; empirical). Across trajectories \(d_t\) is, on average, non-increasing in \(t\). We make no guarantee: we measure* the fraction of monotone trajectories, the mean regression slope with a bootstrap \(95\%\) CI, and a one-sided Wilcoxon test on \(d_t-d_{t-1}\), and we report null results where they occur.*
Theorem 1 is the honest replacement for the discarded contraction claim: SHP guarantees termination, not contraction.
Comparing stopping policies fairly is itself a methodological problem, and we treat it as a contribution.
For each question we generate the full Writer\(\rightarrow\)Critic trajectory once, to depth \(T_{\max}\), caching every draft and embedding. Each stopping policy then replays over this single cached trajectory and chooses its own stop round. Two benefits follow: (i) all policies see identical drafts, so a difference in rounds or quality is attributable to the policy and not to generation noise—a strictly paired comparison; and (ii) the costly generation is paid once rather than once per policy.
The RAGAS judge is the binding cost. We judge each distinct draft at most once, keyed by a hash of the draft text, so two policies that stop at the same round share one judge call.
We distinguish the tokens a policy spends to run (Writer \(+\) Critic every round, plus the judge only if the policy consults the quality signal to decide) from the tokens we spend to measure final quality (never charged to the policy). This distinction is what reveals that the full cascade pays a large hidden cost (§8).
All tests are paired across questions. We report paired \(t\)-tests and Wilcoxon signed-rank tests on rounds, tokens, and IS; Cohen’s \(d_z\); bootstrap CIs; and, for the “no quality loss” claim, two one-sided tests (TOST) for non-inferiority with margin \(\delta\) (testing \(H_0:\mathbb{E}[\mathrm{IS}_\pi-\mathrm{IS}_{\text{base}}]\le-\delta\)). Token savings are reported as \((T_{\text{base}}-T_\pi)/T_{\text{base}}\).
We use HotpotQA [1], a peer-reviewed multi-hop question-answering benchmark, in its distractor setting, streamed directly from
the public HuggingFace Hub (hotpot_qa/distractor, validation split). Our builder programmatically (i) filters to multi-hop hard questions, so a single draft rarely suffices and the loop has genuine room to iterate; (ii) for each
question forms a realistic retrieval context of the gold supporting paragraphs plus distractor paragraphs (\(\approx4\) contexts total); and (iii) assigns a deterministic development/test split by hashing
the example identifier (no randomness, fully reproducible). This yields \(N\!\approx\!80\) scenarios, \(20\) development / \(60\) test. How the data is
used: the question and its contexts are given to both the Writer and the Critic (RAG grounding), and the context and the gold answer are given to the RAGAS judge to compute the four quality metrics. The thresholds \(\varepsilon,k\) are tuned on the development split only; the test split is frozen and report-only.
All numbers below come from live LLM inference—real Writer/Critic generations, real judge scores, measured token counts and embeddings—not from simulation. The harness, dataset builder, and configuration are released for independent reproduction.
Both the Writer/Critic agents and the RAGAS judge use an 8B instruction model (llama-3.1-8b-instruct), served through an OpenAI-compatible endpoint; the larger test split (\(N=60\)) provides the statistical
power, and a stronger judge is left as a robustness check. Embeddings are local. Compute is credit-based and modest, a limitation we state openly.
shp (full cascade); entropy_only (the judge-free variant: cosine-distance signal \(+\) failsafe); critic_only; fixed_k for \(k\in\{1,3,6\}\) (fixed_k6 is the max_iterations baseline); random_stop; and oracle_is, which stops at the round of maximum measured IS and serves as a quality upper bound. A
seven-cell ablation toggles each signal.
Table 2 reports the realized development-split outcome; the baseline is fixed_k6.
| Policy | Rounds | Op.tokens | vs base | Final IS |
|---|---|---|---|---|
| fixed_k6 (base) | 6.0 | 11,281 | — | 0.651 |
| entropy_only | 4.05 | 7,068 | \(-37\%\) | 0.661 |
| critic_only | 6.0 | 11,281 | \(0\%\) | 0.651 |
| fixed_k3 | 3.0 | 5,217 | \(-54\%\) | 0.629 |
| fixed_k1 | 1.0 | 1,548 | \(-86\%\) | 0.661 |
| shp (full) | 2.6 | 27,130 | \(+140\%\) | 0.636 |
| oracle_is | 3.1 | 33,007 | \(+193\%\) | 0.782 |
4pt
Table 3 reports the realized results on the frozen \(60\)-question test split—the headline numbers—which confirm and sharpen the development trend with three times the sample size. The
baseline is again fixed_k6 (\(6.0\) rounds, \(11{,}070\) operational tokens, \(\mathrm{IS}=0.670\)). All significance tests are paired across
the \(60\) questions.
| Policy | Rounds | Tokens | \(\Delta\)IS | \(p\) | Non-inf. |
|---|---|---|---|---|---|
| fixed_k6 (base) | 6.0 | — | — | — | — |
| entropy_only | 3.92 | \(-38\%\) | \(-0.004\) | 0.81 | no\(^\dagger\) |
| critic_only | 6.0 | \(0\%\) | \(0.000\) | — | — |
| fixed_k3 | 3.0 | \(-53\%\) | \(+0.001\) | 0.97 | no\(^\dagger\) |
| fixed_k1 | 1.0 | \(-86\%\) | \(+0.030\) | 0.17 | yes |
| shp (full) | 2.40 | \(+129\%\) | \(-0.004\) | 0.78 | no |
| oracle_is | 2.73 | \(+170\%\) | \(+0.115\) | \(3e{-}11\) | yes |
3.5pt
\(^\dagger\)Point estimate at parity (\(|\Delta\mathrm{IS}|\le0.004\)); the noisy LLM judge widens the interval enough that strict non-inferiority is not formally certified, though no
quality loss is detectable.
Over the \(300\) per-round test distances, the mean and median are \(0.040\) and \(0.022\) with a maximum of \(0.39\); \(80\%\) fall below \(\varepsilon=0.06\) (Fig. 6). Testing Conjecture 1 directly, the per-step differences \(d_t-d_{t-1}\) are significantly negative (one-sided Wilcoxon \(p=1.3\times10^{-3}\); mean OLS slope \(-0.009\)): distances decrease on average across rounds. However, only \(\sim5\%\) of trajectories are strictly monotone—the descent is real but noisy. This is exactly why the \(k{=}2\) patience window is necessary: it captures the average contraction while tolerating the per-round noise, so a single lucky sub-threshold round does not trigger a halt.
The test split (\(N=60\)) confirms and sharpens the development trend.
The efficiency claim holds. Judge-free entropy_only cuts \(38\%\) of operational tokens versus max_iterations at statistically indistinguishable
quality (\(\Delta\mathrm{IS}=-0.004\), \(p=0.81\)). fixed_k3 likewise saves \(53\%\) at parity. Stopping early is both cheap and safe.
Full SHP is counter-productive. Consulting the judge every round to power the information-gain signal makes shp the most expensive policy—\(+129\%\) tokens (\(2.3\times\) the baseline)—for no quality benefit. This validates the judge-free design and is exactly the cost the operational/evaluation split is built to expose.
Iteration does not improve measured quality here—it slightly hurts it. The single best practical policy is fixed_k1: returning the first grounded draft is the cheapest (\(-86\%\) tokens) and the highest quality (\(\mathrm{IS}=0.700\), \(\Delta=+0.030\), TOST non-inferior). Meanwhile the oracle reaches \(0.785\) (\(+0.115\), \(p\!\approx\!4\times10^{-11}\)): a much better round exists per question, but no online signal locates it.
Are these results promising? On efficiency, yes and immediately actionable: a free, guaranteed-terminating stopper removes \(38\%\) of the token cost of the standard
max_iterations loop with no detectable quality loss. On quality, the result is honest and informative rather than triumphant: on this benchmark iteration does not pay, and the largest opportunity is the oracle gap—a
concrete, measurable target that turns “identify the best round” into the central open problem.
The results separate a solved problem from an open one. Stopping early for efficiency is easy and safe: the free entropy signal saves tokens and the failsafe guarantees termination. Stopping at the best round for quality is unsolved: the oracle gap shows substantial unrealized headroom that neither cosine distance nor information gain captures. We therefore reframe SHP’s lasting contribution as (a) a guaranteed-terminating, judge-free stopper that saves tokens at parity quality, and (b) an evaluation protocol and an oracle target that make best-round identification measurable for future work.
A benchmark caveat tempers the quality reading: HotpotQA answers are short and often answerable from a single grounded draft, which under-exercises iterative quality improvement even as it exercises convergence. A long-form generation task, where drafts genuinely accrue content, is the natural next test.
Two limitations temper the quality reading. (i) The judge is a noisy LLM proxy. Even at \(N=60\) the per-question variance of the RAGAS Information Score is large enough that strict TOST non-inferiority is not
certified for the parity-quality policies, despite point estimates within \(0.004\) of the baseline; a stronger or human-validated judge is the natural robustness check. (ii) The benchmark under-exercises
iteration. HotpotQA answers are short and often answerable from a single grounded draft, which is precisely why fixed_k1 wins on quality; a long-form generation task, where drafts genuinely accrue content, is required to test whether
iteration ever pays. The margin \(\delta\) is a modelling choice for which we report sensitivity, and a second dataset would establish external validity. Finally, Conjecture 1 holds only on average (Section 8.2); Theorem 1 keeps the system safe regardless.
SHP reframes “when to stop an agent loop” from a blind counter to a content-aware, quality-gated decision, backed by an honest termination guarantee and a reusable, judge-efficient evaluation protocol. Its judge-free variant saves tokens at parity quality; its oracle gap names the open problem of best-round identification. Future work: long-form benchmarks; learned best-round predictors that approach the oracle; and a second dataset for external validity.
We position SHP against five recent works that share its mathematical backbone (fixed points and contraction), its setting (multi-agent LLM systems), or its motivation (wasted iteration). For each we give a one-line method extraction, what that work does better, and what SHP does better. Table 4 summarizes the relevance along three axes.
4pt
Method. Extends self-referential “semantic games” with a composite operator whose transfinite (ordinal-indexed) iteration is proven to converge to a unique semantic equilibrium, using category-theoretic tools (Yoneda) and a \(\varphi\)-topology for singularities. Does better: far deeper mathematics and a genuine existence-and-uniqueness proof. SHP does better: it is a deployed, quality-gated, data-driven system; Alpay V is purely theoretical and has no notion of output quality. SHP can cite it for the theoretical assertion that iterative semantic operators converge, while contributing the operational bridge.
Method. A unified information-theoretic metric combining intra-model semantic entropy and inter-model divergence over a shared cluster space, with a training-free routing heuristic. Does better: formal entropy measures and cross-model disagreement, benchmarked on TriviaQA/SQuAD. SHP does better: it targets temporal convergence across rounds of one loop rather than cross-model spread at one instant, and it grounds halting in output quality. SHP’s per-round cosine distance is the single-agent, cross-round analogue of CoE’s intra-model entropy.
Method. Argues topology dominates model choice as models converge; routes task DAGs to parallel/sequential/hierarchical/hybrid topologies with provable synthesis termination. Does better: handles many topologies and proves termination across them; broad benchmark suite. SHP does better: its termination is driven by meaning convergence and gated on quality, not by structural heuristics. The two are orthogonal: given a fixed topology, SHP decides when to exit.
Method. Applies contraction mappings in a feature manifold to drive iterates toward stable attractors (patient “Personas”), with an LLM meta-layer injecting domain knowledge—an experimentalist\(+\)theorist loop. Does better: a cohesive contraction/information-geometry formalism validated on real clinical data with measurable AUC gains. SHP does better: it operates in the text/QA domain with multi-dimensional RAG quality scoring and a full real-time stack. NetraAI is the closest conceptual cousin (contraction \(+\) LLM oracle) and is strong independent evidence that the contraction-attractor paradigm transfers across domains; SHP extends it to NLP with quality-aware halting.
Method. Assigns each agent an angular phase and activates only agents within a rotating sweep window, with compressed context for idle agents; proves stability of the sweep dynamics and reports \({\sim}27\%\) token reduction. Does better: a concrete token-efficiency mechanism for \(N\)-agent systems with stability proofs. SHP does better: it decides global termination of the loop, not which agent fires when. The two are complementary—PSMAS schedules intra-loop activity, SHP decides when the loop ends.
Across all five, SHP’s consistent differentiators are (1) quality-gated halting (no other work ties geometric convergence to a multi-metric quality score), (2) the judge-efficient, paired evaluation protocol with operational/evaluation cost separation, and (3) engineering honesty—a proven termination guarantee in place of an unsupported contraction claim. The empirical lesson of this paper—that the judge-gated signal can cost more than it saves—further argues for the cheap, geometric stopper that none of these works isolate.
Every run stores seeds, the git commit hash, and the fully resolved configuration. Proven theoretical claims are verified by python -m shp.theory_checks. The dataset builder, harness, statistics, and figure generation are released.