fix[evals] remove braintrust api key requirement (#2145)#2153
Merged
Conversation
# why # what changed # test plan <!-- This is an auto-generated description by cubic. --> --- ## Summary by cubic Make Braintrust optional for evals. Evals run without a BRAINTRUST_API_KEY and skip sending logs, removing prior errors/warnings; behavior is unchanged when a key is set. - **Bug Fixes** - Added hasBraintrustApiKey() and made tracedSpan() a passthrough when no key. - Runner now passes noSendLogs: true to Eval and skips flush() without a key; sends logs and flushes when present. - `AISdkClientWrapped` uses the plain `ai` SDK unless `braintrust` can wrap it (key present), avoiding “Please specify an api key” and flush warnings. - Added tests covering both key-present and key-absent paths. <sup>Written for commit 0a850a0. Summary will update on new commits. <a href="https://cubic.dev/pr/browserbase/stagehand/pull/2145?utm_source=github">Review in cubic</a></sup> <!-- End of auto-generated description by cubic. --> --------- Co-authored-by: Claude <noreply@anthropic.com>
|
Contributor
There was a problem hiding this comment.
No issues found across 6 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 Braintrust as Braintrust Module
participant AISDK as AISdkClientWrapped
participant Env as Environment
Note over Runner,Env: Braintrust API key governs two independent paths
Runner->>Braintrust: hasBraintrustApiKey()
Braintrust->>Env: Read BRAINTRUST_API_KEY
Env-->>Braintrust: Key present or absent
Braintrust-->>Runner: boolean
alt Key present (sendLogs = true)
Runner->>Braintrust: loadBraintrust()
Braintrust-->>Runner: { Eval, flush }
Runner->>Runner: Eval(..., { noSendLogs: false })
Runner->>Braintrust: flush()
Braintrust-->>Runner: Logs sent
AISDK->>Braintrust: loadWrappedAISDK()
Braintrust->>Braintrust: import("braintrust").wrapAISDK(ai)
Braintrust-->>AISDK: wrapped AI SDK
else Key absent (sendLogs = false)
Runner->>Braintrust: loadBraintrust()
Braintrust-->>Runner: { Eval, flush }
Runner->>Runner: Eval(..., { noSendLogs: true })
Note over Runner: flush() skipped entirely
AISDK->>Braintrust: loadWrappedAISDK()
Braintrust->>Braintrust: Return plain ai SDK as WrappedAI
Braintrust-->>AISDK: unwrapped AI SDK
Braintrust->>Braintrust: tracedSpan() calls fn() directly
Braintrust-->>Runner: No Braintrust tracing
end
tkattkat
approved these changes
May 21, 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.
why
Evals should be able to run without the braintrust dependency
what changed
hasBraintrustApiKey()and madetracedSpan()a passthrough when no key.AISdkClientWrappedfalls back to the plainaiSDK whenbraintrustwrapping isn’t available; introduced aWrappedAItype and lazy load keyed onBRAINTRUST_API_KEY.test plan
core-runnertest to set a dummy key; fixes for test stability and build.Summary by cubic
Make Braintrust optional for evals. Evals run without
BRAINTRUST_API_KEYand skip sending logs; behavior is unchanged when a key is set.hasBraintrustApiKey()and madetracedSpan()a passthrough when no key.noSendLogs: truetoEvaland skipsflush()without a key; sends logs and flushes when present.AISdkClientWrappedfalls back to the plainaiSDK whenbraintrustwrapping isn’t available; introduced aWrappedAItype and lazy load keyed onBRAINTRUST_API_KEY.core-runnertest to set a dummy key; fixes for test stability and build.Written for commit 482e49b. Summary will update on new commits. Review in cubic