Skip to content

fix(evals): use workspace Browse and repair CLI adapter - #2963

Merged
shrey150 merged 7 commits into
mainfrom
fix/evals-workspace-browse-compat
Sep 17, 2026
Merged

shrey150 merged 7 commits into
mainfrom
fix/evals-workspace-browse-compat

Conversation

@shrey150

@shrey150 shrey150 commented Sep 17, 2026

Copy link
Copy Markdown
Collaborator

Release versioning rewrites evals' pinned Browse dependency without updating the lockfile, causing the next frozen install to fail (failed release). Use browse: "workspace:*", update its lockfile importer, and make metadata tests read the workspace CLI version and entrypoint.

The native Browse eval adapter also sends obsolete commands and fails at --json with both published Browse 0.9.5 and the workspace CLI. Update startup, tab/mouse commands, timeout and screenshot flags to the supported grammar. Track tabs by stable target IDs, follow the CLI-selected active tab after closing a page, and share short cryptographically random session names with the external wrapper. Regression tests cover tab identity, active-tab selection, malformed responses, and session-name safety/uniqueness.

This PR targets main and includes the dependency/build changes from #2965 together with the adapter fixes. #2965 is superseded. Changesets policy and public-package versions are unchanged; broader wrapper restrictions and abort/cleanup-timeout work from #2838 remain outside this PR.

E2E Test Matrix

Current head 2ea510e1b has the same code, dependencies, lockfile, and tests as verified commit 09f3feb7c; only the upstream README was updated afterward. Retargeting this PR to main did not change its head commit. Both the dependency-only subset and the combined implementation were tested independently with pnpm 11.10.0.

Command / flow Observed output Confidence / sufficiency
CI=true pnpm install --frozen-lockfile Passed for dependency-only and combined changes Confirms workspace dependency resolution and lockfile consistency
CI=true pnpm exec changeset version, CI=true pnpm exec tsx scripts/release/consolidate-changelogs.ts, then CI=true pnpm install --frozen-lockfile Passed for both; Browse became 0.9.7; eval manifest and lockfile stayed unchanged Exercises the failing release sequence; generated release files were restored afterward
pnpm exec turbo run build --filter=@browserbasehq/stagehand-evals 14/14 build tasks passed for both Builds Browse and eval bundles
pnpm exec vitest run --config packages/evals/vitest.config.ts --maxWorkers=4 Combined: 92 files / 768 tests passed. Dependency-only subset: 90 files / 761 tests passed Full eval unit suites, with the inherited devbox OpenAI key unset
Actual native adapter against local Chromium Startup, navigation, waits, fill/hover/coordinate click, press/typing, PNG/JPEG screenshots, snapshot and scrolling passed Real CLI subprocesses against a synthetic local page
Create/switch/close real browser tabs Closing active middle, inactive and active last tabs preserved the CLI-selected page and subsequent titles Verifies tab identity and active-page synchronization
Actual generated Claude/Codex Browse wrapper Opened and submitted a synthetic form and read the expected title; passed for both subsets Shared external wrapper works with the workspace CLI
Native/wrapper cleanup No remaining PID/socket files after shutdown settled Smoke resources cleaned up
GitHub CI after the README reconciliation Dependency-only parent: 46 passed, 9 skipped. Combined head while stacked: 9 passed, 15 skipped; none failed or pending The earlier combined source tree also passed the full 47-check CI run; check selection depends on the PR diff

The native adapter's obsolete-command failure predates the dependency switch; the build fix itself does not require the adapter changes. Browser smokes used local Chromium with an isolated daemon directory and a test-only --no-sandbox launcher for the container. Remote adapter sessions, paid model evals, and package publishing were not performed locally.

@changeset-bot

changeset-bot Bot commented Sep 17, 2026

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: 2ea510e

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

All reported issues were addressed across 8 files

