diff --git a/run_agent.py b/run_agent.py index 295106e3d5..7543d1d0c0 100644 --- a/run_agent.py +++ b/run_agent.py @@ -3469,7 +3469,7 @@ class AIAgent: api_start_time = time.time() retry_count = 0 - max_retries = 6 # Increased to allow longer backoff periods + max_retries = 3 compression_attempts = 0 max_compression_attempts = 3 codex_auth_retry_attempted = False @@ -3939,8 +3939,11 @@ class AIAgent: # These indicate a problem with the request itself (bad model ID, # invalid API key, forbidden, etc.) and will never succeed on retry. # Note: 413 and context-length errors are excluded — handled above. + # Also catch local validation errors (ValueError, TypeError) — these + # are programming bugs, not transient failures. + is_local_validation_error = isinstance(api_error, (ValueError, TypeError)) is_client_status_error = isinstance(status_code, int) and 400 <= status_code < 500 and status_code != 413 - is_client_error = (is_client_status_error or any(phrase in error_msg for phrase in [ + is_client_error = (is_local_validation_error or is_client_status_error or any(phrase in error_msg for phrase in [ 'error code: 401', 'error code: 403', 'error code: 404', 'error code: 422', 'is not a valid model', 'invalid model', 'model not found',