Skip to content

fix[evals] remove braintrust api key requirement (#2145)#2153

Merged
miguelg719 merged 2 commits into
mainfrom
contrib/2145
May 21, 2026
Merged

fix[evals] remove braintrust api key requirement (#2145)#2153
miguelg719 merged 2 commits into
mainfrom
contrib/2145

Conversation

@miguelg719
Copy link
Copy Markdown
Collaborator

@miguelg719 miguelg719 commented May 21, 2026

why

Evals should be able to run without the braintrust dependency

what changed

  • Added hasBraintrustApiKey() and made tracedSpan() a passthrough when no key.
  • AISdkClientWrapped falls back to the plain ai SDK when braintrust wrapping isn’t available; introduced a WrappedAI type and lazy load keyed on BRAINTRUST_API_KEY.

test plan

  • Added tests for key-present/absent paths and updated core-runner test to set a dummy key; fixes for test stability and build.

Summary by cubic

Make Braintrust optional for evals. Evals run without BRAINTRUST_API_KEY and skip sending logs; 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 falls back to the plain ai SDK when braintrust wrapping isn’t available; introduced a WrappedAI type and lazy load keyed on BRAINTRUST_API_KEY.
    • Added tests for key-present/absent paths and updated core-runner test to set a dummy key; fixes for test stability and build.

Written for commit 482e49b. Summary will update on new commits. Review in cubic

# 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>
@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented May 21, 2026

⚠️ No Changeset found

Latest commit: 482e49b

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@miguelg719 miguelg719 marked this pull request as ready for review May 21, 2026 16:46
Copy link
Copy Markdown
Contributor

@cubic-dev-ai cubic-dev-ai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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
Loading

Re-trigger cubic

@miguelg719 miguelg719 merged commit 278890b into main May 21, 2026
36 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants