@@ -10869,6 +10869,10 @@ def test_create_evaluation_run_builds_gemini_agent_config(self):
1086910869 == _TEST_GEMINI_AGENT
1087010870 )
1087110871 assert "agent_engine" not in agent_run_config
10872+ # agent_info.name overrides the default candidate name.
10873+ inference_configs = request_body ["inferenceConfigs" ]
10874+ assert "gemini-agent" in inference_configs
10875+ assert _evals_common ._DEFAULT_CANDIDATE_NAME not in inference_configs
1087210876
1087310877 def test_create_evaluation_run_agent_engine_does_not_set_gemini (self ):
1087410878 evals_module = evals .Evals (api_client_ = self .mock_api_client )
@@ -10896,6 +10900,140 @@ def test_create_evaluation_run_agent_engine_does_not_set_gemini(self):
1089610900 agent_run_config = self ._agent_run_config (request_body )
1089710901 assert "gemini_agent_config" not in agent_run_config
1089810902 assert agent_run_config ["agent_engine" ] == _TEST_AGENT_ENGINE
10903+ # agent_info.name overrides the default candidate name.
10904+ inference_configs = request_body ["inferenceConfigs" ]
10905+ assert "ae-agent" in inference_configs
10906+ assert _evals_common ._DEFAULT_CANDIDATE_NAME not in inference_configs
10907+
10908+ def test_create_evaluation_run_gemini_agent_without_agent_info (self ):
10909+ """Gemini agent resource alone triggers inference_configs auto-construction."""
10910+ evals_module = evals .Evals (api_client_ = self .mock_api_client )
10911+
10912+ evals_module .create_evaluation_run (
10913+ dataset = agentplatform_genai_types .EvaluationRunDataSource (
10914+ evaluation_set = "projects/123/locations/us-central1/evaluationSets/789"
10915+ ),
10916+ metrics = [
10917+ agentplatform_genai_types .EvaluationRunMetric (
10918+ metric = "multi_turn_task_success_v1" ,
10919+ metric_config = agentplatform_genai_types .UnifiedMetric (
10920+ predefined_metric_spec = genai_types .PredefinedMetricSpec (
10921+ metric_spec_name = "multi_turn_task_success_v1" ,
10922+ )
10923+ ),
10924+ )
10925+ ],
10926+ dest = "gs://test-bucket/output" ,
10927+ agent = _TEST_GEMINI_AGENT ,
10928+ # No agent_info provided.
10929+ )
10930+
10931+ request_body = self ._get_create_run_body ()
10932+ agent_run_config = self ._agent_run_config (request_body )
10933+ assert (
10934+ agent_run_config ["gemini_agent_config" ]["gemini_agent" ]
10935+ == _TEST_GEMINI_AGENT
10936+ )
10937+ assert "agent_engine" not in agent_run_config
10938+ # Default candidate name should match the constant.
10939+ inference_configs = request_body ["inferenceConfigs" ]
10940+ assert _evals_common ._DEFAULT_CANDIDATE_NAME in inference_configs
10941+
10942+ def test_create_evaluation_run_no_agent_no_agent_info_no_inference (self ):
10943+ """Without agent or agent_info, no inference_configs are auto-constructed."""
10944+ evals_module = evals .Evals (api_client_ = self .mock_api_client )
10945+
10946+ evals_module .create_evaluation_run (
10947+ dataset = agentplatform_genai_types .EvaluationRunDataSource (
10948+ evaluation_set = "projects/123/locations/us-central1/evaluationSets/789"
10949+ ),
10950+ metrics = [
10951+ agentplatform_genai_types .EvaluationRunMetric (
10952+ metric = "multi_turn_task_success_v1" ,
10953+ metric_config = agentplatform_genai_types .UnifiedMetric (
10954+ predefined_metric_spec = genai_types .PredefinedMetricSpec (
10955+ metric_spec_name = "multi_turn_task_success_v1" ,
10956+ )
10957+ ),
10958+ )
10959+ ],
10960+ dest = "gs://test-bucket/output" ,
10961+ # No agent, no agent_info.
10962+ )
10963+
10964+ request_body = self ._get_create_run_body ()
10965+ assert "inferenceConfigs" not in request_body or not request_body .get (
10966+ "inferenceConfigs"
10967+ )
10968+
10969+ def test_create_evaluation_run_agent_engine_without_agent_info (self ):
10970+ """Agent Engine resource alone triggers inference_configs auto-construction."""
10971+ evals_module = evals .Evals (api_client_ = self .mock_api_client )
10972+
10973+ evals_module .create_evaluation_run (
10974+ dataset = agentplatform_genai_types .EvaluationRunDataSource (
10975+ evaluation_set = "projects/123/locations/us-central1/evaluationSets/789"
10976+ ),
10977+ metrics = [
10978+ agentplatform_genai_types .EvaluationRunMetric (
10979+ metric = "multi_turn_task_success_v1" ,
10980+ metric_config = agentplatform_genai_types .UnifiedMetric (
10981+ predefined_metric_spec = genai_types .PredefinedMetricSpec (
10982+ metric_spec_name = "multi_turn_task_success_v1" ,
10983+ )
10984+ ),
10985+ )
10986+ ],
10987+ dest = "gs://test-bucket/output" ,
10988+ agent = _TEST_AGENT_ENGINE ,
10989+ # No agent_info provided.
10990+ )
10991+
10992+ request_body = self ._get_create_run_body ()
10993+ agent_run_config = self ._agent_run_config (request_body )
10994+ assert agent_run_config ["agent_engine" ] == _TEST_AGENT_ENGINE
10995+ assert "gemini_agent_config" not in agent_run_config
10996+ # Default candidate name should match the constant.
10997+ inference_configs = request_body ["inferenceConfigs" ]
10998+ assert _evals_common ._DEFAULT_CANDIDATE_NAME in inference_configs
10999+
11000+ @mock .patch .object (_evals_common , "_resolve_dataset" )
11001+ def test_create_evaluation_run_uses_dataset_candidate_name (
11002+ self , mock_resolve_dataset
11003+ ):
11004+ """When dataset.candidate_name is set (e.g. from run_inference), the
11005+ inference_configs key should match it instead of using the default."""
11006+ mock_resolve_dataset .return_value = (
11007+ agentplatform_genai_types .EvaluationRunDataSource (
11008+ evaluation_set = "projects/123/locations/us-central1/evaluationSets/789"
11009+ )
11010+ )
11011+ evals_module = evals .Evals (api_client_ = self .mock_api_client )
11012+
11013+ evals_module .create_evaluation_run (
11014+ dataset = agentplatform_genai_types .EvaluationDataset (
11015+ eval_dataset_df = pd .DataFrame ({"prompt" : ["hello" ]}),
11016+ candidate_name = "my-agent-v2" ,
11017+ ),
11018+ metrics = [
11019+ agentplatform_genai_types .EvaluationRunMetric (
11020+ metric = "multi_turn_task_success_v1" ,
11021+ metric_config = agentplatform_genai_types .UnifiedMetric (
11022+ predefined_metric_spec = genai_types .PredefinedMetricSpec (
11023+ metric_spec_name = "multi_turn_task_success_v1" ,
11024+ )
11025+ ),
11026+ )
11027+ ],
11028+ dest = "gs://test-bucket/output" ,
11029+ agent = _TEST_GEMINI_AGENT ,
11030+ # No agent_info -- candidate name should come from dataset.
11031+ )
11032+
11033+ request_body = self ._get_create_run_body ()
11034+ inference_configs = request_body ["inferenceConfigs" ]
11035+ assert "my-agent-v2" in inference_configs
11036+ assert _evals_common ._DEFAULT_CANDIDATE_NAME not in inference_configs
1089911037
1090011038
1090111039class TestResolveInteractionsForDisplay :
0 commit comments