Skip to content

fix(bedrock): retry transient 400 errors#1289

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

fix(bedrock): retry transient 400 errors#1289
javierdejesusda wants to merge 1 commit intoanthropics: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
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