evals: restore session URLs on the v4 path and split the harness context - #2617
Merged
Conversation
- initStagehand now creates the Browserbase session first (via the shared core/targets creator) and attaches with browserbase.connect, so the session id is known to the harness: sessionUrl/debugUrl flow into every TaskResult again and the session is released on cleanup and on every init failure path. The dead systemPrompt parameter is dropped (its v3 equivalent is agent-only). - BenchHarnessContext becomes a discriminated union (sdk: v4 | v3): the runner narrows instead of probing optional fields, and the v4Page ?? page fallback disappears. A legacy task reaching the v4 context is now an explicit error instead of an undefined v3. - benchRunner tests: the legacy fixtures move from the deleted combination category to agent, the only non-deterministic category left.
|
Contributor
There was a problem hiding this comment.
All reported issues were addressed across 4 files
Architecture diagram
sequenceDiagram
participant CLI as CLI Runner
participant Bench as benchHarness.ts
participant Init as initStagehand.ts
participant BB as Browserbase SDK
participant Task as Task Definition
participant Result as TaskResult
Note over CLI,Result: NEW: v4 Session URL Flow
CLI->>Bench: stagehandHarness.start(input)
Bench->>Init: initStagehand({environment, modelName, logger})
alt environment === "BROWSERBASE"
Init->>BB: launchRunnerProvidedBrowserbaseChrome()
BB-->>Init: {sessionId, sessionUrl, debugUrl, cleanup}
Init->>Init: Store sessionUrl & debugUrl
Init->>BB: browserbase.connect({apiKey, sessionId})
alt connect fails
BB-->>Init: error
Init->>BB: endSession() (release session)
Init-->>Bench: throw
end
BB-->>Init: browser handle
else environment === "LOCAL"
Init->>Init: localBrowser.launch({headless: false})
Init-->>Init: sessionUrl="" debugUrl=""
end
Init->>Init: stagehand.init({browser, model})
alt init fails
Init->>BB: browser.close()
Init->>BB: endSession()
Init-->>Bench: throw
end
Init-->>Bench: {stagehand, page, sessionUrl, debugUrl, endSession}
Note over Bench,Task: CHANGED: Context is now discriminated union
Bench->>Bench: Build ctx with sdk: "v4" discriminant
Bench->>Bench: Store sessionUrl & debugUrl in ctx
Bench-->>CLI: {ctx, cleanup}
CLI->>Task: executeBenchTask(ctx)
alt sdk === "v4"
Task->>Task: Uses stagehand + page (v4 SDK)
else sdk === "v3"
alt legacy task on v4 context
Task-->>CLI: EvalsError ("Legacy task cannot run on v4")
else
Task->>Task: Uses v3 + agent + page
end
end
Task-->>CLI: TaskResult
Note over CLI,Result: CHANGED: sessionUrl flows to TaskResult
CLI->>Result: withBenchSessionUrls(result, ctx)
Result->>Result: Inject sessionUrl & debugUrl from ctx
Result-->>CLI: Enriched TaskResult
Note over CLI,BB: CHANGED: Cleanup releases session explicitly
CLI->>Bench: cleanup()
Bench->>Init: stagehand.close()
Bench->>BB: browser.close() (disconnects only)
Bench->>BB: endSession() (RELEASE session - best effort)
Note over Bench,BB: browser.close() on connected handle <br/>does not release Browserbase session
Reply with feedback, questions, or to request a fix.
Re-trigger cubic
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
Review follow-up for #2570, implemented. Three fixes and one test cleanup; only functional change is the session-URL restoration.
initStagehandnow creates the Browserbase session first via the sharedlaunchRunnerProvidedBrowserbaseChrome()creator and attaches withbrowserbase.connect({ apiKey, sessionId }), instead ofbrowserbase.launch(which hides the session id behind the opaqueStagehandBrowserhandle, Define TypeScript Stagehand browser contracts #2517).sessionUrl/debugUrlflow into every TaskResult and the Braintrust replay click-through again, and the session is explicitly released (REQUEST_RELEASE) on cleanup and on every init failure path —browser.close()on a connected handle only disconnects.BenchHarnessContext→ discriminated union (sdk: "v4" | "v3"): the runner narrows on the discriminant instead of probing five optional fields; thev4Page ?? pagefallback is gone, and a legacy task reaching a v4 context is an explicitEvalsErrorinstead ofv3: undefined.systemPromptparameter dropped frominitStagehand— nothing passes it, and the v3 equivalent is agent-only.combinationcategory →agent, the only non-deterministic category left after evals: make the bench framework v4-only for act/extract/observe #2587.Not touched, for reviewer attention on #2570 itself: the
EVAL_VERIFIER_MODEL/ keyless-provider and Claude Code result-parsing commits are orthogonal to running a/e/o on v4 (they only affect the agent/external-harness grading paths and change nothing unless the env var is set) — candidates for splitting into their own PR.Verification
run dropdown -e local -t 1 -m google/gemini-2.5-flash→ 1/1 passed (first full v4 pass through the harness; requirespackages/extensionbuilt for the local launch's extension preload)run dropdown -e browserbase -t 1to confirm sessionUrl lands in resultsSummary by cubic
Restores session and debug URLs for v4 eval runs by creating Browserbase sessions first and connecting, and simplifies the harness context with an explicit v3/v4 split for clearer task handling.
Bug Fixes
sessionUrlanddebugUrlfor v4 tasks.initStagehandnow creates the session vialaunchRunnerProvidedBrowserbaseChromeand attaches withbrowserbase.connect({ apiKey, sessionId }).Refactors
BenchHarnessContextis now a discriminated union (sdk: "v4" | "v3"). Removesv4Page ?? pagefallback and throws on legacy tasks reaching the v4 context.systemPromptfrominitStagehandin@browserbasehq/stagehandv4 flow.combinationtoagent.Written for commit e31cb72. Summary will update on new commits.