feat(evals): add mastra bench harness (integrations/mastra-sdk) - #2807
Draft
miguelg719 wants to merge 4 commits into
Draft
feat(evals): add mastra bench harness (integrations/mastra-sdk)#2807miguelg719 wants to merge 4 commits into
miguelg719 wants to merge 4 commits into
Conversation
|
Contributor
There was a problem hiding this comment.
All reported issues were addressed across 24 files
Architecture diagram
sequenceDiagram
participant CLI as Evals CLI
participant Runner as mastraRunner
participant Adapter as mastraToolAdapter
participant SDK as mastra-sdk (Integration)
participant Mastra as @mastra/core (Agent)
participant Tool as Stagehand (MCP/Bridge)
Note over CLI,Tool: NEW: Mastra Bench Harness Execution Flow
CLI->>Runner: runAgent(harness: "mastra")
Runner->>Adapter: NEW: prepareMastraToolAdapter()
Adapter->>Adapter: Resolve Tool Surface (e.g., stagehand_facade)
alt NEW: Mount via MCP (stdio)
Adapter->>Adapter: buildMastraMcpServers()
else NEW: Mount via handles (in-process code)
Adapter->>Tool: Start Code Bridge
Adapter->>SDK: createTool(stagehand_browser_run)
end
Adapter-->>Runner: Prepared Adapter (MCP configs / Tools)
Runner->>SDK: NEW: runMastraSession(prompt, model, tools)
SDK->>SDK: NEW: Generate unique session agentId/MCP ID
opt If MCP enabled
SDK->>Tool: createMcpClient & List Tools
end
SDK->>Mastra: Agent.stream(prompt)
loop Agent Step Execution
Mastra->>SDK: tool-call event
alt Call via MCP
SDK->>Tool: stdio request to MCP Server
else Call via Browser Run Tool
SDK->>Tool: execute JS via Code Bridge
end
Tool-->>SDK: tool-result (JSON/Images)
Note over SDK,Tool: NEW: ObservationRecorder captures step evidence
SDK->>Adapter: NEW: onToolResult() notification
Adapter->>Tool: captureEvidence()
SDK->>Mastra: Return result to Agent
Mastra->>SDK: text-delta / reasoning-delta
end
Mastra-->>SDK: finish event (Token Usage)
SDK-->>Runner: MastraSessionResult (Events, Usage, Text)
Runner->>Runner: NEW: mastraAdapter.fromHarnessResult()
Note right of Runner: CHANGED: Map Mastra events to<br/>NormalizedTrajectory (Steps + Metrics)
Runner->>Adapter: cleanup()
Adapter->>Tool: Teardown MCP/Bridge
Adapter->>Adapter: NEW: Recursive RM of temp workspace
Runner-->>CLI: TaskResult (Trajectory, Success/Fail)
Note over SDK,Mastra: NEW: Sensitive data (keys, tokens)<br/>redacted from event stream & logs
Reply with feedback, questions, or to request a fix.
Re-trigger cubic
miguelg719
marked this pull request as draft
August 24, 2026 18:19
…pters Phase 1 of the mastra harness: a structural runMastraSession layer over @mastra/core Agent.stream + @mastra/mcp MCPClient, an evals tool adapter that mounts stagehand_facade / playwright_mcp / chrome_devtools_mcp over stdio MCP and hosts the code surfaces as an in-process createTool backed by the existing code bridge, a fullStream -> Trajectory adapter, and a runner mirroring codexRunner. Registry/planner wiring lands in Phase 2.
…-runner skeleton Wire the Phase 1 Mastra adapters into the bench harness registry via defineExternalHarness and move mastraRunner onto runExternalHarnessTask so it shares the prompt/parse/grade lifecycle and normalized harness_* metrics with codex and claude_code. - benchHarness: add mastraHarness (stagehand_facade default surface, openai/gpt-5.4-mini default model, EVAL_MASTRA_MODELS override via the generic planner key) and register it last in harnessRegistry. - mastraToolAdapter: export MASTRA_TOOL_SURFACES and resolve surface/profile with the shared toolSurfaceResolution helpers; drop the bespoke resolvers. - mastraRunner: delegate prompt building, result parsing, status/stop-reason normalization, evidence capture and verifier grading to the skeleton; emit only harness_* metrics (no mastra_* names). Tool instructions now ride in the prompt instead of the Mastra system prompt to avoid duplication. - tests: registry/planner/runner/adapter coverage for the new harness, and update the registry-derived guidance regexes that hardcoded the old "claude_code or codex" list.
- Use a per-session MCPClient id so concurrent bench rows no longer disconnect each other's live MCP connection (@mastra/mcp caches clients by id). - Sanitize Mastra event summaries, transcripts, logs, and trajectory tool results/errors; drop the unused full process.env copy from the prepared tool adapter. - Do not score success JSON emitted before an SDK error as a pass. - Make MCP discovery abortable and bound MCP disconnect and runtime cleanup with timeouts so cancellation cannot hang or leak the temp workspace. - Add a real @mastra/mcp MCPClient test covering the unique-id contract.
…up errors, deep-sanitized tool args/results, fixed discovery-failure message
miguelg719
force-pushed
the
harness/wave-mastra
branch
from
August 24, 2026 18:34
7964829 to
c0a2370
Compare
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.
What
Adds
--harness mastrato evals, backed by a new private@browserbasehq/stagehand-integrations-mastra-sdkpackage.packages/integrations/mastra-sdk—runMastraSession: in-process@mastra/coreAgent +@mastra/mcpMCPClient (per-session UUID id), streamed tool-call/result/usage events, abort forwarding, status/stopReason normalization, redaction.packages/evals/framework/mastraToolAdapter.ts—via:"mcp"mounts (stagehand_facade, playwright_mcp, chrome_devtools_mcp) with idempotent cleanup; step observations recorded.packages/evals/framework/harnesses/mastraAdapter.ts— events →NormalizedToolCall[].defineExternalHarnesson the shared external-runner skeleton from the base PR.Testing
evals run b:webvoyager --harness mastra --tool stagehand_facade -l 1 -t 1 -e browserbase): harness drove 7 Stagehand tool calls through the facade and produced a final answer.Stacked on the wave-core PR. Implemented with Codex (gpt-5.6) under supervision; Claude +
codex exec reviewfindings (MCPClient id collision, env leakage, redaction) fixed in-branch.Summary by cubic
Adds a Mastra-backed bench harness to evals so
--harness mastraruns tasks through@mastra/core+@mastra/mcp. This extends the external-runner flow to Mastra with normalized trajectories, harness_* metrics, and sanitized logs.@browserbasehq/stagehand-integrations-mastra-sdkwraps Agent.stream and MCPClient with per-session client IDs, abort forwarding, bounded disconnect, token-usage normalization, and sanitized transcripts.mastraToolAdapter: mounts Stagehand via stdio MCP (stagehand_facade,playwright_mcp,chrome_devtools_mcp) and exposes code surfaces (stagehand_code,playwright_code,cdp_code) as an in-process tool (stagehand_browser_run) backed by the existing code bridge; records step evidence with idempotent cleanup.mastraAdapter: converts Mastra fullStream events intoTrajectorywith deep-sanitized args/results and image extraction for observations.mastraRunner: plugs into the shared external-runner to build prompts, stream/parse results, and map status/usage; success JSON emitted before an SDK error does not count as a pass.stagehand_facade; default model isopenai/gpt-5.4-mini; planner respectsEVAL_MASTRA_MODELS.Review and rollout notes
@mastra/coreand@mastra/mcpin the workspace; the loader throws a clear error if missing.command(optionalargs,env); non-stdio configs are rejected.EVAL_MASTRA_MAX_STEPS(fallbackAGENT_EVAL_MAX_STEPS, default 50).EVAL_MASTRA_MCP_TIMEOUT_MS; disconnect is bounded.EVAL_CAPTURE_EVIDENCE_TIMEOUT_MS(default 15s).EVAL_AGENT_MOUNT_CLEANUP_TIMEOUT_MS(default 30s).packages/integrations/mastra-sdk/dist, adds Turbo/Vitest targets; no changes to other harnesses’ behavior.Written for commit c0a2370. Summary will update on new commits.