Skip to content

Python: Prevent keyword argument collision when model is passed in client_kwargs - #10258

Merged
Eduard van Valkenburg (eavanvalkenburg) merged 3 commits into
microsoft:mainfrom
Dhruv-Sh-git:fix/issue-10194
Nov 12, 2026
Merged

Eduard van Valkenburg (eavanvalkenburg) merged 3 commits into
microsoft:mainfrom
Dhruv-Sh-git:fix/issue-10194

Conversation

@Dhruv-Sh-git

@Dhruv-Sh-git Dhruv Shaswat (Dhruv-Sh-git) commented Nov 11, 2026 •

Copy link
Copy Markdown
Contributor

Motivation & Context

Passing model or other telemetry-related fields through client_kwargs could cause a TypeError in _get_span_attributes. This happened because ChatTelemetryLayer.get_response passed some arguments explicitly while also unpacking merged_client_kwargs, resulting in duplicate keyword arguments.

Description & Changes

  • Updated the span attribute handling to combine merged_client_kwargs with the resolved operation_name, provider_name, model, and service_url before calling _get_span_attributes.
  • Added parameterized regression tests in test_observability.py to cover both streaming and non-streaming responses.

Closes #10194

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

@agent-framework-automation agent-framework-automation Bot added the python Usage: [Issues, PRs], Target: Python label Nov 11, 2026
@eavanvalkenburg

Copy link
Copy Markdown
Member

/review

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

MAF Automated Review — Iteration 1

Result: No findings
Scope: full PR (1 commit(s)): e2994df2c4ab
Model: gpt-5.6-sol

Overview

This PR copies client_kwargs into a telemetry-only mapping and then overlays the framework-resolved fields before calling _get_span_attributes, eliminating duplicate-keyword failures without mutating caller data. The original client_kwargs mapping is still forwarded unchanged to downstream clients, and the added regression test exercises both streaming and non-streaming responses while verifying the selected model attribute. No Critical, High, or Medium issue remains after reconciling the changed behavior against its callers, extraction logic, and tests.

Reviewed the supplied pull-request change set across correctness, security/reliability, architecture, and failure behavior.
No publishable findings remained after source verification for this scope.

Merged via the queue into microsoft:main with commit 647adc9 Nov 12, 2026
44 checks passed

This branch was successfully deployed

1 active deployment
github-app-auth — f45b8763 Deployed Nov 11, 2026 by Dhruv-Sh-git via add_label #27598
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

python Usage: [Issues, PRs], Target: Python

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Python: [Bug]: Passing model in client_kwargs raises TypeError when instrumentation is on

3 participants