Architecture diagram
sequenceDiagram
    participant Eval as Eval Tool Adapter
    participant Run as BrowseCliRuntime
    participant CLI as Browse CLI (workspace)
    participant Pkg as Package Manager
    participant Repo as Repo Root

    Note over Eval,Repo: Workspace Dependency Resolution

    Eval->>Eval: Read workspace dependency manifest
    Eval->>Pkg: Resolve browse dependency
    alt Resolved as workspace version
        Pkg-->>Eval: Local package (workspace:*)
        Eval->>Repo: Locate CLI entrypoint
        Repo-->>Eval: packages/cli/bin/run.js
    else Resolved as published version
        Pkg-->>Eval: Published package
        Eval->>CLI: Use installed binary
    end

    Note over Eval,CLI: Native Adapter Session Startup

    Eval->>Run: Create session with generated name
    Run->>Run: Generate session identifier
    Note over Run: Include PID, timestamp, random suffix
    Run->>CLI: open about:blank --session <id>
    alt Local environment
        Run->>CLI: Add --local flag
    else Remote environment
        Run->>CLI: Add --remote flag
    end
    CLI-->>Run: Connection established
    Run-->>Eval: Session ready

    Note over Eval,CLI: Tab Management Flow

    Eval->>CLI: tab list --session <id>
    CLI-->>Eval: Tabs with targetId mappings
    Eval->>Eval: Map tabs to page handles
    Eval->>CLI: tab new <url> --session <id>
    CLI-->>Eval: New tab targetId
    Eval->>CLI: tab switch <targetId> --session <id>
    Eval->>CLI: tab close <targetId> --session <id>

    Note over Eval,CLI: Page Operations

    Eval->>CLI: navigate --wait <state> --timeout <ms> --session <id>
    Eval->>CLI: screenshot --base64 --full-page --type <fmt> --session <id>
    CLI-->>Eval: Base64-encoded image
    Eval->>CLI: wait selector <selector> --timeout <ms> --state <state> --session <id>
    Eval->>CLI: mouse click <x> <y> --session <id>
    Eval->>CLI: mouse hover <x> <y> --session <id>
    Eval->>CLI: mouse scroll <x> <y> <dx> <dy> --session <id>
    Eval->>CLI: type <text> --session <id>
    Eval->>CLI: fill <selector> <text> --session <id>
    Eval->>CLI: press <key> --session <id>

    Note over Eval: Command output parsed as JSON

    opt Startup failure
        Run->>CLI: open about:blank --session <id>
        CLI-->>Run: Error
        Run->>Run: Cleanup session resources
        Run-->>Eval: Propagate error
    end

    alt Tab response missing targetId
        CLI-->>Eval: Tab entry without targetId
        Eval->>Eval: Reject as ambiguous
    else Valid tab response
        Eval->>Eval: Address by targetId, preserving identity
    end
Loading

Reply with feedback, questions, or to request a fix.

Re-trigger cubic

Comment thread packages/evals/core/tools/browse_cli.ts Outdated
Comment thread packages/evals/core/tools/browse_cli.ts Outdated
Comment thread packages/evals/browseCliPaths.ts Outdated
Follow the CLI-selected tab after closing, use cryptographic session names, and throw a typed error for missing target IDs. Add tab-selection regressions and format the inherited README to unblock CI.

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

All reported issues were addressed across 4 files (changes from recent commits).

Reply with feedback, questions, or to request a fix.

Re-trigger cubic

Comment thread packages/evals/browseCliPaths.ts
@shrey150 shrey150 changed the title fix(evals): use workspace Browse with compatible CLI commands fix(evals): repair native Browse CLI adapter Sep 17, 2026
@shrey150
shrey150 changed the base branch from main to fix/evals-workspace-build September 17, 2026 18:19
@shrey150
shrey150 added this pull request to stack #2968 September 17, 2026 21:53
@shrey150
shrey150 removed this pull request from stack #2968 September 17, 2026 22:07
@shrey150 shrey150 changed the title fix(evals): repair native Browse CLI adapter fix(evals): use workspace Browse and repair CLI adapter Sep 17, 2026
@shrey150
shrey150 changed the base branch from fix/evals-workspace-build to main September 17, 2026 22:07
@shrey150

Copy link
Copy Markdown
Collaborator Author

@cubic-dev-ai review this PR.

