fix(bedrock): retry transient 400 errors#1289
Open
javierdejesusda wants to merge 1 commit intoanthropics:mainfrom
Open
fix(bedrock): retry transient 400 errors#1289javierdejesusda wants to merge 1 commit intoanthropics:mainfrom
javierdejesusda wants to merge 1 commit intoanthropics:mainfrom
Conversation
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Bedrock can return transient errors like
ThrottlingExceptionwith HTTP 400 status codes. The base_should_retryonly retries on 408, 409, 429, and 5xx, so these transient 400s aren't retried.Overrides
_should_retryinBaseBedrockClientto check thex-amzn-errortyperesponse header for known transient error types (ThrottlingException,TooManyRequestsException,ModelTimeoutException,ServiceUnavailableException). Same pattern as the existing_make_status_erroroverride in the same class.Verification
Three tests added:
ThrottlingException→ retried, second request succeedsValidationException→ not retried, raisesBadRequestErrorcloses #940