Lesson 48.3 · 3 of 3 · 4 min read · Reviewed 24 Nov 2026
Knowing when to stop
By the end, you can
- Set stopping rules for refinement loops.
- Avoid over-editing.
Stop rules
| Rule | Example |
|---|---|
| Criteria pass | All tests green, every claim cited |
| Round limit | At most 3 revisions |
| No improvement | Score didn’t rise in the last round |
| Budget | Token or time cap for the task |
Use several together: “stop when criteria pass, or after 3 rounds, or if the score doesn’t improve.”
Over-editing is real
Without a stop rule, revision loops often:
- Grow the text with hedges and caveats.
- Smooth away specific, useful details.
- Drift from the original request.
- Flip-flop between two versions.
Keep the best, not the last
best = draft0; best_score = score(draft0)
for round in 1..3:
draft = revise(best, critique(best))
s = score(draft)
if s > best_score: best, best_score = draft, s
if passes(best): break
return best, remaining_failures(best)
Report honestly
If it didn’t pass, say which criteria failed. Downstream code or a person can then decide: accept, fix by hand, or escalateEscalation: Handing a case from an agent to a person, with the context needed to continue..
Key points
- Stop when the criteria pass, when a round limit is hit, or when changes stop improving the score.
- Endless revision can make outputs worse: longer, blander, or drifting from the task.
- Track a score or a checklist per round so you can see when gains flatten.
- If the limit is hit without passing, return the best version and flag what still fails.
Stop a revise loop at the right time
Apply pass, no-improvement and round-limit stop rules and return the best draft with an honest flag.
You will have: A revise loop that stops for a stated reason and returns the best-scoring round.
Steps
- Run the starter: it runs every round and returns the last, lower-scoring draft.
- Stop as soon as a draft reaches the pass mark.
- Stop when a round does not improve on the best score so far.
- Keep the best round, not the latest.
- Change SCORES so round 3 scores 9 and check the loop stops on 'criteria pass'.
Done when
- The solution stops at round 3 for no improvement.
- It returns round 2 with score 8, not round 5 with score 6.
- It flags that the pass mark of 9 was not met.
Open in the Playground No API key needed.
Starter code (Python)
# Stop a revise loop at the right time, and keep the best draft, not the last.
SCORES = [5, 7, 8, 8, 7, 6] # simulated rubric score of draft v0, v1, v2 ... after each revision
PASS, MAX_ROUNDS = 9, 5
def score(round_no):
return SCORES[round_no]
best_round, best = 0, score(0)
stop_reason = "round limit"
for r in range(1, MAX_ROUNDS + 1):
s = score(r)
print(f"round {r}: score {s}")
# TODO: if s passes, record it as best and stop with reason "criteria pass"
# TODO: if s is not higher than best, stop with reason "no improvement"
# TODO: otherwise record r as the best round so far
best_round, best = r, s # (starter: always keeps the latest)
print(f"stopped: {stop_reason}; returning round {best_round} (score {best})")
if best < PASS:
print(f"flag: below the pass mark of {PASS}, say what still fails")
Show a solution
# Stop a revise loop at the right time, and keep the best draft, not the last.
SCORES = [5, 7, 8, 8, 7, 6] # simulated rubric score of draft v0, v1, v2 ... after each revision
PASS, MAX_ROUNDS = 9, 5
def score(round_no):
return SCORES[round_no]
best_round, best = 0, score(0)
stop_reason = "round limit"
for r in range(1, MAX_ROUNDS + 1):
s = score(r)
print(f"round {r}: score {s}")
if s >= PASS:
best_round, best, stop_reason = r, s, "criteria pass"
break
if s <= best:
stop_reason = f"no improvement at round {r}"
break
best_round, best = r, s
print(f"stopped: {stop_reason}; returning round {best_round} (score {best})")
if best < PASS:
print(f"flag: below the pass mark of {PASS}, say what still fails")
Finished the chapter? Take the chapter check.