Skip to content

Reuse browser session setup across locator calls - #3420

Open
arunjmoorthy wants to merge 1 commit into
browserbase:mainfrom
arunjmoorthy:arun/reuse-locator-session-setup
Open

arunjmoorthy wants to merge 1 commit into
browserbase:mainfrom
arunjmoorthy:arun/reuse-locator-session-setup

Conversation

@arunjmoorthy

@arunjmoorthy arunjmoorthy commented Nov 9, 2026 •

Copy link
Copy Markdown

why

Repeated locator calls send Runtime.enable and DOM.enable to the same browser session even after setup succeeds. This addresses the repeated setup portion of #3239. #3326 covers logging overhead, and element-handle reuse is a separate part of the issue.

what changed

Internal locator operations share each session’s pending or successful setup. A failed request can be retried. Explicit enable and disable commands still reach Chrome and invalidate saved setup for their domain. Session teardown clears the saved state.

test plan

  • The focused transport tests count commands sent to the browser. Before the fix, 12 of 14 cases failed. All 14 pass with the fix, including retry, reset, concurrency, and independent caller timeouts.
  • Ran 23 local Chrome tests covering repeated fills and reads, navigation, iframes, and page closure.
  • The full just check stops on main’s existing agent-discoverability-metadata.md release entry. The release validator accepts this change’s entry. In the broader Python run, 1,093 tests passed, nine were skipped, and four were excluded after a transport test hung during cleanup.

Summary by cubic

Internal locator calls now reuse pending or successful DOM.enable and Runtime.enable setup within each browser session, avoiding repeated setup commands.

  • Failed setup can be retried; explicit enable and disable commands still reach Chrome and refresh the saved state.
  • Session teardown clears saved setup, and separate sessions keep independent state.
  • Tests cover retries, concurrency, timeouts, navigation, and multiple pages.

Written for commit 554f3dc. Summary will update on new commits.

View guided diff

@changeset-bot

changeset-bot Bot commented Nov 9, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 554f3dc

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 23 packages
Name Type
@browserbasehq/stagehand-extension Patch
@browserbasehq/stagehand Patch
@browserbasehq/stagehand-python Patch
browse Patch
@browserbasehq/stagehand-examples Patch
@browserbasehq/stagehand-integrations-claude-cua-sdk Patch
@browserbasehq/stagehand-integrations Patch
@browserbasehq/eve Patch
@browserbasehq/stagehand-integrations-gemini-cua-sdk Patch
@browserbasehq/stagehand-integrations-example-pi-facade Patch
@browserbasehq/stagehand-integrations-claude-agent-sdk Patch
@browserbasehq/stagehand-integrations-example-claude-code-facade Patch
@browserbasehq/stagehand-integrations-codex-sdk Patch
@browserbasehq/stagehand-integrations-example-codex-facade Patch
@browserbasehq/stagehand-integrations-cursor-sdk Patch
@browserbasehq/stagehand-integrations-example-cursor-facade Patch
@browserbasehq/stagehand-integrations-deepagents-sdk Patch
@browserbasehq/stagehand-integrations-eve-sdk Patch
@browserbasehq/stagehand-integrations-fx-sdk Patch
@browserbasehq/stagehand-integrations-mastra-sdk Patch
@browserbasehq/stagehand-integrations-example-mastra-facade Patch
@browserbasehq/stagehand-integrations-pi-sdk Patch
@browserbasehq/stagehand-integrations-example-vercel-ai-facade Patch

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

@github-actions

github-actions Bot commented Nov 9, 2026

Copy link
Copy Markdown
Contributor

This PR is from an external contributor and must be approved by a stagehand team member with write access before CI can run.
Approving the latest commit mirrors it into an internal PR owned by the approver.
If new commits are pushed later, the internal PR stays open but is marked stale until someone approves the latest external commit and refreshes it.

@github-actions github-actions Bot added external-contributor Tracks PRs mirrored from external contributor forks. external-contributor:awaiting-approval Waiting for a stagehand team member to approve the latest external commit. labels Nov 9, 2026
@arunjmoorthy
arunjmoorthy marked this pull request as ready for review November 9, 2026 04:15
"@browserbasehq/stagehand-python": patch
---

Reuse successful DOM and Runtime setup across internal locator operations within a browser session. Failed setup remains retryable, explicit CDP enable and disable commands are still sent, and session teardown clears saved setup.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we trim this to one user-facing line? Release notes read best when they describe the effect rather than the mechanics:

Suggested change
Reuse successful DOM and Runtime setup across internal locator operations within a browser session. Failed setup remains retryable, explicit CDP enable and disable commands are still sent, and session teardown clears saved setup.
Speed up repeated locator actions by skipping redundant DOM and Runtime setup calls.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

external-contributor:awaiting-approval Waiting for a stagehand team member to approve the latest external commit. external-contributor Tracks PRs mirrored from external contributor forks.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants