-
Notifications
You must be signed in to change notification settings - Fork 1.4k
feat(gateway): support profile and routing_group
#3361
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
profile and routing_group
Docs Preview
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the final PR Bugbot will review for you during this billing cycle
Your free Bugbot reviews will reset on December 9
Details
You are on the Bugbot Free tier. On this plan, Bugbot will review limited PRs each billing cycle.
To receive Bugbot reviews on all of your PRs, visit the Cursor dashboard to activate Pro and start your 14-day free trial.
| http_client.headers.setdefault('pydantic-ai-gateway-profile', profile) | ||
|
|
||
| if routing_group is not None: | ||
| http_client.headers.setdefault('pydantic-ai-gateway-routing-group', routing_group) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Bug: Cached Client Headers: Stale Values Persist
Using setdefault to add profile and routing_group headers causes incorrect behavior when the cached HTTP client is reused. Since cached_async_http_client returns the same client instance for the same api_type, subsequent calls with different profile or routing_group values won't update the headers because setdefault only sets values for keys that don't exist. This means the second call will incorrectly use headers from the first call instead of the newly specified values.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fair.
Note
Adds optional
routing_groupandprofileparams togateway_providerthat set corresponding Gateway headers; includes tests.pydantic_ai/providers/gateway.py)routing_groupandprofileparameters across overloads and implementation.pydantic-ai-gateway-routing-groupandpydantic-ai-gateway-profilewhen provided.tests/providers/test_gateway.py)routing_groupandprofile.Written by Cursor Bugbot for commit 5a757e2. This will update automatically on new commits. Configure here.