evals: promote agent-mount contract to v4-spike - #2635
Merged
Conversation
|
Contributor
There was a problem hiding this comment.
1 issue found across 2 files
Confidence score: 3/5
- In
packages/evals/core/contracts/tool.ts,stagehand_codewas added toToolSurfacebut runtime resolvers still fall through to "not implemented"/"No default startup profile" paths, so selecting that surface can fail at runtime instead of executing a tool flow — align resolver/default-profile handling with the updated union and add a guard test forstagehand_code.
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="packages/evals/core/contracts/tool.ts">
<violation number="1" location="packages/evals/core/contracts/tool.ts:9">
P2: `stagehand_code` is now part of `ToolSurface`, but the runtime resolvers still don't handle it, so selecting that surface reaches thrown "not implemented"/"No default startup profile" paths. Keeping the union aligned with implemented registry/startup branches (or deferring this union member) would avoid a misleading supported-surface contract.</violation>
</file>
Architecture diagram
sequenceDiagram
participant Harn as Agent Harness
participant ToolCtrl as CoreTool
participant StartRes as ToolStartResult
participant Mount as AgentMount
participant Evid as captureEvidence
Note over Harn,Evid: NEW: Agent-Mount Contract Flow (v4-spike)
Harn->>ToolCtrl: start(input) via CoreTool interface
activate ToolCtrl
ToolCtrl-->>StartRes: Return ToolStartResult
deactivate ToolCtrl
Note over StartRes: Contains optional agentMount + captureEvidence
alt Native surface (no mount)
Harn->>StartRes: Use session directly
StartRes-->>Harn: Cleanup lifecycle
else Agent-mounted delivery
Harn->>Mount: Access agentMount via
alt via: "handles"
Mount->>Mount: Resolve handles (Record<string, unknown>)
Mount->>Mount: Validate reserved handles (startUrl, task, console)
else via: "mcp"
Mount->>Mount: Load mcpServers config
else via: "cli"
Mount->>Mount: Build command (bin, args, cwd, env)
end
Harn->>StartRes: Use promptInstructions for agent context
end
opt Evidence capture requested
Harn->>Evid: Call captureEvidence()
activate Evid
Evid->>Evid: Swallow per-field failures, never throw
Evid-->>Harn: Return ProbeEvidence (screenshot, url, ariaTree)
deactivate Evid
end
Harn->>StartRes: Call cleanup()
activate StartRes
Note over StartRes: captureEvidence invalid after this
StartRes-->>Harn: Runtime released
deactivate StartRes
alt Compile-time validation
Harn->>Mount: Verify discriminated union fields
Mount-->>Harn: TypeScript ensures via-specific properties
Note over Harn: e.g., CLI mount requires command field
end
Reply with feedback, questions, or to request a fix.
Re-trigger cubic
A uniform declaration of what a tool surface offers a coding agent: code_handles (in-scope objects the agent writes code against, mounted by the harness as a single local-MCP run tool), mcp_server, or cli — plus the LLM_RUN_TOOL_SERVER/LLM_RUN_TOOL_NAME bindings the mount uses. Types and constants only; no surface or adapter changes. Part 1/4 of the #2473 port onto the current SDK generation. <!-- This is an auto-generated description by cubic. --> --- ## Summary by cubic Updates the tool-surface contract to include agent delivery (`AgentMount`) and final-state evidence capture, keeping native `CoreTool.surface` independent from how it’s delivered to the agent. Types + tests only; supports STG-2671. - **New Features** - Types: `AgentMount` (`via: handles | mcp | cli` with `promptInstructions`), `AgentRunToolSpec`; `ToolStartResult` gains optional `agentMount` and `captureEvidence(): Promise<ProbeEvidence>`. - Enums: `ToolSurface` adds `stagehand_code`; `CoreTool.family` adds `stagehand`. - Constants: `AGENT_RUN_TOOL_SERVER` ("stagehand_browser"), `AGENT_RUN_TOOL_NAME` (`mcp__stagehand_browser__run`), `AGENT_RUN_TOOL_RESERVED_HANDLES` (`startUrl`, `task`, `console`). - Contract semantics: delivery is independent of native surface; CLI env merges over harness env; reserved harness bindings; capture-before-cleanup ordering. - Tests: `tool-contract.test.ts` validates delivery independence, handle mounts, and evidence capture. <sup>Written for commit d3ba958. Summary will update on new commits.</sup> <a href="https://cubic.dev/pr/browserbase/stagehand/pull/2590?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. --> --------- Co-authored-by: Miguel <36487034+miguelg719@users.noreply.github.com>
shriyatheunicorn
force-pushed
the
evals-v4-root
branch
from
August 8, 2026 04:49
aeebcd2 to
fd74210
Compare
akeimach
approved these changes
Aug 9, 2026
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
Corrects the base-target mistake from #2590 by landing its merged agent-mount contract on v4-spike.
This branch is exactly current v4-spike plus the #2590 squash commit:
After merge, #2591 and the remaining stack will be rebased directly onto v4-spike.
Verification
Summary by cubic
Promotes the agent-mount tool-surface contract to
v4-spike, adding type-safe agent delivery bindings and best-effort evidence capture, independent ofCoreTool.surface. Types and tests only; no runtime changes.ToolStartResultadds optionalagentMountandcaptureEvidence(): Promise<ProbeEvidence>.AgentMountunion (via: handles | mcp | cli) withpromptInstructions; plusAgentRunToolSpec.AGENT_RUN_TOOL_SERVER,AGENT_RUN_TOOL_NAME,AGENT_RUN_TOOL_RESERVED_HANDLES. Enums:ToolSurfaceaddsstagehand_code;CoreTool.familyaddsstagehand.packages/evals/tests/core/tool-contract.test.ts) validate surface/delivery independence, handle mounts, and evidence capture.Written for commit fd74210. Summary will update on new commits.