feat(sdk): set-once integration attribution via ConnectionConfig.setIntegration#1524
feat(sdk): set-once integration attribution via ConnectionConfig.setIntegration#1524mishushakov wants to merge 5 commits into
Conversation
…ntegration Replace the per-call `integration` connection option with a process-wide, set-once setter: `ConnectionConfig.setIntegration()` (JS) and `ConnectionConfig.set_integration()` (Python). Integrations wrapping the SDK tag themselves once at startup and every request carries the identifier in the User-Agent header — no more threading the option through individual SDK calls, and the knob is kept out of the public, documented API surface. The `integration` option is removed from `ConnectionConfigOpts` (now a deprecated alias of `ConnectionOpts`) and from the Python constructor. The CLI uses the new setter to tag all its traffic as `e2b-cli/<version>`. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
|
Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits. |
🦋 Changeset detectedLatest commit: 8e34321 The changes in this PR will be included in the next version bump. This PR includes changesets to release 2 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
PR SummaryMedium Risk Overview The changeset says an explicit Callers that still pass Reviewed by Cursor Bugbot for commit 8e34321. Bugbot is set up for automated code reviews on this repo. Configure here. |
Package ArtifactsBuilt from 37ddf3b. Download artifacts from this workflow run. JS SDK ( npm install ./e2b-2.31.1-streamline-sdk-attribution.0.tgzCLI ( npm install ./e2b-cli-2.13.1-streamline-sdk-attribution.0.tgzPython SDK ( pip install ./e2b-2.30.0+streamline.sdk.attribution-py3-none-any.whl |
… rpc headers test Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Cover the two behaviors the setter contract implies but nothing asserted: custom User-Agent headers are preserved (Python) or overridden by an integration, and setIntegration does not retro-tag configs constructed before it was called (JS). Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
…ration After ConnectionConfig.set_integration(None), configs built while an integration was set kept the stale tagged User-Agent through get_api_params rebuilds: the header was only recomputed when the classvar was non-None, and __init__ preserves an existing User-Agent. Track whether the User-Agent was SDK-built and recompute it from the current integration on every get_api_params call, while still preserving user-supplied User-Agents (construction-time and per-call). Reported by Cursor BugBot on #1524. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
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.
Reviewed by Cursor Bugbot for commit c6697b1. Configure here.
Unify the two precedence rules ConnectionConfig grew (construction-time custom User-Agent lost to the integration, per-call won over it) into a single one — an explicitly provided User-Agent always wins, otherwise the SDK-built one tagged with the current integration — and extract it into _apply_user_agent, shared by __init__ and get_api_params. _build_user_agent and the JS buildUserAgent now read the integration themselves instead of taking it as a parameter. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

Replaces the per-call
integrationconnection option with a set-once, process-wide setter —ConnectionConfig.setIntegration()in JS andConnectionConfig.set_integration()in Python — so integrations wrapping the SDK tag themselves once at startup and every request carries the identifier in theUser-Agentheader, with no threading through individual SDK calls. The setter is internal and hidden from generated docs; theintegrationoption is removed fromConnectionConfigOpts(kept as a deprecated alias ofConnectionOpts) and from the Python constructor, and the round-trip machinery from #1459 is no longer needed since rebuilt configs read the process-wide value. User-Agent handling now follows a single rule via one shared helper: an explicitly providedUser-Agentalways wins (Python), otherwise the SDK sends its own tagged with the current integration — including recomputing after the integration is cleared. Tests cover attribution, clearing, config rebuilds, and custom User-Agent precedence in both SDKs, with changesets fore2band@e2b/python-sdk(minor). CLI attribution using this setter will follow in a separate PR.Usage (internal integrations only):
🤖 Generated with Claude Code