diff --git a/src/google/adk/evaluation/base_eval_service.py b/src/google/adk/evaluation/base_eval_service.py index 34c5fe2fe5..71d304e640 100644 --- a/src/google/adk/evaluation/base_eval_service.py +++ b/src/google/adk/evaluation/base_eval_service.py @@ -45,6 +45,7 @@ class EvaluateConfig(BaseModel): parallelism: int = Field( default=4, + ge=1, description="""Number of parallel evaluations to run during an Eval. Few factors to consider while changing this value: @@ -71,6 +72,7 @@ class InferenceConfig(BaseModel): parallelism: int = Field( default=4, + ge=1, description="""Number of parallel inferences to run during an Eval. Few factors to consider while changing this value: diff --git a/tests/unittests/evaluation/test_base_eval_service.py b/tests/unittests/evaluation/test_base_eval_service.py new file mode 100644 index 0000000000..f87104d086 --- /dev/null +++ b/tests/unittests/evaluation/test_base_eval_service.py @@ -0,0 +1,41 @@ +# Copyright 2026 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +from __future__ import annotations + +from google.adk.evaluation.base_eval_service import EvaluateConfig +from google.adk.evaluation.base_eval_service import InferenceConfig +from google.adk.evaluation.eval_metrics import EvalMetric +from pydantic import ValidationError +import pytest + + +def test_evaluate_config_rejects_zero_parallelism(): + """parallelism=0 must be rejected. + + It is forwarded unclamped to asyncio.Semaphore(value=parallelism), where a + zero value hangs every acquire() indefinitely instead of raising -- a + degenerate value that fails silently rather than loudly. + """ + with pytest.raises(ValidationError): + EvaluateConfig( + eval_metrics=[EvalMetric(metric_name="response_match_score")], + parallelism=0, + ) + + +def test_inference_config_rejects_zero_parallelism(): + """Same defect as EvaluateConfig.parallelism, on the inference side.""" + with pytest.raises(ValidationError): + InferenceConfig(parallelism=0)