Please review the full combined diff against main, including the workspace Browse dependency, lockfile and metadata-test changes consolidated from #2965, plus the native CLI adapter and session/tab regression tests. The PR is now standalone; its head remains 2ea510e1b5e620b1112391e28db6144befa0dfe9. The latest automatic check skipped AI review because the head is a merge commit, so this is a request for a fresh review of the complete current PR.

@cubic-dev-ai

cubic-dev-ai Bot commented Sep 17, 2026

Copy link
Copy Markdown
Contributor

@cubic-dev-ai review this PR.

Please review the full combined diff against main, including the workspace Browse dependency, lockfile and metadata-test changes consolidated from #2965, plus the native CLI adapter and session/tab regression tests. The PR is now standalone; its head remains 2ea510e1b5e620b1112391e28db6144befa0dfe9. The latest automatic check skipped AI review because the head is a merge commit, so this is a request for a fresh review of the complete current PR.

@shrey150 I have started the AI code review. It will take a few minutes to complete.

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

No issues found across 9 files

Confidence score: 5/5

  • Automated review surfaced no issues in the provided summaries.
  • No files require special attention.
Architecture diagram
sequenceDiagram
    participant Eval as Stagehand Evals
    participant Workspace as pnpm Workspace
    participant CLI as Browse CLI (packages/cli)
    participant Adapter as BrowseCliTool Adapter
    participant Session as BrowseCliSession
    participant CLIProc as CLI Subprocess
    participant Tabs as Browser Tabs

    Note over Eval,CLI: Dependency Resolution
    Eval->>Workspace: CHANGED: Declare "browse": "workspace:*"
    Workspace-->>Eval: Resolve to workspace CLI package
    Eval->>CLI: CHANGED: Use workspace CLI (was external 0.9.5)
    CLI-->>Eval: Expose package.json version/entrypoint

    Note over Adapter,CLIProc: Session Startup
    Adapter->>Session: Create session with session name
    Session->>Session: generate session name (pid + random hex)
    Session->>CLIProc: Launch subprocess
    CLIProc->>CLIProc: Start with local/remote browser

    Note over Session,Tabs: Command Flow (Stable Tab IDs)
    Session->>CLIProc: tab list
    CLIProc-->>Session: Return tabs with targetIds
    Session->>Session: Store handles by targetId
    Session->>CLIProc: tab new [url] / tab switch targetId
    CLIProc->>Tabs: Create/switch browser tab
    Tabs-->>CLIProc: Tab ready
    CLIProc-->>Session: Confirm operation

    Note over Session,CLIProc: Page Operations (Updated Grammar)
    Session->>CLIProc: wait selector --timeout --state
    Session->>CLIProc: mouse click/hover/scroll [coords]
    Session->>CLIProc: fill selector text / type text
    Session->>CLIProc: screenshot --base64 --full-page --type --quality
    CLIProc->>Tabs: Execute browser action
    Tabs-->>CLIProc: Action result
    CLIProc-->>Session: Return result

    Note over Session,CLIProc: Tab Close & Selection
    Session->>CLIProc: tab close targetId
    CLIProc->>Tabs: Close tab
    CLIProc-->>Session: Return selectedTargetId (CLI active tab)

    alt CLI returns selected tab
        Session->>Session: Set activePageId = selectedTargetId
        Session->>CLIProc: Refresh tab list
    else No selected tab returned
        Session->>Session: Clear activePageId
        Session->>CLIProc: Refresh tab list (optional)
    end

    Note over Session,CLIProc: Error Handling
    Session->>CLIProc: Send malformed command
    CLIProc-->>Session: Return error/empty targetId
    Session->>Session: Throw EvalsError (missing targetId)

    Note over Adapter,CLIProc: Session Cleanup
    Adapter->>Session: close()
    Session->>CLIProc: Terminate subprocess
    CLIProc-->>Session: Confirm shutdown
    Session-->>Adapter: Session closed

    Note over Eval,CLI: Metadata Reporting
    Eval->>CLI: Read workspace CLI package.json
    CLI-->>Eval: version + entrypoint
    Eval->>Eval: Include in Braintrust rows / TUI metadata
Loading

Re-trigger cubic

@shrey150
shrey150 merged commit 574ecdd into main Sep 17, 2026
25 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants