microsoft / microsoft/agent-framework
Python: duplicate User-Agent headers when caller passes lowercase user-agent
Nobody has claimed this yet.
- 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
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- 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