Skip to content

Conversation

@cjermain
Copy link
Contributor

@cjermain cjermain commented Nov 9, 2025

This PR fixes FallbackModel behavior for AWS Bedrock by wrapping ClientError exceptions with ModelHTTPError. This is relevant for AWS Bedrock when their quota system raises ThrottlingException. Currently the ClientError exceptions are not caught, so they bypass the default fallback mechanism which expects ModelHTTPError.

from pydantic_ai import Agent
from pydantic_ai.models import FallbackModel

# Fall back to OpenAI if Bedrock throttles
fallback_model = FallbackModel(
    'bedrock:anthropic.claude-3-5-sonnet-20241022-v2:0',  # may hit rate limit
    'openai:gpt-4o',  # fallback
)

agent = Agent(fallback_model)

Copy link
Collaborator

@DouweM DouweM left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@cjermain Thanks Colin!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants