evals: declare the playwright_code agent mount - #2592
Merged
miguelg719 merged 1 commit intoAug 9, 2026
Conversation
|
Contributor
There was a problem hiding this comment.
All reported issues were addressed across 1 file
Architecture diagram
sequenceDiagram
participant Evals as Evals Framework
participant Harness as External Harness
participant PLC as prepareLLMExposure()
participant Target as prepareCoreBrowserTarget()
participant Browser as Playwright Browser
participant Agent as Claude Code Agent
participant TaskPlan as ExternalHarnessTaskPlan
Note over Evals,Agent: NEW: playwright_code LLMExposure setup flow
Harness->>PLC: prepareLLMExposure(plan, env, logger, startupProfile?)
alt unresolved startupProfile
PLC->>PLC: default: env === "BROWSERBASE" ? runner_provided_browserbase_cdp : runner_provided_local_cdp
end
alt invalid startupProfile
PLC-->>Harness: throw EvalsError
end
PLC->>Target: prepareCoreBrowserTarget(env, "playwright_code", startupProfile)
Target-->>PLC: { providedEndpoint, cleanup, metadata? }
alt no providedEndpoint.url
PLC-->>Harness: throw EvalsError
end
PLC->>Browser: chromium.connectOverCDP(url, headers)
Browser-->>PLC: connectedBrowser
PLC->>Browser: contexts()[0] ?? newContext()
Browser-->>PLC: context
PLC->>Browser: pages()[0] ?? newPage()
Browser-->>PLC: page
PLC->>PLC: log startup info
Note over PLC,Agent: Build LLMExposure
PLC-->>Harness: "LLMExposure { kind: 'code_handles', handles: { page, context, browser }, promptInstructions, runTool: { description, codeParamDescription, denyMessage, task }, captureFinalState, cleanup }"
Note over Agent,TaskPlan: Agent uses runTool during task
Agent->>Agent: Execute JavaScript with page/context/browser/startUrl/task in scope
Agent-->>Harness: Result
Note over PLC,Agent: End-of-task captureFinalState
Harness->>PLC: captureFinalState()
PLC->>Browser: page.screenshot()
Browser-->>PLC: Buffer
PLC->>Browser: page.url()
Browser-->>PLC: string
PLC-->>Harness: { screenshot, url }
Note over PLC,Agent: Cleanup
Harness->>PLC: cleanup()
PLC->>Browser: browser.close()
Browser-->>PLC: done
PLC->>Target: targetCleanup()
Target-->>PLC: done
PLC-->>Harness: complete
alt error during initialization
PLC->>Browser: try close()
PLC->>Target: targetCleanup()
PLC-->>Harness: throw EvalsError
end
Reply with feedback, questions, or to request a fix.
Re-trigger cubic
shriyatheunicorn
force-pushed
the
stg-2671-playwright-code-exposure
branch
from
August 5, 2026 07:14
4ca3ae0 to
6d57e4f
Compare
shriyatheunicorn
force-pushed
the
stg-2671-playwright-code-exposure
branch
from
August 5, 2026 08:12
6d57e4f to
bb41558
Compare
shriyatheunicorn
force-pushed
the
stg-2671-playwright-code-exposure
branch
from
August 5, 2026 08:28
bb41558 to
1dd8a47
Compare
shriyatheunicorn
force-pushed
the
stg-2671-playwright-code-exposure
branch
from
August 5, 2026 17:45
1dd8a47 to
633fea7
Compare
shriyatheunicorn
force-pushed
the
stg-2671-playwright-code-exposure
branch
from
August 5, 2026 19:06
633fea7 to
d74e112
Compare
shriyatheunicorn
force-pushed
the
stg-2671-playwright-code-exposure
branch
from
August 5, 2026 22:40
d74e112 to
35c5cc6
Compare
shriyatheunicorn
force-pushed
the
stg-2671-playwright-code-exposure
branch
from
August 6, 2026 02:16
35c5cc6 to
0156798
Compare
shriyatheunicorn
force-pushed
the
stg-2671-playwright-code-exposure
branch
from
August 6, 2026 02:46
0156798 to
4bea251
Compare
miguelg719
force-pushed
the
stg-2671-playwright-code-exposure
branch
from
August 6, 2026 22:21
4bea251 to
c1a91e1
Compare
shriyatheunicorn
force-pushed
the
stg-2671-playwright-code-exposure
branch
from
August 6, 2026 23:12
c1a91e1 to
6898f3d
Compare
miguelg719
force-pushed
the
stg-2671-playwright-code-exposure
branch
from
August 6, 2026 23:27
6898f3d to
409de2a
Compare
shriyatheunicorn
force-pushed
the
stg-2671-playwright-code-exposure
branch
from
August 8, 2026 04:49
409de2a to
9cf16fb
Compare
miguelg719
approved these changes
Aug 9, 2026
miguelg719
added a commit
that referenced
this pull request
Aug 9, 2026
Same shape as #2592 for the CDP surface: prompt instructions carried over verbatim, code_handles declaration, captureEvidence() for the terminal screenshot, URL, and aria tree. Behavior is unchanged until the adapter consumes mounts generically in #2596. Part of the nondeterministic-evals stack (#2591 → #2611). <!-- This is an auto-generated description by cubic. --> --- ## Summary by cubic Expose `cdp_code` as an `LLMExposure` with an agent-mountable `cdp` runtime, clearer prompt instructions, and richer final-state evidence. Linked to Linear STG-2671 (part 5/6). Requires the `LLMExposure` contract (1/6). - **New Features** - Agent mount: `handles.cdp`; prompt includes `AGENT_RUN_TOOL_NAME`, a first navigate/load recipe, run-tool description and code param, and a deny message; `captureEvidence` collects screenshot, URL, and `ariaTree`. - Runtime: `send`/`browser` plus `on`/`off`/`once`/`waitForEvent`/`wait` with session scoping, timeouts, safe teardown, and unhandled-rejection guards; exposes `targetId`/`sessionId`; `createAgentRuntime(logger)` initializes it. - Representation: adds `representation` capability; `page.represent()` returns the accessibility tree with metadata; evidence includes `ariaTree`. - Page management: `syncPages` keeps session pages current before `listPages`/`activePage`; bootstrap only creates a target if none exist. <sup>Written for commit e641edf. Summary will update on new commits.</sup> <a href="https://cubic.dev/pr/browserbase/stagehand/pull/2595?utm_source=github" target="_blank" rel="noopener noreferrer" data-no-image-dialog="true"><picture><source media="(prefers-color-scheme: dark)" srcset="https://www.cubic.dev/buttons/review-in-cubic-dark.svg"><source media="(prefers-color-scheme: light)" srcset="https://www.cubic.dev/buttons/review-in-cubic-light.svg"><img alt="Review in cubic" src="https://www.cubic.dev/buttons/review-in-cubic-dark.svg"></picture></a> <!-- End of auto-generated description by 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.
The surface now owns its agent mount: prompt instructions (carried over
verbatim from the per-surface block inside the claude_code tool
adapter), a code_handles declaration, and captureEvidence() returning
the terminal screenshot, URL, and aria tree. Behavior is unchanged until
the adapter consumes mounts generically in #2596.
Part of the nondeterministic-evals stack (#2591 → #2611).
Summary by cubic
Make
playwright_codeagent-mountable so the v4 harness can consume it generically, with handle exposure, prompt wiring, runTool config, and best-effort evidence capture. No behavior change; supports STG-2671’s non-deterministic suite.agentMountwith handle access (page,context,browser), prompt instructions (incl. first-action guidance), andrunToolconfig (async snippet scope:page,context,browser,startUrl,task,console; return JSON-serializable values; deny message referencesAGENT_RUN_TOOL_NAME).captureEvidencetyped asProbeEvidence(screenshot, URL,ariaTreeviapage.represent({ includeIframes: true })with best-effort per modality); track active page on"page"events; ensured initial page exists; unified cleanup.Written for commit 9cf16fb. Summary will update on new commits.