fix: track SDK language in v4 metadata - #2467
Merged
Merged
Conversation
🦋 Changeset detectedLatest commit: f9ff170 The changes in this PR will be included in the next version bump. This PR includes changesets to release 3 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 |
Contributor
There was a problem hiding this comment.
No issues found across 5 files
Confidence score: 5/5
- Automated review surfaced no issues in the provided summaries.
- No files require special attention.
Architecture diagram
sequenceDiagram
participant TSClient as TypeScript SDK Client
participant TSBrowserbase as Browserbase Session Client
participant BrowserbaseAPI as Browserbase API
participant PythonClient as Python SDK Client
participant PythonRPC as RPC Client
participant StagehandExt as Stagehand Extension
Note over TSClient,StagehandExt: TypeScript SDK: Session Creation with Metadata
TSClient->>TSBrowserbase: createSession({ userMetadata, ...params })
TSBrowserbase->>TSBrowserbase: Merge userMetadata with authoritative STAGEHAND_SESSION_METADATA
Note over TSBrowserbase: stagehand: "true", stagehand_sdk_language: "typescript"
alt Caller provides spoofed stagehand keys
Note over TSBrowserbase: Caller keys are overridden by authoritative metadata
end
TSBrowserbase->>BrowserbaseAPI: createSession({ userMetadata, extensionId, ...params })
BrowserbaseAPI-->>TSBrowserbase: Session with cdpUrl, sessionId
TSBrowserbase-->>TSClient: Session connection details
Note over PythonClient,StagehandExt: Python SDK: Runtime Configuration with Client Info
PythonClient->>PythonRPC: connect_rpc_client(cdp, ...)
PythonRPC->>PythonRPC: Construct _STAGEHAND_SDK_CLIENT_INFO
Note over PythonRPC: name: "stagehand-sdk-python", version: from importlib.metadata
PythonRPC->>StagehandExt: runtime.configure({ client_info, cdp_url, log_level, telemetry })
Note over PythonRPC,StagehandExt: client_info sent as ImplementationInfo payload
StagehandExt-->>PythonRPC: Configuration acknowledged
PythonRPC-->>PythonClient: Connected RPC client
Note over TSClient,StagehandExt: Future: Go SDK would follow same pattern for session metadata
akeimach
approved these changes
Jul 28, 2026
shrey150
added a commit
that referenced
this pull request
Jul 28, 2026
## Summary - tag Browserbase sessions created by the Go SDK with authoritative `stagehand` and `stagehand_sdk_language` user metadata, mirroring the TypeScript SDK - preserve caller-provided session metadata while preventing the attribution fields from being spoofed - add a unit test that captures the outgoing session-create request and asserts spoofed attribution keys are overridden, plus update the existing typed-request round-trip test ## Why Stagehand v3 identifies its SDK language with the `x-language` request header. V4 no longer routes SDK work through the hosted Stagehand API, so Browserbase session metadata is the durable, queryable equivalent for cloud sessions. #2467 added this for the TypeScript and Python SDKs. The Go SDK has since landed on `v4-spike`, so this PR completes the follow-up for Go. ## E2E Test Matrix | Command / flow | Observed output | Confidence / sufficiency | | --- | --- | --- | | Build the current server extension, then run the Go generator check and embedded-extension check | Both freshness checks passed after rebasing onto the current `v4-spike`. | Confirms the PR no longer inherits the generated-model or embedded-extension drift that previously failed CI. | | Go CI path: gofmt, vet, example compilation, package tests with local Chrome, generator tests, and build | All commands passed; the Stagehand package and extension packages passed their test suites. | Covers the complete Go CI path against the rebased branch. | | `go test -race -run 'TestStagehandSessionMetadata|TestBrowserbaseSessionClientCreateUsesTypedEndpoint' .` | Passed under the race detector. | Directly exercises authoritative attribution, caller-map immutability, and the typed Browserbase request path. | | `BROWSERBASE_SMOKE=1 go test -run TestStagehandBrowserbaseIntegration` → create a real Browserbase session through the Go SDK → retrieve it through the Browserbase API | Retrieved `{"stagehand":"true","stagehand_sdk_language":"go","suite":"stagehand-v4-go-public-smoke"}`; the session was released. | Proves the exact Go attribution behavior is durable and queryable on a live Browserbase session. | --------- Co-authored-by: Claude Sonnet 5 <noreply@anthropic.com>
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
stagehandandstagehand_sdk_languageuser metadataruntime.configure.clientInfometadata fieldWhy
Stagehand v3 identifies its SDK language with the
x-languagerequest header. V4 no longer routes SDK work through the hosted Stagehand API, so Browserbase session metadata is the durable, queryable equivalent for cloud sessions. The existing cross-languageclientInfohandshake remains the right metadata path for runtime connections.v4-spikecurrently creates Browserbase sessions from the TypeScript SDK. Python session creation is not implemented on this branch yet, while the in-flight Go SDK already sends its language and version throughclientInfo. Future Python and Go Browserbase session creators should stampstagehand_sdk_languagewith their respective language values.E2E Test Matrix
stagehand: "true",stagehand_sdk_language: "typescript", and preserved the customsuitefieldvitest run --root . packages/sdk-ts/testsuv run --locked pytestruntime.configure.client_infopayloaduv run --isolated --no-project --with dist/*.whl python scripts/smoke.pystagehand.initandstagehand.closeagainst the built extensionLinear
STG-2714
Summary by cubic
Track SDK language in v4 metadata to meet Linear STG-2714. TypeScript sessions now set authoritative Browserbase user metadata, and Python sends SDK name and version via client_info during runtime configuration.
stagehand: "true"andstagehand_sdk_language: "typescript", merging otheruserMetadataand preventing spoofing using centralized SDK identity.client_infowithname: "stagehand-sdk-python"and installed packageversioninruntime.configure.Written for commit f9ff170. Summary will update on new commits.