azure-ai-evaluation: PromptyEvaluatorBase falls back to the first digit anywhere in the judge's reply, and the threshold turns a stray digit into a wrong pass/fail (15 evaluators)
Maintainers usually reply within 1 day
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 75/100
- Issue type
- Bug
- Clarity
- Clearly specified
- Activity status
- Active
- Tech stack
- python
- Domain
- ai, testing-qa
Research direction
The bug is in sdk/evaluation/azure-ai-evaluation/azure/ai/evaluation/_evaluators/_common/_base_prompty_eval.py at lines 196-198. Start by reading the _do_eval method and understanding the regex fallback. Write a test that reproduces the problematic judge replies listed in the issue. The fix should improve the regex to find the intended score, not the first digit. Check the fifteen evaluators that inherit from PromptyEvaluatorBase to ensure the fix applies to all. Run existing tests to verify no regression.
Written by the indexing model from the issue text.
Description
sdk/evaluation/azure-ai-evaluation/azure/ai/evaluation/_evaluators/_common/_base_prompty_eval.py (HEAD 4993311), _do_eval:
- line 188 — structured path:
score = parsed_output.get("score", math.nan)✓ - lines 196-198 — fallback when the reply is not parseable JSON:
match = re.search(r"\d", llm_output) if match: score = float(match.group()) - lines 115-123 — the score is then compared to
self._threshold(default 3) to produce the boolean result.
re.search(r"\d", …) returns the first digit anywhere in the text. The prompts ask for a bare integer, but nothing enforces it, and judge models routinely add reasoning before the number.
Measured
The fallback expression executed verbatim, with the threshold applied as at lines 115-123:
reply first-digit score >= 3 ?
'5' 5.0 pass (correct)
'The answer is grounded. 5' 5.0 pass (correct)
'The answer makes 3 claims, all supported by the context. Score: 5' 3.0 pass (score wrong: judge said 5)
'2 of the statements are unsupported, so this is not grounded: 1' 2.0 fail (score wrong: judge said 1)
'Score: 4 (one minor gap)' 4.0 pass (correct)
'10 out of 10' 1.0 fail (wrong: reads "10" as 1)
'0' 0.0 fail (out of range, no check)
Rows 3 and 4 are the point: the judge's verdict is correct, the recorded score is a number lifted from its explanation, and the pass/fail derived from it can differ from what the judge concluded. There is also no range check, so 0 and 7 are accepted on a 1–5 scale, and 10 becomes 1.
Stated plainly: I ran the fallback expression rather than importing the package; it is a two-line regex and the class wrapper does not alter it.
Who inherits this
grep -rl PromptyEvaluatorBase _evaluators/ — fifteen: coherence, fluency, groundedness, intent_resolution, relevance, response_completeness, retrieval, similarity, task_adherence, task_completion, tool_call_accuracy, tool_call_success, tool_input_accuracy, tool_output_utilization, tool_selection. One base class, one fix site.
Related
The deprecated promptflow-evals carried the identical re.search(r"\d") in five evaluators; this SDK inherited it into the base class and added the threshold on top, which is what turns a wrong number into a wrong verdict.
Suggested fix
In the fallback, prefer an anchored or labelled match before a bare digit: re.fullmatch(r"\s*(\d+)\s*", llm_output) (the whole reply is the number), then re.search(r"[Ss]core\s*[:=]?\s*(\d+)", llm_output), then the last number in the reply rather than the first; validate the result against the evaluator's declared range and return math.nan (which the aggregation already skips) with the raw reply in the reason field when it fails. One parametrized test with rows 3 and 4 above would pin it.
Happy to open the PR.
- Dominant language
- Python
- Stars
- 5.6k
- Forks
- 3.4k
- Avg merge
- 2d 6h
- Merged PRs (30d)
- 212
Getting set up
Starts the project's dev container in your browser, under your own GitHub account.
- No Dockerfile or Docker Compose file
- Has a pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from Azure/azure-sdk-for-python
-
[Teams Chatbot]: Clarify Python dev-feed publication from a branch versus PyPI releasePossibly taken @jianingwang123 claimed this 2 days ago. Opencustomer-reported question
Difficulty 2/5 1-3 hours Newbie friendliness 62/100
Azure/azure-sdk-for-python#49548 · 1 comment · 2 reactions · 2 assignees ·
Maintainers usually reply within 1 day
-
Client customer-reported Hosted Agents needs-team-attention question Service Attention
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Azure/azure-sdk-for-python#49477 · 4 comments · 1 reaction ·
Maintainers usually reply within 1 day
-
azure-ai-evaluation: a content-harm score of 0 (no harm) is parsed as NaN in _parse_content_harm_response (numeric branch uses 0 < x instead of 0 <= x)Possibly taken @pujitha24 claimed this 18 days ago. OpenEvaluation Service Attention
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
Azure/azure-sdk-for-python#49190 · 1 comment · 1 reaction ·
Maintainers usually reply within 1 day
-
Update CODEOWNERSOpen
Difficulty 1/5 Under an hour Newbie friendliness 90/100
Azure/azure-sdk-for-python#49183 · 1 reaction ·
Maintainers usually reply within 1 day
-
azure-search-documents ContentUnderstandingSkill is missing model_name and model_deploymentPossibly taken @wasim-builds claimed this 12 days ago. OpenSearch Service Attention
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
Azure/azure-sdk-for-python#48555 · 1 comment · 1 reaction ·
Maintainers usually reply within 1 day
All issues in Azure/azure-sdk-for-python
Similar issues
-
Difficulty 1/5 Under an hour Newbie friendliness 82/100
EchoTools/nevr-runtime#651 ·
Maintainers usually reply within 1 day
-
bug frontend rt sev-3
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
Maintainers usually reply within 2 days
-
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
noontide-co/mainbranch#1211 · 1 comment ·
Maintainers usually reply within 1 day
-
[1.x Bug] run-operation --sql reports success but rolls back writes on transaction-capable adaptersOpentriage
Difficulty 2/5 1-3 hours Newbie friendliness 64/100
dbt-labs/dbt#16784 · 1 comment ·
Maintainers usually reply within 1 day