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