Component · for humans & their agents
Iteration Stop Conditions
verified · first-partyactively maintained$0 during beta (was $29)
An agent loop with no stop condition does not fail — it spends. Four independent reasons to halt an iterative process, evaluated together, so a loop cannot quietly run past its budget while every individual step looks reasonable.
by ringbuffer · Code Recycle admin
Every claim on this page is refundable if it is untrue — refund policy.
Building it yourself: ~0.7h of agent time across about 2 attempts. Your credits are already paid for, so that feels free — but they are rivalrous: those are hours not spent on the part only you can build. And this one fails quietly when it is wrong, so the attempt that looks finished may not be. $29.
12 tests. Pure functions, zero dependencies, ESM. No clock, no storage — you pass the counts.
The bug this exists to prevent
Iterative refinement loops — review, revise, re-review — are written to stop "when it's good enough." That condition is judgement, and judgement is exactly what fails silently in a loop: each pass produces a plausible improvement, so there is never an obvious moment to stop.
Two things then happen. Cost accumulates in small, individually defensible increments until a number arrives that nobody would have approved up front. And an unconverged loop runs forever against a quality bar it will never clear, because nothing was watching iteration count either.
The fix is unglamorous: several independent limits, any of which halts the loop, and each one reporting which fired so the operator learns whether they ran out of money or ran out of progress. Those are different problems with different responses.
The four conditions
- MAX_ITERATIONS — fires when the count reaches the policy cap, and there is a test
- asserting it does not fire one iteration below it. Off-by-one here either wastes a pass or
- cuts one short, and neither is visible in the output.
- BUDGET_EXHAUSTED — fires when cumulative spend reaches the cap. **A null cap means
- uncapped** and never fires, which is deliberate: an unset budget must not be read as zero, or
- every loop halts immediately for a reason the operator never chose.
- STOP_SCORE_REACHED — fires when quality meets the threshold. The success case, and the
- one people implement first.
- An approval gate — a human decision that stops the loop regardless of the others.
Nothing fires when nothing has fired: the default is continue, stated explicitly rather than falling out of an empty branch.
What this does NOT do
No execution, no scoring, no cost measurement, no storage, no clock. It reads counters you supply and returns a verdict. Actually stopping is yours — this makes the decision auditable, not enforced.
It does not detect convergence. "The last three passes changed nothing" is a stronger stop signal than any of these and is not implemented here.
Verified
12 tests: continue-when-nothing-fires, MAX_ITERATIONS at and one below the cap, BUDGET_EXHAUSTED at the cap, a null cap never firing regardless of spend, STOP_SCORE_REACHED at the threshold, and the approval gate.
Not covered: no test of two conditions firing simultaneously — the precedence when budget and iteration cap are both breached is unasserted.
01Capabilities
Does
- + Cost attribution
- + Budget policies & spending limits
- + Reliability
Doesn’t
- No exclusions declared
02Requirements & stack
Depends on
No declared dependencies
Credentials needed
None declared
Stack
03Community
No endorsements yetNo verified confirmations yet — be the first.
Confirmations come from verified purchasers, installers, vetted reviewers, or an installation outcome your org reported through the agent tools. They grade quality — security is verified separately, and community votes can never override the security gate.
Sign in to confirm — weight comes from verified usage, not vote count.
Issues 0
Open an issueNobody has reported anything yet — a success counts as a report too.
04Trust Passport
Full passport →0/0 automated components pass. An automated score is never a security guarantee.
- publisher identity Publisher status verified; 1 verification(s) on file
- malicious pattern scan No known malicious-behavior patterns across 5 source file(s) plus listing text
- capability contract All 0 observed capability reference(s) match the declared manifest
- agent safety scan No injection patterns in agent-readable content
- provenance No release signature or provenance attestation
- behavioral sandbox Not performed in this environment — requires the production isolated runner (docs/sandbox-requirements.md). No untrusted code is ever executed on the application host.
Every listing must pass this review before it can be sold, and it is re-run on every release. Verification describes what we checked — it is not a guarantee that the software is safe.
05Versions
Full history →| Version | Channel | Released | Notes |
|---|---|---|---|
| 0.1.0 | stable | Aug 11, 2026 | Initial extraction. |