refactor(evals): extract EvalRunner interface (Braintrust Eval() default; no behavior change) - #2354
Conversation
|
There was a problem hiding this comment.
No issues found across 2 files
Confidence score: 5/5
- Automated review surfaced no issues in the provided summaries.
- No files require special attention.
Architecture diagram
sequenceDiagram
participant Runner as runEvals()
participant EvalRunner as EvalRunner Interface
participant Braintrust as BraintrustEvalRunner
participant BraintrustLib as @braintrust/core (Eval/flush)
participant Task as task callback
participant Progress as onProgress callback
Note over Runner,Progress: Eval execution flow (no behavior change)
Runner->>EvalRunner: run(config)
activate EvalRunner
EvalRunner->>Braintrust: Eval(projectName, {experimentName, metadata, data, task, scores, maxConcurrency, trialCount}, {noSendLogs})
Braintrust->>Task: invoke for each testcase
activate Task
alt cooperative abort active
Task->>Progress: {type: "failed", error: "aborted"}
Task-->>Braintrust: {_success: false, error: "aborted by user"}
else normal execution
Task->>Progress: {type: "started"}
Task->>Task: executeTask(input, resolvedTask, options)
alt success
Task->>Progress: {type: "passed"}
else failure
Task->>Progress: {type: "failed", error}
end
Task-->>Braintrust: TaskResult
end
deactivate Task
Braintrust-->>EvalRunner: evalResult
alt sendLogs == true
EvalRunner->>Braintrust: flush()
Braintrust-->>EvalRunner: done
end
EvalRunner-->>Runner: EvalRunnerResult
deactivate EvalRunner
Note over Runner,Progress: Post-eval (unchanged)
Runner->>Runner: shutdownTracing() if otel
ceaf31f to
24f88b9
Compare
24f88b9 to
9957587
Compare
…l; no behavior change)
9957587 to
044620c
Compare
|
Superseded by the Stagehand 4.0 retarget stack (#2757–#2762). Main moved to the 4.0 monorepo restructure (packages/core → packages/sdk-ts; evals package restructured), so this 3.x-era diff no longer applies. The OTEL/LangSmith tracing work — plus native-span capture via 4.0's global tracer and claude_code/codex agent spans — is reimplemented additively on 4.0 in the new stack. |
why
Isolates the Braintrust
Eval()coupling behind a thin seam so a future backend swap is mechanical instead of a rewrite. Pure structural refactor.what changed
framework/evalRunner.ts(new):EvalRunnerinterface +BraintrustEvalRunnerwrapping the existingEval()call verbatim (same progress/reporter/noSendLogs/flushsemantics)framework/runner.ts:runEvalsbuilds a config and delegates; everything else (trajectories, summary mapping, otel init/shutdown, offline mode, abort handling) unchangedtest plan
noSendLogs) behavior identicalStack 4/5 · base: #2353
Summary by cubic
Extracted an
EvalRunnerinterface with a defaultBraintrustEvalRunnerto decouple eval execution from Braintrust. No behavior change;runEvalsnow builds a config and delegates to the runner.framework/evalRunner.tswithEvalRunner,EvalRunnerConfig,EvalRunnerResult, andBraintrustEvalRunnerthat wrap BraintrustEval()/flush, use silent progress/reporter, and honorsendLogsvianoSendLogs.framework/runner.tsto remove inline Braintrust wiring, derivesendLogsfromhasBraintrustApiKey(), and call the runner; abort handling, offline mode, concurrency/trials, and summary mapping unchanged.Written for commit 044620c. Summary will update on new commits.