#34When does the retry loop stop?EasyAgentic AI
When does the retry loop stop?
Background
The Orchestrator stops retrying when any of these holds:
- the Critic passed the answer, or
- there are no gaps left to re-search, or
- the attempt budget is exhausted (
attempt >= max_retries).
Otherwise it re-searches the gaps and tries again.
Problem statement
Implement should_stop(passed, gaps, attempt, max_retries) returning whether to stop.
Input
passed—bool, the Critic's verdict.gaps— list of remaining gap sub-questions.attempt— current attempt index (0-based).max_retries— the retry budget.
Output
Returns True if the loop should stop, else False.
Examples
Example 1 — passed
Input: passed=True, gaps=["x"], attempt=0, max_retries=2
Output: True
Example 2 — keep going
Input: passed=False, gaps=["x"], attempt=0, max_retries=2
Output: False
Example 3 — budget exhausted
Input: passed=False, gaps=["x"], attempt=2, max_retries=2
Output: True
Constraints
- Stop if
passedORnot gapsORattempt >= max_retries.
Notes
- The third condition is graceful degradation: out of retries, return the best-effort answer rather than loop forever.
Python
Loading...
▶ Run executes the 3 visible sample tests below in your browser. Submit runs the full suite — including hidden tests — on the server for an official verdict.
- •Reference example: passed stops the loop
- •Sample: failed with gaps and budget left continues
- •Reference example: budget exhausted stops