Skip to content

feat(claude): sync claude plugin eval suites to braintrust experiments - #364

Open
Abhijeet Prasad (AbhiPrasad) wants to merge 3 commits into
mainfrom
trace-claude-plugin-evals-aac7dadc
Open

Abhijeet Prasad (AbhiPrasad) wants to merge 3 commits into
mainfrom
trace-claude-plugin-evals-aac7dadc

Conversation

@AbhiPrasad

@AbhiPrasad Abhijeet Prasad (AbhiPrasad) commented Dec 1, 2026 •

Copy link
Copy Markdown
Member

resolves https://linear.app/braintrustdata/issue/SDK-1021/sdk-automatically-sync-claude-code-plugin-eval-results-to-braintrust

link to trace https://www.braintrust.dev/app/Braintrust%20SDKs/p/z-abhi-bt-project/experiments/demo-plugin%20%C2%B7%20with%20plugin%20%C2%B7%20haiku%20%C2%B7%203dca784b

image

🤖 This text was AI-generated.

claude plugin eval (https://code.claude.com/docs/en/plugin-evals) scores a plugin by running each case with and without it, but its results stay in a local aggregate-result.json and HTML report. Each run's agent session lives in a temporary sandbox that Claude Code deletes when the suite ends, so there was no way to look at those runs or compare suites over time in Braintrust.

bt trace eval claude runs the suite and, when it finishes, syncs it the way the Braintrust Harbor integration syncs a Harbor job (https://docs.braintrust.dev/integrations/sdk-integrations/harbor):

bt trace eval --project my-evals claude -- ./my-plugin --runs 3
bt trace eval claude --from evals/results/2026-12-01T17-02-11-482Z
dataset  "claude-plugin-eval · <plugin>"     one record per case
experiment "<plugin> · baseline · ..."       no-plugin arm
experiment "<plugin> · with plugin · ..."    base experiment = baseline
  eval (row per run)                         input = case prompt, output = final reply
  ├── Claude Code session                    turns, LLM calls, tool calls
  ├── <grader> [score]                       1 or 0 per grader verdict
  └── run_score [score]                      the run's weighted score
  • Because the baseline is the with-plugin experiment's comparison base, Braintrust shows the plugin's effect on every score. --base-experiment compares against another experiment instead.
  • To capture sessions, bt passes --keep-temp, imports each run's native transcript below its row through the same translator used for live Claude Code tracing, and then deletes the sandboxes it kept. It never passes --trust-plugin.
  • Dataset records, experiments, and rows have IDs derived from the result document, so syncing a result again updates it instead of duplicating it. --from backfills existing results. Sessions are included only if their sandboxes still exist.
  • --tag and --additional-metadata apply to the experiment rows and the imported traces, like the other bt trace commands.

Transcript import gains a find_in_config lookup so a transcript can be found in a config directory other than the user's, such as an eval run's sandbox.

Limitations: there is no braintrust-sync.json manifest, no verifier attachments, and no span-plugin flag yet. When --output-dir is not passed, results go to a temporary directory whose path is printed. bt must bump its pinned bt-daemon revision to expose the command.

> 🤖 **This text was AI-generated.**

`claude plugin eval` (https://code.claude.com/docs/en/plugin-evals) scores a
plugin by running each case with and without it, but its results stay in a
local `aggregate-result.json` and HTML report. Each run's agent session lives
in a temporary sandbox that Claude Code deletes when the suite ends, so there
was no way to look at those runs or compare suites over time in Braintrust.

`bt trace eval claude` runs the suite and, when it finishes, syncs it the way
the Braintrust Harbor integration syncs a Harbor job
(https://docs.braintrust.dev/integrations/sdk-integrations/harbor):

```bash
bt trace eval --project my-evals claude -- ./my-plugin --runs 3
bt trace eval claude --from evals/results/2026-12-01T17-02-11-482Z
```

```text
dataset  "claude-plugin-eval · <plugin>"     one record per case
experiment "<plugin> · baseline · ..."       no-plugin arm
experiment "<plugin> · with plugin · ..."    base experiment = baseline
  eval (row per run)                         input = case prompt, output = final reply
  ├── Claude Code session                    turns, LLM calls, tool calls
  ├── <grader> [score]                       1 or 0 per grader verdict
  └── run_score [score]                      the run's weighted score
```

- Because the baseline is the with-plugin experiment's comparison base,
  Braintrust shows the plugin's effect on every score. `--base-experiment`
  compares against another experiment instead.
- To capture sessions, `bt` passes `--keep-temp`, imports each run's native
  transcript below its row through the same translator used for live Claude
  Code tracing, and then deletes the sandboxes it kept. It never passes
  `--trust-plugin`.
- Dataset records, experiments, and rows have IDs derived from the result
  document, so syncing a result again updates it instead of duplicating it.
  `--from` backfills existing results. Sessions are included only if their
  sandboxes still exist.
- `--tag` and `--additional-metadata` apply to the experiment rows and the
  imported traces, like the other `bt trace` commands.

Transcript import gains a `find_in_config` lookup so a transcript can be found
in a config directory other than the user's, such as an eval run's sandbox.

Limitations: there is no `braintrust-sync.json` manifest, no verifier
attachments, and no span-plugin flag yet. When `--output-dir` is not passed,
results go to a temporary directory whose path is printed. `bt` must bump its
pinned `bt-daemon` revision to expose the command.
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Dec 1, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-12-01T19:40:26.104531Z 4aa8df3 New commits
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: dca4aa45e0

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "Codex (@codex) review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "Codex (@codex) address that feedback".

Comment thread bt-daemon/src/plugin_eval/mod.rs Resolved
@AbhiPrasad

Copy link
Copy Markdown
Member Author

I'm not 100% sure about the bt trace eval api - Stephen Belanger (@Qard) lmk what you think!

@greptile-apps

greptile-apps Bot commented Dec 1, 2026 •

Copy link
Copy Markdown

Confidence Score: 5/5RetriggerView in Greptile

[Medium impact] The PR appears safe to merge; no new actionable issues were found.

Summary

Adds bt trace eval claude to run or import Claude plugin eval suites into Braintrust.

  • The Claude eval command runs suites and sends their results to Braintrust.
  • Each Claude eval result becomes a dataset and comparable experiments.
  • Available Claude sessions appear beneath their matching eval rows.

Diagram

%%{init: {'theme': 'neutral'}}%%
flowchart LR
  A["Run Claude plugin eval"] --> C["Read result"]
  B["Import saved result"] --> C
  C --> D["Upsert dataset cases"]
  D --> E["Register baseline experiment"]
  E --> F["Register with-plugin experiment"]
  F --> G["Write eval and score rows"]
  G --> H["Import available agent sessions"]
  H --> I["Remove successfully imported sandboxes owned by this run"]
Loading

Reviews (3) · Last reviewed commit: "fix(claude): keep stored eval outputs wh..." · Reviewed by Greptile

Comment thread bt-daemon/src/plugin_eval/mod.rs Resolved
Comment thread bt-daemon/src/trace_runtime.rs Resolved
Comment thread bt-daemon/src/plugin_eval/mod.rs Resolved
Comment thread bt-daemon/src/trace_runtime.rs Resolved
> 🤖 **This text was AI-generated.**

Review of `bt trace eval claude` found five ways a sync could lose data or
upload the wrong thing:

```text
suite finishes ──▶ sync fails ──▶ sandboxes deleted ──▶ traces gone for good
long suite ──────▶ token captured at launch has expired ──▶ upload fails
reused --output-dir + failed rerun ──▶ previous result synced again
bt trace eval claude -- --help ──▶ asks for a Braintrust login
result entry without a `name` ──▶ whole result rejected
```

Now:

- Sandboxes are deleted only when the sync succeeds and their transcript
  was imported. The ones that are kept are reported with the command to retry:

  ```text
  warning: kept 1 run sandbox(es) whose agent traces were not imported;
  retry with `bt trace eval claude --from <results>/aggregate-result.json`
  ```

- Credentials are still checked before the suite runs, so a login prompt
  never waits for a long eval. They are resolved again through the host when
  syncing starts, which refreshes an expiring OAuth token.
- A result is synced only if `aggregate-result.json` was written by this
  invocation, judged by its modification time.
- `init` and `--help` invocations run `claude plugin eval` directly, without
  resolving a project or login.
- Case, plugin, and grader `name` fields are optional, as AGENTS.md requires
  for agent-owned data. Cases with neither a name nor a directory are skipped
  with a warning. Verdicts without a name are not scored.

Transcript imports still run concurrently, but are collected in order so each
failure maps back to its sandbox.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: d15607faa9

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "Codex (@codex) review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "Codex (@codex) address that feedback".

Comment thread bt-daemon/src/plugin_eval/plan.rs Resolved
> 🤖 **This text was AI-generated.**

A successful `bt trace eval claude` run deletes the run sandboxes it kept,
because their transcripts are already in Braintrust. Each run's final reply
and session ID are read from those sandboxes. Syncing the same result again
with `--from` could no longer read them, and experiment rows were written as
full replacements, so the re-sync erased the stored values:

```text
first sync    eval row: output = "Ahoy, friend!", session_id = f47d…
              sandboxes deleted
--from again  eval row: output = (none), session_id = (none),
              agent_trace_unavailable = "sandbox was deleted"
```

This also hit runs whose traces were imported when retrying a suite where
only some imports failed.

Root `eval` rows are now written with `_is_merge`, so fields a sync cannot
read from disk keep their stored values. Score rows are still replaced,
since every score is fully known from the result document.

A deleted sandbox no longer records `agent_trace_unavailable` on the row,
because an earlier sync may have imported that trace. The reason is now typed
(`TraceUnavailable`). Only a trace that exists but cannot be read is recorded
on its row. The command still warns when runs have no agent trace.

This branch has not been deployed

No deployments
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.

1 participant