diff --git a/run_agent.py b/run_agent.py index bb1c8b8995..08164a2bff 100644 --- a/run_agent.py +++ b/run_agent.py @@ -10199,7 +10199,12 @@ class AIAgent: api_error, retry_count=retry_count, max_retries=max_retries, ): primary_recovery_attempted = True - retry_count = 0 + # Do NOT reset retry_count to 0 — that causes the + # attempt counter to show (1/3), (2/3), (1/3), (2/3) + # instead of a monotonically increasing sequence. + # Grant one extra attempt beyond max_retries so the + # rebuilt client gets exactly one shot (issue #12956). + max_retries += 1 continue # Try fallback before giving up entirely self._emit_status(f"⚠️ Max retries ({max_retries}) exhausted — trying fallback...")