Repository navigation
feat: add a user_agent_suffix option - #1145
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #1145 +/- ##
==========================================
+ Coverage 95.43% 95.47% +0.03%
==========================================
Files 61 61
Lines 5935 5940 +5
==========================================
+ Hits 5664 5671 +7
+ Misses 271 269 -2
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Pijukatel
left a comment
There was a problem hiding this comment.
Just a question, if we are going to use it ourselves
| user_agent_suffix_cases = [ | ||
| pytest.param(None, '', id='no suffix'), | ||
| pytest.param('MyTool/1.0', '; MyTool/1.0', id='string suffix'), | ||
| pytest.param(['SDK/3.0.0', 'Crawlee/1.0.0'], '; SDK/3.0.0; Crawlee/1.0.0', id='list suffix'), |
There was a problem hiding this comment.
Is this just a test, or a hint that we are going to set those suffixes in our tools built on top of the client?
There was a problem hiding this comment.
We surely can.
In JS, SDK and the MCP server use it. The SDK sets SDK/<version> and Crawlee/<version>.
In Python, the LangChain and Haystack integrations do the same, but through client internals. LangChain uses client.http_client._headers and Haystack uses client.http_client.httpx_client. Strands sends its own custom x-apify-integration-platform header.
Adds
user_agent_suffixtoApifyClient,ApifyClientAsyncand the built-in HTTP clients, so tools built on top of the client can identify themselves. It takes a string or a list of strings and appends them to the defaultUser-Agentafter;, the same format as the JS client'suserAgentSuffix. Withwith_custom_http_client, pass it to the HTTP client's constructor.Closes: #1148
✍️ Drafted by Claude Code