Skip to content

fix(eval): track unhandled scores per row for the error score handler - #909

Open
Raphael Fakhri (RaphaelFakhri) wants to merge 1 commit into
braintrustdata:mainfrom
RaphaelFakhri:fix/eval-error-score-handler-per-row
Open

Raphael Fakhri (RaphaelFakhri) wants to merge 1 commit into
braintrustdata:mainfrom
RaphaelFakhri:fix/eval-error-score-handler-per-row

Conversation

@RaphaelFakhri

Copy link
Copy Markdown
Contributor

Summary

_run_evaluator_internal_impl keeps unhandled_scores in the enclosing function and updates it with nonlocal from every row. When a row's task raises, it skips the scorers and reads whatever the last finished row stored there:

  • If an earlier row finished all its scorers, the value is None, so error_score_handler never runs and the failed row has no scores.
  • If an earlier row had a failing scorer, the failed row only gets an error score for that one scorer.

With error_score_handler=default_error_score_handler, failed rows drop out of the score averages instead of counting as 0. This change keeps unhandled_scores local to each row, which matches the JavaScript SDK.

Changes

  • Initialize unhandled_scores inside run_evaluator_task and drop the nonlocal declaration.
  • Add a test where the second row's task raises after the first row either finishes cleanly or has a failing scorer.

Testing

cd py
python -m pytest src/braintrust/test_framework.py -k error_score_handler

Before the change: 2 failed ({} == {'exact_match': 0, 'picky': 0} and {'picky': 0} == {'exact_match': 0, 'picky': 0}). After the change: 2 passed.

python -m pytest src/braintrust/test_framework.py src/braintrust/test_framework2.py src/braintrust/test_workflow_eval.py: 185 passed, 5 skipped.

unhandled_scores was shared across every row of an eval, so a row whose task raised used whatever the last finished row left behind. The error score handler then ran with a partial scorer list or not at all. Track it per row, matching the JavaScript SDK.
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 10, 2026 •

Copy link
Copy Markdown

Codex Review Summary

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

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-10T19:27:49.792340Z 41dcb41 PR opened
ℹ️ 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.

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