feat: add User-Agent header for Anthropic API calls#4500
Open
mikelambert wants to merge 1 commit intocrewAIInc:mainfrom
Open
feat: add User-Agent header for Anthropic API calls#4500mikelambert wants to merge 1 commit intocrewAIInc:mainfrom
mikelambert wants to merge 1 commit intocrewAIInc:mainfrom
Conversation
Passes User-Agent: crewai/{version} to the Anthropic SDK
so Anthropic can identify traffic from CrewAI.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
c6594a9 to
054b01a
Compare
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
Bugbot Autofix is OFF. To automatically fix reported issues with Cloud Agents, enable Autofix in the Cursor dashboard.
| "base_url": self.base_url, | ||
| "timeout": self.timeout, | ||
| "max_retries": self.max_retries, | ||
| "default_headers": {"User-Agent": f"crewai/{__version__}"}, |
There was a problem hiding this comment.
Custom User-Agent replaces Anthropic SDK's built-in User-Agent
Low Severity
Setting User-Agent via default_headers completely replaces the Anthropic SDK's built-in User-Agent header (typically Anthropic/Python x.y.z), because the SDK merges _custom_headers last via dictionary unpacking. The PR goal is to improve debugging and traffic attribution, but this actually removes the SDK version info that Anthropic uses for diagnostics. A different header name (e.g., X-CrewAI-Version) would add identification without losing the SDK's own User-Agent.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.


Summary
User-Agent: crewai/<version>header to Anthropic API client paramsWhy
This enables Anthropic to identify traffic from CrewAI integrations, improving debugging and traffic attribution for both Anthropic and CrewAI users.
Test plan
ruff checkpassesruff formatpasses🤖 Generated with Claude Code
Note
Low Risk
Small, well-tested change limited to HTTP client header construction for Anthropic requests; low likelihood of regressions beyond header merging behavior.
Overview
Adds a default
User-Agent: crewai/<version>header to Anthropic SDK client initialization via_get_client_params().Updates client param merging to deep-merge
default_headersso the newUser-Agentis retained even when callers supply their own headers, and extends unit tests to assert the header is present across custom/override/none cases (plus a new dedicated test).Written by Cursor Bugbot for commit 054b01a. This will update automatically on new commits. Configure here.