Repository navigation
Description
Describe the bug
During adk eval (especially on multi-turn trajectory and rubric evaluators with long conversation histories), LLM judge requests call add_default_retry_options_if_not_present(llm_request) to attach _DEFAULT_HTTP_RETRY_OPTIONS (attempts=7, initial_delay=5.0, max_delay=120, exp_base=2.0) to llm_request.config.http_options.retry_options.
However, when a judge call hits a client-side request timeout (asyncio.TimeoutError / TimeoutError or google.auth.exceptions.TimeoutError when AsyncAuthorizedSession wraps aiohttp), the sample fails on the first attempt without retrying:
- In
google-genai(<= 3.0.0) withaiohttp(google-adk's default async HTTP transport):_api_client._AIOHTTP_TRANSIENT_EXConly lists(ClientConnectorError, ClientOSError, ServerDisconnectedError)and omitsasyncio.TimeoutErrorandgoogle.auth.exceptions.TimeoutError(tracked upstream in aiohttp timeout and wrapped google-auth transport exceptions are not retried despite HttpRetryOptions being configured googleapis/python-genai#3329 / fix(retry): retry on aiohttp and google-auth timeout exceptions with HttpRetryOptions googleapis/python-genai#3330). - In non-
GeminiBaseLlmjudge implementations:LlmAsJudgeresolvesjudge_modelthroughLLMRegistry, which supports non-Geminimodels (LiteLlm,AnthropicLlm, customBaseLlm) that do not interpretGenerateContentConfig.http_options.retry_options. - All-or-nothing sample aggregation: In
LlmAsJudge.evaluate_invocations(),if any(isinstance(r, BaseException) for r in invocation_result_samples):discards allnum_samples(default5) for that invocation and marks the invocationEvalStatus.NOT_EVALUATED(score=None) whenever a single sample times out without retry.
To Reproduce
import asyncio
from google.adk.evaluation.eval_case import Invocation
from google.adk.evaluation.eval_metrics import EvalMetric, JudgeModelOptions, LlmAsAJudgeCriterion
from google.adk.evaluation.evaluator import EvaluationResult, PerInvocationResult
from google.adk.evaluation.llm_as_judge import AutoRaterScore, LlmAsJudge
from google.adk.models.llm_response import LlmResponse
from google.genai import types as genai_types
class DemoJudge(LlmAsJudge[LlmAsAJudgeCriterion]):
def format_auto_rater_prompt(self, actual, expected):
return "grade this"
def convert_auto_rater_response_to_score(self, auto_rater_response):
return AutoRaterScore(score=1.0)
def aggregate_per_invocation_samples(self, samples):
return samples[0]
def aggregate_invocation_results(self, results):
return EvaluationResult(per_invocation_results=results)
async def main():
judge = DemoJudge(
eval_metric=EvalMetric(
metric_name="demo",
criterion=LlmAsAJudgeCriterion(
threshold=0.5,
judge_model_options=JudgeModelOptions(
judge_model="gemini-2.5-flash",
judge_model_config=genai_types.GenerateContentConfig(
http_options=genai_types.HttpOptions(
retry_options=genai_types.HttpRetryOptions(
attempts=3, initial_delay=0.0, max_delay=0.0, jitter=0.0
)
)
),
num_samples=2,
),
),
),
criterion_type=LlmAsAJudgeCriterion,
)
calls = 0
async def flaky_generate_content_async(llm_request):
nonlocal calls
calls += 1
if calls == 1:
raise asyncio.TimeoutError("Request timed out after 120.0 seconds.")
yield LlmResponse(
content=genai_types.Content(parts=[genai_types.Part(text="ok")])
)
judge._judge_model.generate_content_async = flaky_generate_content_async
inv = Invocation(
invocation_id="inv1",
user_content=genai_types.Content(parts=[genai_types.Part(text="hi")]),
final_response=genai_types.Content(parts=[genai_types.Part(text="hello")]),
)
res = await judge.evaluate_invocations([inv], [inv])
print("calls:", calls, "status:", res.per_invocation_results[0].eval_status)
asyncio.run(main())Output on main:
calls: 2 status: EvalStatus.NOT_EVALUATED
Expected behavior
When retry_options is configured on the judge request (either by default via add_default_retry_options_if_not_present or by the caller) and the underlying model client has not already retried the timeout, LlmAsJudge, PerTurnUserSimulatorQualityV1, and HallucinationsV1Evaluator should retry TimeoutError and google.auth.exceptions.TimeoutError according to retry_options (attempts, initial_delay, max_delay, exp_base, jitter), while avoiding double-retrying when a future google-genai version already includes those timeout classes in _AIOHTTP_TRANSIENT_EXC.
Activity
fix(eval): retry client-side timeouts in LLM judge evaluators
claxman commentedon Nov 13, 2026
Taking this.
Eval judges attach HttpRetryOptions and then fail the sample on the first TimeoutError. That timeout is not in google-genai's aiohttp transient set.
LlmAsJudge, HallucinationsV1Evaluator, and PerTurnUserSimulatorQualityV1 now share a tenacity retry of TimeoutError and google.auth.exceptions.TimeoutError. A RuntimeError is still one call. pytest of the four eval files: 106 passed.
PR: #8121
sanketpatil06 commentedon Nov 17, 2026
Hi @rladeira, thanks for the report. We reproduced the issue on main and confirmed that your PR #8076 fixes it. The PR is under review and will be merged once it's approved.
fix(eval): retry client-side timeouts in LLM judge evaluators