Skip to content

fix(agent): set retryable=False for auth errors in _classify_by_message - #7033

Closed
JiayuuWang wants to merge 1 commit into
NousResearch:mainfrom
JiayuuWang:contribot/fix-error-classifier-auth-retry
Closed

fix(agent): set retryable=False for auth errors in _classify_by_message#7033
JiayuuWang wants to merge 1 commit into
NousResearch:mainfrom
JiayuuWang:contribot/fix-error-classifier-auth-retry

Conversation

@JiayuuWang

Copy link
Copy Markdown
Contributor

Summary

In agent/error_classifier.py, the _classify_by_message() function (the fallback path when no HTTP status code is available) marks auth errors as retryable=True. This is inconsistent with the _classify_by_status() path which correctly uses retryable=False for 401/403 auth errors.

Fix

Change retryable=Trueretryable=False in the auth pattern branch of _classify_by_message(). Auth errors indicate the credential is invalid; retrying with the same key will always fail. The should_rotate_credential=True already signals the correct recovery action.

Impact

When an API response lacks an HTTP status code but contains an auth-related message, the classifier previously returned retryable=True for auth failures. This caused:

  1. The caller retries with the same invalid credential instead of rotating
  2. Creates an unnecessary retry loop before eventually hitting max retries
  3. Wastes time and potentially burns rate-limit quota with doomed requests

Fixing this aligns the message-based path with the status-code path behavior.

Test plan

  • Run existing error classifier tests: pytest tests/agent/test_error_classifier.py -v
  • Verify auth error classification returns retryable=False

Fixes #7026.

Auth errors (401/403) should not be retried with the same credential,
matching the behavior of _classify_by_status(). The should_rotate_credential
flag already signals the correct recovery action.

Fixes NousResearch#7026.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@teknium1

Copy link
Copy Markdown
Contributor

Closed in favor of #7027 which includes the same fix plus an explanatory inline comment. Your fix was identical and correct — thanks for the contribution, @JiayuuWang!

@teknium1 teknium1 closed this Apr 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bug: message-based auth errors use retryable=True in _classify_by_message() causing retry loops

2 participants