Skip to content

Conversation

@dmytrostruk
Copy link
Member

@dmytrostruk dmytrostruk commented Jan 30, 2026

Motivation and Context

Resolves: #3502

Added filtering of internal kwargs for Anthropic client to avoid passing them when making API calls.

Contribution Checklist

  • The code builds clean without any errors or warnings
  • The PR follows the Contribution Guidelines
  • All unit tests pass, and I have added new tests where possible
  • Is this a breaking change? If yes, add "[BREAKING]" prefix to the title of the PR.

@dmytrostruk dmytrostruk self-assigned this Jan 30, 2026
Copilot AI review requested due to automatic review settings January 30, 2026 22:10
Copy link
Contributor

Copilot AI left a 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() and get_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

@dmytrostruk dmytrostruk changed the title Python: Added internal kwargs filtering for chat clients Python: Added internal kwargs filtering for Anthropic client Jan 30, 2026
@markwallace-microsoft
Copy link
Member

markwallace-microsoft commented Jan 30, 2026

Python Test Coverage

Python Test Coverage Report •
FileStmtsMissCoverMissing
packages/anthropic/agent_framework_anthropic
   _chat_client.py36315058%367, 390, 392, 407, 429–432, 441, 443, 480–484, 486, 488–489, 491, 496–497, 499, 532–533, 542, 544–545, 550, 567–568, 610, 625, 629–630, 646, 655, 657, 661–662, 705–707, 709, 722–723, 730–732, 736–738, 742–745, 756, 758, 780, 790, 812–818, 825–826, 834–835, 843–846, 853–854, 860–861, 867–868, 874, 882–884, 888, 895–896, 902–903, 909–910, 916, 924–927, 934–935, 954, 961–962, 981, 1003, 1005, 1014–1015, 1021, 1043–1044, 1050–1051, 1060–1070, 1077–1083, 1090–1096, 1103–1112, 1119–1122
TOTAL16250202487% 

Python Unit Test Overview

Tests Skipped Failures Errors Time
3721 221 💤 0 ❌ 0 🔥 1m 6s ⏱️

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

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Python: [Bug]: AsyncMessages.create() got an unexpected keyword argument '_function_middleware_pipeline'.

3 participants