Reset error_retries on successful loop iteration
Reset the error_retries counter immediately after a successful message-loop iteration inside the Agent class, and remove the redundant reset outside the loop. This consolidates the retry counter logic so it is cleared only when an iteration completes successfully.
frdel committed
Feb 18, 2026 at 17:26 UTC
01cdb7b92d7df02ea39b7dcf45009526c174243a
1 file changed
+2
-2
agent.py
+2
-2
@@ -491,6 +491,8 @@ class Agent:
491
if tools_result: # final response of message loop available
492
return tools_result # break the execution if the task is done
493
494
+ error_retries = 0 # reset retry counter on successful iteration
495
+
496
# exceptions inside message loop:
497
except InterventionException as e:
498
error_retries = 0 # reset retry counter on user intervention
@@ -515,8 +517,6 @@ class Agent:
517
"message_loop_end", loop_data=self.loop_data
518
)
519
518
- error_retries = 0 # reset retry counter on successful iteration
519
-
520
# exceptions outside message loop:
521
except InterventionException as e:
522
error_retries = 0 # reset retry counter on user intervention