AgentEvaluator can pass hallucinations_v1 even when the run is unscored
メンテナーはふだん 3 日以内に返信
評価
この issue はまだ評価されていません。
説明
🔴 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:
- 2.15.0 (or main @ c81876a49).
- 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
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートあり
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
google/adk-python のほかの issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
google/adk-python#8360 ·
メンテナーはふだん 3 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
google/adk-python#8359 ·
メンテナーはふだん 3 日以内に返信
-
Can pin to litellm version be changed?対応中かも @llalitkumarrr が 10 日前に担当しました。 オープンmodels
難易度 1/5 1時間未満 初心者へのやさしさ 65/100
google/adk-python#8129 · コメント 2 件 · 担当者 1 名 ·
メンテナーはふだん 3 日以内に返信
-
OpenAPI tools ignore operation- and path-level server overrides対応中かも @sanketpatil06 が 14 日前に担当しました。 オープンtools
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
google/adk-python#8064 · コメント 4 件 · 担当者 1 名 ·
メンテナーはふだん 3 日以内に返信
-
Two docstrings in openapi_tool document parameters the signatures do not accept対応中かも @surajksharma07 が 17 日前に担当しました。 オープン
難易度 1/5 1時間未満 初心者へのやさしさ 88/100
google/adk-python#8024 · コメント 1 件 · 担当者 1 名 ·
メンテナーはふだん 3 日以内に返信
google/adk-python の issue をすべて見る
似ている issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
vllm-project/vllm#70030 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
TigreGotico/tugaphone#408 ·
メンテナーはふだん 1 日以内に返信
-
t: bug
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
メンテナーはふだん 3 日以内に返信
-
needs-triage
難易度 1/5 1時間未満 初心者へのやさしさ 85/100
Azure/azure-sdk-for-python#50155 · リアクション 1 件 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 66/100
メンテナーはふだん 1 日以内に返信