The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(cron): will_retry answers False on a finite repeat's final run
kshitijk4poor5693204f1099
diff --git a/cron/unreachable_retry.py b/cron/unreachable_retry.pyindex 20102853da4..8a29c93bbe2 100644--- a/cron/unreachable_retry.py+++ b/cron/unreachable_retry.py@@ -69,10 +69,15 @@ def _is_recurring(job: Dict[str, Any]) -> bool:def will_retry(job: Dict[str, Any]) -> bool:"""True iff ``plan_retry`` will park a re-run for this flagged failure, so the scheduler- may hold the interim notice: recurring, unpaused, ladder not exhausted, enabled, and the- rung strictly before the natural occurrence. Called before ``mark_job_run``."""+ may hold the interim notice: recurring, unpaused, not on its final finite repeat, ladder+ not exhausted, enabled, and the rung strictly before the natural occurrence. Called+ before ``mark_job_run``."""if not _is_recurring(job) or job.get("state") == "paused":return False+ repeat = job.get("repeat") or {}+ times = repeat.get("times")+ if times and times > 0 and int(repeat.get("completed") or 0) + 1 >= times:+ return False # _advance_after_run completes the job; plan_retry never runsstate = job.get(STATE_KEY) or {}attempt = int(state.get("attempt") or 0)if attempt >= len(RETRY_DELAYS_SECONDS):diff --git a/tests/cron/test_unreachable_retry.py b/tests/cron/test_unreachable_retry.pyindex caffb14a832..ee3a29d03b7 100644--- a/tests/cron/test_unreachable_retry.py+++ b/tests/cron/test_unreachable_retry.py@@ -109,6 +109,9 @@ def test_will_retry_mirrors_plan_retry_yield(tmp_cron_home):assert jm[ur.STATE_KEY]["attempt"] == 1assert ur.will_retry(jm) is False, "10m cadence beats the 15m rung: yielded, notice goes out"+ last = create_job("final run", "every 24h", repeat=1)+ assert ur.will_retry(get_job(last["id"])) is False, "final finite repeat completes the job"+def test_reaching_the_model_resets_ladder_and_oneshots_never_retry(tmp_cron_home):"""Any run that reached the model clears retry state; one-shots (pre-claimed