Repository navigation
feat(claude): sync claude plugin eval suites to braintrust experiments - #364
Abhijeet Prasad (AbhiPrasad) wants to merge 3 commits into
Conversation
> 🤖 **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.
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour 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. |
There was a problem hiding this comment.
💡 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".
|
I'm not 100% sure about the |
Confidence Score: 5/5
[Medium impact] The PR appears safe to merge; no new actionable issues were found. SummaryAdds
|
> 🤖 **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.
There was a problem hiding this comment.
💡 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".
> 🤖 **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.
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
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 localaggregate-result.jsonand 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 clauderuns 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):--base-experimentcompares against another experiment instead.btpasses--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.--frombackfills existing results. Sessions are included only if their sandboxes still exist.--tagand--additional-metadataapply to the experiment rows and the imported traces, like the otherbt tracecommands.Transcript import gains a
find_in_configlookup 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.jsonmanifest, no verifier attachments, and no span-plugin flag yet. When--output-diris not passed, results go to a temporary directory whose path is printed.btmust bump its pinnedbt-daemonrevision to expose the command.