Skip to content

Commit e29c0f3

Browse files
committed
fix: guard empty rubric text in substring fallback + debug logging
Address reviewer feedback on #6072: - Guard `if not rubric and normalized_rubric_text:` prevents empty judge Property: lines from matching every rubric via substring - Guard `if ct and` prevents empty rubric keys from matching - Add logger.debug when substring fallback rescues a match to track judge drift in eval logs - Add test_empty_property_text_does_not_match test case
1 parent c7fca2c commit e29c0f3

2 files changed

Lines changed: 15 additions & 2 deletions

File tree

src/google/adk/evaluation/rubric_based_evaluator.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -431,14 +431,19 @@ def convert_auto_rater_response_to_score(
431431
normalized_rubric_text = _normalize_text(rubric_response.property_text)
432432
rubric = normalized_rubric_to_rubric_map.get(normalized_rubric_text, None)
433433

434-
if not rubric:
434+
if not rubric and normalized_rubric_text:
435435
candidates = [
436436
r
437437
for ct, r in normalized_rubric_to_rubric_map.items()
438-
if ct in normalized_rubric_text or normalized_rubric_text in ct
438+
if ct and (ct in normalized_rubric_text or normalized_rubric_text in ct)
439439
]
440440
if len(candidates) == 1:
441441
rubric = candidates[0]
442+
logger.debug(
443+
"Rubric substring fallback: '%s' → '%s'",
444+
rubric_response.property_text[:60],
445+
rubric.rubric_id,
446+
)
442447

443448
if rubric:
444449
rubric_scores.append(

tests/unittests/evaluation/test_rubric_based_evaluator.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -808,3 +808,11 @@ def test_ambiguous_substring_match_rejected(self):
808808
judge_property_text="Uses tools",
809809
)
810810
assert len(result.rubric_scores) == 0
811+
812+
def test_empty_property_text_does_not_match(self):
813+
"""Empty judge Property: line must not match via substring fallback."""
814+
result = self._build_evaluator_and_score(
815+
rubric_texts=["Uses tools correctly"],
816+
judge_property_text="",
817+
)
818+
assert len(result.rubric_scores) == 0

0 commit comments

Comments
 (0)