adk-python icon indicating copy to clipboard operation
adk-python copied to clipboard

per_turn_user_simulator_quality_v1 crashes with pydantic ValidationError when judge_model_config is not set

Open christiannpierre-afk opened this issue 6 months ago • 2 comments

🔴 Required Information

Please ensure all items in this section are completed to allow for efficient triaging. Requests without complete information may be rejected / deprioritized. If an item is not applicable to you - please mark it as N/A

Describe the Bug: A clear and concise description of what the bug is.

per_turn_user_simulator_quality_v1 always crashes with a pydantic ValidationError when configured via a JSON eval config file. The evaluator unconditionally passes judge_model_config as LlmRequest.config, but judge_model_config is always None because it is annotated with SkipJsonSchema and cannot be set through a JSON file. LlmRequest does not accept None for its config field, causing every eval case using this metric to fail.

Steps to Reproduce:

  1. Install google-adk==1.33.0
  2. Create a conversation eval config JSON file that includes per_turn_user_simulator_quality_v1: { "criteria": { "per_turn_user_simulator_quality_v1": { "threshold": 0.7, "judge_model_options": { "judge_model": "gemini-2.5-flash", "num_samples": 1 } } }, "user_simulator_config": { "model": "gemini-2.5-flash", "max_allowed_invocations": 10 } }
  3. Run adk eval <agent_module> <eval_set_id> --config_file_path <path_to_config>
  4. Observe error for every eval case that uses this metric

Expected Behavior: The evaluator should treat a None judge_model_config as "use model defaults" — either by omitting config from the LlmRequest entirely or by constructing a default GenerateContentConfig.

Observed Behavior: Every eval case evaluated with this metric raises a pydantic ValidationError and is skipped: ERROR - local_eval_service.py:357 - Metric evaluation failed for metric per_turn_user_simulator_quality_v1 for eval case id '' with following error: 1 validation error for LlmRequest config Input should be a valid dictionary or object to extract fields from [type=model_attributes_type, input_value=None, input_type=NoneType] For further information visit https://errors.pydantic.dev/2.12/v/model_attributes_type

Environment Details:

  • ADK Library Version: google-adk 1.33.0
  • Desktop OS: Linux
  • Python Version: 3.12

Model Information:

  • Are you using LiteLLM: No
  • Which model is being used: gemini-2.5-flash

🟡 Optional Information

Providing this information greatly speeds up the resolution process.

Regression: Did this work in a previous version of ADK? If so, which one?

Logs:

  ERROR - local_eval_service.py:357 - Metric evaluation failed for metric
  `per_turn_user_simulator_quality_v1` for eval case id 'b7427af2' with following error
  `1 validation error for LlmRequest
  config
    Input should be a valid dictionary or object to extract fields from
    [type=model_attributes_type, input_value=None, input_type=NoneType]
      For further information visit https://errors.pydantic.dev/2.12/v/model_attributes_type`
  Traceback (most recent call last):
    File ".../google/adk/evaluation/local_eval_service.py", line 348, in _evaluate_metric_for_eval_case
      evaluation_result = await self._evaluate_metric(...)
    File ".../google/adk/evaluation/local_eval_service.py", line 432, in _evaluate_metric
      return await metric_evaluator.evaluate_invocations(...)
    File ".../google/adk/evaluation/simulation/per_turn_user_simulator_quality_v1.py", line 188, in evaluate_invocations
      stop_signal_evaluation = await self._evaluate_stop_signal_turn(...)
    File ".../google/adk/evaluation/simulation/per_turn_user_simulator_quality_v1.py", line 365, in _evaluate_stop_signal_turn
      return await self._evaluate_intermediate_turn(...)
    File ".../google/adk/evaluation/simulation/per_turn_user_simulator_quality_v1.py", line 328, in _evaluate_intermediate_turn
      llm_request = LlmRequest(
  pydantic_core._pydantic_core.ValidationError: 1 validation error for LlmRequest
  config
    Input should be a valid dictionary or object to extract fields from
    [type=model_attributes_type, input_value=None, input_type=NoneType]

Screenshots / Video: If applicable, add screenshots or screen recordings to help explain your problem.

Additional Context: Add any other context about the problem here.

Minimal Reproduction Code: Please provide a code snippet or a link to a Gist/repo that isolates the issue.

// Code snippet here

How often has this issue occurred?:

  • Always (100%)

christiannpierre-afk avatar May 12 '26 20:05 christiannpierre-afk

Hi — I'd like to take this. The fix mirrors the existing guard in llm_as_judge.py (L147-148) where the same judge_model_config is treated as optional via ... or genai_types.GenerateContentConfig(). The same guard is missing at per_turn_user_simulator_quality_v1.py (L336) . I'll port that pattern, add a unit test under tests/unittests/evaluation/simulation/ covering the None-config path, and run pytest tests/unittests/evaluation/. OK to proceed?

darshil3011 avatar May 13 '26 01:05 darshil3011

@christiannpierre-afk the issue is that judge_model_config is always None when the config comes from a JSON file (it's wrapped in SkipJsonSchema), but LlmRequest.config rejects None.

As a workaround, try updating line 336 in per_turn_user_simulator_quality_v1.py from config=self._llm_options.judge_model_config to config=self._llm_options.judge_model_config or genai_types.GenerateContentConfig() — the same guard already used in llm_as_judge.py at L147–148.

Could you test this against your full eval run and confirm it resolves the crash on your end ?

surajksharma07 avatar May 13 '26 11:05 surajksharma07