-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Python: Added internal kwargs filtering for Anthropic client #3544
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
base: main
Are you sure you want to change the base?
Conversation
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.
Pull request overview
This PR adds internal kwargs filtering to Python chat clients to prevent framework-internal parameters from being passed to chat client implementations. This fixes issue #3502 where _function_middleware_pipeline and other internal kwargs were incorrectly being passed to the Anthropic client, causing errors.
Changes:
- Added
_filter_internal_kwargs()utility function to filter out internal framework kwargs (underscore-prefixed,thread,middleware) - Applied filtering in
BaseChatClient.get_response()andget_streaming_response()before calling_inner_get_response()and_inner_get_streaming_response() - Added comprehensive unit tests for the filtering function and integration tests verifying the filtering works in both response methods
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| python/packages/core/agent_framework/_clients.py | Added _filter_internal_kwargs() function and applied it in get_response() and get_streaming_response() methods to filter kwargs before passing to implementation methods |
| python/packages/core/tests/core/test_clients.py | Added comprehensive tests for _filter_internal_kwargs() function and integration tests verifying filtering in both get_response() and get_streaming_response() methods |
Python Test Coverage Report •
Python Unit Test Overview
|
||||||||||||||||||||||||||||||
Motivation and Context
Resolves: #3502
Added filtering of internal kwargs for Anthropic client to avoid passing them when making API calls.
Contribution Checklist