Migrate SDK consumers to browser context - #2584
Open
miguelg719 wants to merge 1 commit into
Open
Conversation
|
Contributor
There was a problem hiding this comment.
cubic analysis
All reported issues were addressed across 49 files
Linked issue analysis
Linked issue: STG-2763: Change stagehand.context to browser.context
| Status | Acceptance criteria | Notes |
|---|---|---|
| ✅ | Replace references to stagehand.context in v4 docs with stagehand.browser.context / browser.context | The diffs show many documentation files updated to reference stagehand.browser.context or browser.context instead of stagehand.context. |
| ✅ | Update TypeScript SDK examples and tests to use browser.context when a browser instance is in scope (or stagehand.browser.context otherwise) | TypeScript examples and numerous tests were updated to use browser.context or stagehand.browser.context consistently. |
| ✅ | Update Python SDK examples and tests to use stagehand.browser.context | Python examples, smoke scripts, README, and tests were modified to reference stagehand.browser.context/new_page/active_page instead of stagehand.context. |
| ✅ | Update Go SDK examples, tests, and client usages to obtain the BrowserContext via client.Browser().Context() or browser.Context() as appropriate | Go client tests, examples, and live tests were updated to call client.Browser().Context() or browser.Context() depending on the example scope, indicating the intended migration of consumers. |
Architecture diagram
sequenceDiagram
participant App as Consumer Application
participant Stagehand as Stagehand Instance
participant Browser as Browser Instance
participant Ctx as BrowserContext
participant Page as Page Object
participant Clipboard as BrowserClipboard
Note over App,Clipboard: Browser-Owned Context Access Pattern (NEW)
App->>Stagehand: create({ browser })
Stagehand->>Browser: associate with Stagehand
App->>Browser: get context
Browser-->>App: browser.context
alt Active Page Access
App->>App: stagehand.browser.context.activePage()
App->>Stagehand: .browser.context (proxy)
Stagehand->>Browser: .context
Browser-->>App: BrowserContext
App->>Ctx: activePage()
Ctx-->>App: Page | undefined
end
alt New Page Creation
App->>App: stagehand.browser.context.newPage()
App->>Ctx: newPage({ url })
Ctx->>Browser: create new tab
Browser-->>Ctx: Page object
Ctx-->>App: Page
end
alt Clipboard Operations
App->>Stagehand: .browser.context.clipboard
Stagehand->>Browser: .context.clipboard
Browser-->>App: BrowserClipboard instance
App->>Clipboard: writeText("Hello")
Clipboard->>Ctx: clipboard operation
Ctx-->>App: done
end
alt Context Lifecycle
App->>App: stagehand.browser.context.close()
App->>Ctx: close()
Ctx->>Browser: close context
Browser-->>App: confirmed
end
opt Go SDK Pattern
App->>App: client.Browser().Context()
App->>Stagehand: .Browser()
Stagehand-->>App: Browser instance
App->>Browser: .Context()
Browser-->>App: BrowserContext
end
opt Python SDK Pattern
App->>Stagehand: .browser.context
Stagehand-->>App: browser property
App->>Browser: .context
Browser-->>App: BrowserContext
end
Reply with feedback, questions, or to request a fix.
Re-trigger cubic
miguelg719
force-pushed
the
miguelgonzalez/stg-2763-migrate-browsercontext
branch
from
August 4, 2026 19:27
d348739 to
a575be4
Compare
miguelg719
force-pushed
the
miguelgonzalez/stg-2763-migrate-browsercontext
branch
2 times, most recently
from
August 4, 2026 20:25
84cceac to
126b0f4
Compare
miguelg719
force-pushed
the
miguelgonzalez/stg-2763-migrate-browsercontext
branch
from
August 4, 2026 21:59
126b0f4 to
acbb699
Compare
seanmcguire12
approved these changes
Aug 4, 2026
miguelg719
force-pushed
the
miguelgonzalez/stg-2763-migrate-browsercontext
branch
from
August 4, 2026 23:42
acbb699 to
8f4820c
Compare
miguelg719
force-pushed
the
miguelgonzalez/stg-2763-migrate-browsercontext
branch
from
August 4, 2026 23:45
8f4820c to
f7cf3df
Compare
miguelg719
force-pushed
the
miguelgonzalez/stg-2763-migrate-browsercontext
branch
from
August 4, 2026 23:48
f7cf3df to
c3d09c4
Compare
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.
why
Consumers must move to the browser-owned context before the Stagehand accessors can be removed.
what changed
Migrates TypeScript, Python, and Go examples, tests, smoke coverage, and v4 documentation to browser context access.
No changeset: this targets the unreleased v4 API.
test plan
Summary by cubic
Switch all SDK docs, examples, and tests to use the browser-owned context with browser factories and
Stagehand.create({ browser }). Completes STG-2763 by replacingstagehand.contextwithbrowser.context(orstagehand.browser.contextwhen accessed via Stagehand).stagehand.context.*withbrowser.context.*(orstagehand.browser.context.*as needed). Preferconst [page] = await browser.context.pages()overactivePage(). Examples, READMEs, and quickstarts updated; no.init().browserbase.launch,localBrowser.launch/connect, andStagehand.create({ browser }). Observability reads the session ID frombrowser.browserbaseSessionId. Clipboard/context/page references usebrowser.context. Install guides say to pass env values to the browser factory.LaunchLocalBrowser+Createflow; examples usebrowser.Context().Pages()[0]instead ofActivePage(). Tests (and thin client) useclient.Browser().Context(). Guidance inidiomatic_go.mdupdated.stagehand.browser.context; smoke/integration and object-model/create tests updated to reflect no.initand nostagehand.contextaccess.Written for commit c3d09c4. Summary will update on new commits.