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 小时
- 30 天内合并 PR
- 6
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 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 个 reaction ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 66/100
维护者通常 1 天内回复