Python: case-insensitive User-Agent detection prevents duplicate headers by ManoharPaturi · Pull Request #8521 · microsoft/agent-framework · GitHub
Skip to content

Python: case-insensitive User-Agent detection prevents duplicate headers - #8521

Merged
Eduard van Valkenburg (eavanvalkenburg) merged 1 commit into
microsoft:mainfrom
ManoharPaturi:fix/user-agent-header-casing
Sep 21, 2026
Merged

Eduard van Valkenburg (eavanvalkenburg) merged 1 commit into
microsoft:mainfrom
ManoharPaturi:fix/user-agent-header-casing

Conversation

@ManoharPaturi

Copy link
Copy Markdown
Contributor

Motivation & Context

Fixes #8520. exact-case "User-Agent" detection let a lowercase user-agent through, producing duplicate UA header lines.

Description & Review Guide

  • What are the major changes? the existing-header lookup is now case-insensitive and the framework token prepends to whichever variant the caller used.
  • What is the impact of these changes? one User-Agent line regardless of caller casing.
  • What do you want reviewers to focus on? the lookup change in prepend_agent_framework_to_user_agent.

Related Issue

Fixes #8520

Contribution Checklist

  • The code builds clean without any errors or warnings
  • All unit tests pass, and I have added new tests where possible
  • The PR follows the Contribution Guidelines
  • This PR is linked to an issue and there is no other open PR for this issue
  • This is not a breaking change.

prepend_agent_framework_to_user_agent looked up the exact key
"User-Agent" when deciding whether an incoming headers dict already
carries a user agent. HTTP header names are case-insensitive, so a caller
passing default_headers={"user-agent": "my-app/1.0"} (for example to
OpenAI clients or the A2A agent) ended up with two User-Agent entries:
their original one plus a new agent-framework one. httpx then sends both
header lines, and which value a server honors is undefined.

Find the existing entry case-insensitively and prepend to it in place, so
exactly one User-Agent header survives.

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 reached their quota limit.

Merged via the queue into microsoft:main with commit 09daae8 Sep 21, 2026
49 checks passed
ZedingZhang (ZedingZhang) pushed a commit to ZedingZhang/agent-framework that referenced this pull request Sep 29, 2026
prepend_agent_framework_to_user_agent looked up the exact key
"User-Agent" when deciding whether an incoming headers dict already
carries a user agent. HTTP header names are case-insensitive, so a caller
passing default_headers={"user-agent": "my-app/1.0"} (for example to
OpenAI clients or the A2A agent) ended up with two User-Agent entries:
their original one plus a new agent-framework one. httpx then sends both
header lines, and which value a server honors is undefined.

Find the existing entry case-insensitively and prepend to it in place, so
exactly one User-Agent header survives.

Co-authored-by: Manohar Paturi <186662190+ManoharPaturi@users.noreply.github.com>

This branch was previously deployed

1 inactive deployment
github-app-auth — 6836adb8 Deployed Sep 18, 2026 by ManoharPaturi via limit_open_prs #1407
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: duplicate User-Agent headers when caller passes lowercase user-agent

3 participants