Repository navigation
feat(sdk): Add trace-aware scorers - #2839
Luca Forstner (lforst) wants to merge 2 commits into
Conversation
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: fd611b5fdd
ℹ️ 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".
| } | ||
| } | ||
|
|
||
| const stateKey = Symbol.for("braintrust-state-v4"); |
There was a problem hiding this comment.
Coordinate instrumentation ownership with the isolated state
When an older SDK copy registers provider instrumentation first, this new state key separates the newer copy's logger and current span, but instrumentation remains shared: instrumentation/registry.ts still deduplicates providers through braintrust.registry.global-hooks.v2, and the invocation hooks retain protocol version 2. Consequently, the newer copy skips registering its own tracing interceptors, and provider calls inside its traced() or defineScorer() callbacks execute the older copy's tracing functions against the older state. Those calls can become no-op spans or log to the older logger instead of joining the new trace. Coordinate instrumentation ownership with the state isolation so mixed-version processes retain correctly parented provider spans.
AGENTS.md reference: AGENTS.md:L53-L53
Useful? React with 👍 / 👎.
defineScorerso the same scoring function can run on its own or in anEval.BRAINTRUST_TRACE_PARENTto attach new spans to the caller’s trace. Previously, it had to pass the parent explicitly. With this variable set,defineScorersigns in with the worker’s current credentials on each call and flushes trace data even if scoring fails.