Skip to content

fix(bedrock): retry transient 400 errors#1289

Open
javierdejesusda wants to merge 1 commit into
anthropics:mainfrom
javierdejesusda:fix/bedrock-retry-transient-400
Open

fix(bedrock): retry transient 400 errors#1289
javierdejesusda wants to merge 1 commit into
anthropics:mainfrom
javierdejesusda:fix/bedrock-retry-transient-400

Conversation

@javierdejesusda

Copy link
Copy Markdown

What

Bedrock can return transient errors like ThrottlingException with HTTP 400 status codes. The base _should_retry only retries on 408, 409, 429, and 5xx, so these transient 400s aren't retried.

Overrides _should_retry in BaseBedrockClient to check the x-amzn-errortype response header for known transient error types (ThrottlingException, TooManyRequestsException, ModelTimeoutException, ServiceUnavailableException). Same pattern as the existing _make_status_error override in the same class.

Verification

Three tests added:

  • Sync: 400 with ThrottlingException → retried, second request succeeds
  • Async: same behavior
  • 400 with ValidationException → not retried, raises BadRequestError

closes #940

Bedrock can return transient errors like ThrottlingException with HTTP
400 status codes. The base retry logic only retries on 408, 409, 429,
and 5xx, so these transient 400s were not retried.

Override _should_retry in BaseBedrockClient to check the
x-amzn-errortype response header for known transient error types.

closes anthropics#940
@javierdejesusda javierdejesusda force-pushed the fix/bedrock-retry-transient-400 branch from 9dfc776 to 407e0fe Compare June 21, 2026 16:33
@javierdejesusda javierdejesusda requested a review from a team as a code owner June 21, 2026 16:33
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.

AnthropicBedrock retry policy not consistent with Bedrock Response

1 participant