AgentEvaluator can pass hallucinations_v1 even when the run is unscored

オープン
#8,276 コメント 1 件 リアクション 0 件 担当者 1 名 GitHub で見る

メンテナーはふだん 3 日以内に返信

@sanketpatil06 がすでに取り組んでいます。

2026年11月20日 から。

  • #8277 @EdwardGlockner による — オープン

評価

この issue はまだ評価されていません。

説明

eval

🔴 Required Information

Describe the Bug:
Since 59b0dd63c (#7967), when the judge can't label one of the responses, hallucinations_v1 returns NOT_EVALUATED (score None) for the eval case instead of scoring it on the rest, unless it fails even with that response counted as correct. The responses it could label still get their own per-invocation scores.

AgentEvaluator doesn't look at that overall result. _process_metrics_and_get_failures averages the per-invocation scores and skips the None, so the metric is scored only on the labelled responses, and it can pass. This happens with a single run, so it's separate from #8230 (the adk eval --num_runs aggregator), which #8238 fixes. This one is in agent_evaluator.py, which AgentEvaluator.evaluate and evaluate_eval_set use.

I found this while checking the other places that average per-invocation scores, after #8230. It's in 2.15.0, and agent_evaluator.py and hallucinations_v1.py are the same on main.

Steps to Reproduce:

  1. 2.15.0 (or main @ c81876a49).
  2. Run the script below. No network needed: the agent uses a fake model, and the judge is stubbed to label the first answer and fail on the second.
import asyncio
from unittest import mock

from google.adk.agents.llm_agent import LlmAgent
from google.adk.evaluation.agent_evaluator import AgentEvaluator
from google.adk.evaluation.eval_case import EvalCase
from google.adk.evaluation.eval_case import Invocation
from google.adk.evaluation.eval_config import EvalConfig
from google.adk.evaluation.eval_metrics import HallucinationsCriterion
from google.adk.evaluation.eval_metrics import JudgeModelOptions
from google.adk.evaluation.eval_set import EvalSet
from google.adk.evaluation.hallucinations_v1 import HallucinationsV1Evaluator
from google.adk.models.base_llm import BaseLlm
from google.adk.models.llm_response import LlmResponse
from google.genai import types

ANSWERS = {
    "Capital of France?": "Paris is the capital of France.",
    "How tall is the Eiffel Tower?": "The Eiffel Tower is 900 m tall.",
}


def content(role, text):
  return types.Content(role=role, parts=[types.Part(text=text)])


class FakeModel(BaseLlm):
  """Answers each question from ANSWERS."""

  async def generate_content_async(self, llm_request, stream=False):
    question = llm_request.contents[-1].parts[0].text
    yield LlmResponse(content=content("model", ANSWERS[question]))


async def judge(self, nl_response, context):
  """Labels the first answer, and can't label the second."""
  if nl_response.startswith("Paris"):
    return 1.0, "[]"
  return None, "unparsable judge output"


async def main():
  agent = LlmAgent(name="geo", model=FakeModel(model="fake"))
  eval_set = EvalSet(
      eval_set_id="geo_set",
      eval_cases=[
          EvalCase(
              eval_id="two_turns",
              conversation=[
                  Invocation(
                      user_content=content("user", question),
                      final_response=content("model", answer),
                  )
                  for question, answer in ANSWERS.items()
              ],
          )
      ],
  )
  eval_config = EvalConfig(
      criteria={
          "hallucinations_v1": HallucinationsCriterion(
              threshold=0.5,
              judge_model_options=JudgeModelOptions(
                  judge_model="gemini-2.5-flash"
              ),
          )
      }
  )
  with (
      mock.patch("google.adk.evaluation.hallucinations_v1.LLMRegistry"),
      mock.patch.object(
          HallucinationsV1Evaluator, "_evaluate_nl_response", judge
      ),
  ):
    await AgentEvaluator.evaluate_eval_set(
        agent_module=agent,
        eval_set=eval_set,
        eval_config=eval_config,
        num_runs=1,
    )
  print("evaluate_eval_set passed")


asyncio.run(main())

Expected Behavior:
The same as when no response could be scored: evaluate_eval_set fails with

hallucinations_v1 for geo was not evaluated. No score was produced, ...

Observed Behavior:

Summary: `EvalStatus.PASSED` for Metric: `hallucinations_v1`. Expected threshold: `0.5`, actual value: `1.0`.
...
evaluate_eval_set passed

The table printed under that summary shows the second answer as NOT_EVALUATED (and it's false), but the metric passes on the first answer alone.

Environment Details:

  • ADK Library Version: 2.15.0, and main @ c81876a49
  • Desktop OS: Windows 10
  • Python Version: 3.11.9

Model Information:

  • Are you using LiteLLM: No
  • Which model is being used: N/A (fake agent model, stubbed judge)

🟡 Optional Information

Regression:
Not quite: before 59b0dd63c the case was scored on the labelled responses anyway (#7963), so it passed then too. 59b0dd63c fixed that in the evaluator, but AgentEvaluator doesn't see it. #8122 (retrying unscored judge calls) makes this rarer, but once the retries run out it's the same.

Proposed fix:
PR with the fix and tests: #8277. It leaves the per-invocation scores of a run that's NOT_EVALUATED with no score out of the average, the same rule #8238 uses in the aggregator.

主要言語
Python
スター
22.3k
フォーク
4.4k
平均マージ
1日 2時間
マージ済み PR(30日)
6

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

google/adk-python のほかの issue

google/adk-python の issue をすべて見る

似ている issue

Python の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。