Skip to content

fix(eval): surface judge reasoning in rubric_scores - #8314

Open
krisztianfekete wants to merge 1 commit into
google:mainfrom
krisztianfekete:fix/eval-judge-reasoning-rubric-scores
Open

krisztianfekete wants to merge 1 commit into
google:mainfrom
krisztianfekete:fix/eval-judge-reasoning-rubric-scores

Conversation

@krisztianfekete

@krisztianfekete krisztianfekete commented Nov 23, 2026 •

Copy link
Copy Markdown

Please ensure you have read the contribution guide before creating a pull request.

Link to Issue or Description of Change

1. Link to an existing issue (if applicable):

2. Or, if no issue exists, describe the change:

Problem:
final_response_match_v2 and hallucinations_v1 parse the judge's reasoning and then drop it, so a failed eval returns only a score (rubric_scores is None / []). The rubric_based_* metrics, and since #7366 the Vertex-backed metrics, already return their reasoning in PerInvocationResult.rubric_scores.

Solution:
Return the reasoning in the existing RubricScore type, as the other judges do. Scores, statuses and aggregation are unchanged.

  • final_response_match_v2: one RubricScore(rubric_id="is_the_agent_response_valid", rationale=<reasoning>, score=<label score>). The new _parse_reasoning matches the field directly instead of parsing the whole answer as JSON, because judge output often has code fences, trailing commas or a list-wrapped value. If the label can't be parsed, the reasoning is still returned, with no score. The majority vote already returns a whole winning sample, so the reasoning always agrees with the reported verdict.
  • hallucinations_v1: one RubricScore per sentence. Its rubric_id is the sentence, its score is 1.0 or 0.0 by label, and its rationale is "<label>: <rationale>". I put the label first because the score alone doesn't say whether a sentence was unsupported or contradictory. An invocation's result collects these from every scored response, in order. A response that can't be scored adds none.
  • To carry the per-sentence scores up to the invocation, _evaluate_nl_response now returns a third value, list[RubricScore]. Existing tests that mock it now return [] as the third value.
  • Updated the rubric_scores row in docs/guides/evaluation/evaluator/index.md.

adk eval --print_detailed_results already prints rubric_id and rationale for each per-invocation RubricScore, so no CLI change is needed.

Testing Plan

Unit Tests:

  • I have added or updated unit tests for my change.
  • All unit tests pass locally.

New tests:

  • test_final_response_match_v2.py: _parse_reasoning across judge output shapes (fenced JSON, list value, escaped characters, raw newline, missing/empty); reasoning kept when the label can't be parsed; and an end-to-end evaluate_invocations test with 3 samples (1 valid, 2 invalid). It checks that the returned reasoning comes from the winning invalid sample.
  • test_hallucinations_v1.py: per-sentence rationales through evaluate_invocations with a scripted judge; no rubric scores for an unscored response; scored responses' rubric scores kept in order when another response in the invocation can't be scored.

The new behavior tests fail on main and pass with this change.

$ pytest tests/unittests/evaluation/test_final_response_match_v2.py tests/unittests/evaluation/test_hallucinations_v1.py
83 passed

$ pytest tests/unittests/evaluation tests/unittests/cli
2962 passed, 1 xfailed

Manual End-to-End (E2E) Tests:

Ran the reproduction script from #8184. It registers a scripted judge through LLMRegistry, so it needs no network or credentials.

Before (main):

final_response_match_v2: 0.0 FAILED rubric_scores = None
hallucinations_v1: 0.0 FAILED rubric_scores = []

After:

final_response_match_v2: 0.0 FAILED rubric_scores = [RubricScore(rubric_id='is_the_agent_response_valid', rationale='The agent says Lyon; the reference says Paris.', score=0.0)]
hallucinations_v1: 0.0 FAILED rubric_scores = [RubricScore(rubric_id='The capital of France is Lyon.', rationale='contradictory: The context states the capital is Paris.', score=0.0)]

Checklist

  • I have read the CONTRIBUTING.md document.
  • I have performed a self-review of my own code.
  • I have commented my code, particularly in hard-to-understand areas.
  • I have added tests that prove my fix is effective or that my feature works.
  • New and existing unit tests pass locally with my changes.
  • I have manually tested my changes end-to-end.
  • Any dependent changes have been merged and published in downstream modules.

Additional context

@krisztianfekete
krisztianfekete force-pushed the fix/eval-judge-reasoning-rubric-scores branch from 4ff36ff to 7aa8287 Compare November 26, 2026 13:55
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.

Eval judges drop their own reasoning (final_response_match_v2, hallucinations_v1)

2 participants