AgentEvaluator can pass hallucinations_v1 even when the run is unscored
Les mainteneurs répondent en général sous 3 jours
Évaluation
Cette issue n'a pas encore été évaluée.
Description
🔴 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.
- Langage dominant
- Python
- Étoiles
- 22.3k
- Forks
- 4.4k
- Merge moyen
- 1 j 2 h
- PR mergées (30 j)
- 6
Préparer son environnement
- Aucun Dockerfile ni fichier Docker Compose
- Propose un modèle de pull request
- Lire le guide de contribution
Par où commencer
- Lisez l'issue en entier, puis le guide de contribution du projet.
- Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
- Forkez le dépôt et travaillez sur une branche.
- Ouvrez une pull request qui référence le numéro de l'issue.
Autres issues de google/adk-python
-
Difficulté 2/5 1-3 heures Accessibilité débutants 72/100
google/adk-python#8360 ·
Les mainteneurs répondent en général sous 3 jours
-
Difficulté 2/5 1-3 heures Accessibilité débutants 82/100
google/adk-python#8359 ·
Les mainteneurs répondent en général sous 3 jours
-
Can pin to litellm version be changed?Peut-être pris @llalitkumarrr l’a pris il y a 10 jours. Ouvertemodels
Difficulté 1/5 Moins d'une heure Accessibilité débutants 65/100
google/adk-python#8129 · 2 commentaires · 1 personne assignée ·
Les mainteneurs répondent en général sous 3 jours
-
OpenAPI tools ignore operation- and path-level server overridesPeut-être pris @sanketpatil06 l’a pris il y a 14 jours. Ouvertetools
Difficulté 2/5 1-3 heures Accessibilité débutants 75/100
google/adk-python#8064 · 4 commentaires · 1 personne assignée ·
Les mainteneurs répondent en général sous 3 jours
-
Two docstrings in openapi_tool document parameters the signatures do not acceptPeut-être pris @surajksharma07 l’a pris il y a 17 jours. Ouverte
Difficulté 1/5 Moins d'une heure Accessibilité débutants 88/100
google/adk-python#8024 · 1 commentaire · 1 personne assignée ·
Les mainteneurs répondent en général sous 3 jours
Toutes les issues de google/adk-python
Issues similaires
-
Difficulté 2/5 1-3 heures Accessibilité débutants 72/100
vllm-project/vllm#70030 ·
Les mainteneurs répondent en général sous 1 jour
-
Difficulté 2/5 1-3 heures Accessibilité débutants 78/100
TigreGotico/tugaphone#408 ·
Les mainteneurs répondent en général sous 1 jour
-
needs-triage
Difficulté 2/5 1-3 heures Accessibilité débutants 74/100
gke-labs/kube-agents#7308 ·
Les mainteneurs répondent en général sous 1 jour
-
t: bug
Difficulté 2/5 1-3 heures Accessibilité débutants 78/100
Les mainteneurs répondent en général sous 3 jours
-
chore
Difficulté 1/5 1-3 heures Accessibilité débutants 88/100
lugassawan/swe-workbench#841 ·