Send Python SDK user agent on control-plane requests#191
Conversation
🧪 Testing GuideWhat this PR addressesThe Python SDK's control-plane HTTP client (used for sandbox creation, etc.) was not sending the SDK-specific Steps to reproduce the original issue
What to verify (expected behavior)
Note Posted by PR Testing Guide · Tag @mendral-app with feedback. |
Interaction FlowsequenceDiagram
participant App as Application
participant AL as autoload()
participant Settings as settings
participant Client as client (httpx)
participant CP as Control Plane API
App->>AL: autoload()
AL->>Settings: read base_url, auth
AL->>Settings: read api_version
AL->>Settings: read headers["User-Agent"]
AL->>Client: with_headers({"Blaxel-Version": ..., "User-Agent": ...})
Client->>CP: HTTP request
Note right of CP: Headers now include:<br/>Blaxel-Version: 2026-04-28<br/>User-Agent: blaxel/sdk/python/x.y.z
CP-->>CP: PostHog observability<br/>classifies SDK traffic
Summary: The Note Posted by PR Sequence Diagram · Tag @mendral-app with feedback. |
There was a problem hiding this comment.
LGTM
Change is minimal and correct. settings.headers["User-Agent"] is evaluated once at autoload time and stored as a static header—no repeated property evaluation or auth-token leakage risk. The riskiest aspect (accidentally sending auth headers via settings.headers) is avoided because only the User-Agent key is extracted explicitly.
Tag @mendral-app with feedback or questions. View session
|
✅ Linked to Linear issue ENG-3781 — status: In Review Note Posted by Linear Issue Enforcer · Tag @mendral-app with feedback. |
|
This is complementary to https://github.com/blaxel-ai/controlplane/pull/4816 which sends tracks SDK information, among other things, upon sandbox creation. |
Summary
Why
Sandbox creation through the Python SDK was reaching PostHog as
request_origin=apiwithrequest_user_agent=python-httpx/..., so backend observability could not extractsdk-versionorsdk-language=python.Tests
pytest tests/core/test_environment.py tests/core/test_settings_api_version.py -qruff format --check src/blaxel/core/common/autoload.py tests/core/test_environment.pyruff check src/blaxel/core/common/autoload.py tests/core/test_environment.pyNote
Adds the Python SDK User-Agent header to the generated control-plane client during autoload, alongside the existing Blaxel-Version header. Adds a test verifying both headers are set.
Written by Mendral for commit 9379bb6.