Skip to content

Python: reject non-boolean passed values when score is present in evaluator dict - #10176

Merged
Eduard van Valkenburg (eavanvalkenburg) merged 2 commits into
microsoft:mainfrom
Dhruv-Sh-git:fix/issue-10165-evaluator-passed-typecheck
Nov 10, 2026
Merged

Eduard van Valkenburg (eavanvalkenburg) merged 2 commits into
microsoft:mainfrom
Dhruv-Sh-git:fix/issue-10165-evaluator-passed-typecheck

Conversation

@Dhruv-Sh-git

@Dhruv-Sh-git Dhruv Shaswat (Dhruv-Sh-git) commented Nov 8, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #10165.

Motivation & Context

When a function evaluator returned a dictionary containing both score and a non-boolean passed value (such as "passed": "false"), _coerce_result() directly coerced passed = bool(d["passed"]).

Since non-empty strings are truthy in Python, "false" evaluated to True, potentially allowing failing evaluations to silently pass CI quality gates.

Description

  • In _evaluation.py::_coerce_result, moved the isinstance(d["passed"], (bool, int)) validation to run whenever "passed" is present in the dictionary.
  • Ensured non-boolean values consistently raise TypeError across both scored and unscored branches.
  • Added regression tests covering string and None values for passed when score is present.
  • Verified that valid boolean overrides (True and False) remain supported.

Validation

  • uv run pytest packages/core/tests/core/test_local_eval.py — 97 passed.
  • Full core test suite (uv run pytest packages/core/tests) — 9,499 passed, 0 failures.
  • uv run poe syntax -P core — Passed.
  • uv run poe pyright -P core — 0 errors.

AI Assistance

AI assistance was used to investigate, develop, and test this fix. The changes were reviewed and verified locally.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

Merged via the queue into microsoft:main with commit a0831d6 Nov 10, 2026
50 checks passed

This branch was previously deployed

1 inactive deployment
github-app-auth — 1928aaaf Deployed Nov 9, 2026 by Dhruv-Sh-git via add_label #27381
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

python Usage: [Issues, PRs], Target: Python

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Python: [Bug]: Function evaluator dict with both "score" and a string "passed" is coerced with bool(), so "false" passes

3 participants