microsoft / microsoft/agent-framework

Python: duplicate User-Agent headers when caller passes lowercase user-agent

Open Beginner friendly
#8,520 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

python triage
Dominant language
Python
Stars
13.6k
Forks
2.3k
Avg merge
2d 45m
Merged PRs (30d)
358

Description

### Motivation & Context

callers that pass a lowercase `user-agent` in default_headers (reachable through OpenAI client options) end up sending two User-Agent lines, because the prepend logic checks `"User-Agent" in headers` with exact casing and then adds its own.

### Reproduction

```python
prepend_agent_framework_to_user_agent({"user-agent": "my-app/1.0"})
# -> both "User-Agent: agent-framework/..." and the original lowercase one survive
# httpx sends duplicate header lines
```

### Expected behavior

header detection is case-insensitive (HTTP headers are case-insensitive); the framework value prepends to the caller's UA instead of duplicating it.

env: python main

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at the prepend_agent_framework_to_user_agent function shown in the reproduction and trace how default_headers are checked before the framework value is added. Verify the lowercase user-agent case and confirm that the completed behavior preserves one header with the framework value prepended to the caller's value.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
api
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Active
Clarity
Clearly specified
Newbie friendliness
78/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.