@@ -10761,6 +10761,10 @@ def test_create_evaluation_run_builds_gemini_agent_config(self):
1076110761 == _TEST_GEMINI_AGENT
1076210762 )
1076310763 assert "agent_engine" not in agent_run_config
10764+ # agent_info.name overrides the default candidate name.
10765+ inference_configs = request_body ["inferenceConfigs" ]
10766+ assert "gemini-agent" in inference_configs
10767+ assert _evals_common ._DEFAULT_CANDIDATE_NAME not in inference_configs
1076410768
1076510769 def test_create_evaluation_run_agent_engine_does_not_set_gemini (self ):
1076610770 evals_module = evals .Evals (api_client_ = self .mock_api_client )
@@ -10788,6 +10792,140 @@ def test_create_evaluation_run_agent_engine_does_not_set_gemini(self):
1078810792 agent_run_config = self ._agent_run_config (request_body )
1078910793 assert "gemini_agent_config" not in agent_run_config
1079010794 assert agent_run_config ["agent_engine" ] == _TEST_AGENT_ENGINE
10795+ # agent_info.name overrides the default candidate name.
10796+ inference_configs = request_body ["inferenceConfigs" ]
10797+ assert "ae-agent" in inference_configs
10798+ assert _evals_common ._DEFAULT_CANDIDATE_NAME not in inference_configs
10799+
10800+ def test_create_evaluation_run_gemini_agent_without_agent_info (self ):
10801+ """Gemini agent resource alone triggers inference_configs auto-construction."""
10802+ evals_module = evals .Evals (api_client_ = self .mock_api_client )
10803+
10804+ evals_module .create_evaluation_run (
10805+ dataset = agentplatform_genai_types .EvaluationRunDataSource (
10806+ evaluation_set = "projects/123/locations/us-central1/evaluationSets/789"
10807+ ),
10808+ metrics = [
10809+ agentplatform_genai_types .EvaluationRunMetric (
10810+ metric = "multi_turn_task_success_v1" ,
10811+ metric_config = agentplatform_genai_types .UnifiedMetric (
10812+ predefined_metric_spec = genai_types .PredefinedMetricSpec (
10813+ metric_spec_name = "multi_turn_task_success_v1" ,
10814+ )
10815+ ),
10816+ )
10817+ ],
10818+ dest = "gs://test-bucket/output" ,
10819+ agent = _TEST_GEMINI_AGENT ,
10820+ # No agent_info provided.
10821+ )
10822+
10823+ request_body = self ._get_create_run_body ()
10824+ agent_run_config = self ._agent_run_config (request_body )
10825+ assert (
10826+ agent_run_config ["gemini_agent_config" ]["gemini_agent" ]
10827+ == _TEST_GEMINI_AGENT
10828+ )
10829+ assert "agent_engine" not in agent_run_config
10830+ # Default candidate name should match the constant.
10831+ inference_configs = request_body ["inferenceConfigs" ]
10832+ assert _evals_common ._DEFAULT_CANDIDATE_NAME in inference_configs
10833+
10834+ def test_create_evaluation_run_no_agent_no_agent_info_no_inference (self ):
10835+ """Without agent or agent_info, no inference_configs are auto-constructed."""
10836+ evals_module = evals .Evals (api_client_ = self .mock_api_client )
10837+
10838+ evals_module .create_evaluation_run (
10839+ dataset = agentplatform_genai_types .EvaluationRunDataSource (
10840+ evaluation_set = "projects/123/locations/us-central1/evaluationSets/789"
10841+ ),
10842+ metrics = [
10843+ agentplatform_genai_types .EvaluationRunMetric (
10844+ metric = "multi_turn_task_success_v1" ,
10845+ metric_config = agentplatform_genai_types .UnifiedMetric (
10846+ predefined_metric_spec = genai_types .PredefinedMetricSpec (
10847+ metric_spec_name = "multi_turn_task_success_v1" ,
10848+ )
10849+ ),
10850+ )
10851+ ],
10852+ dest = "gs://test-bucket/output" ,
10853+ # No agent, no agent_info.
10854+ )
10855+
10856+ request_body = self ._get_create_run_body ()
10857+ assert "inferenceConfigs" not in request_body or not request_body .get (
10858+ "inferenceConfigs"
10859+ )
10860+
10861+ def test_create_evaluation_run_agent_engine_without_agent_info (self ):
10862+ """Agent Engine resource alone triggers inference_configs auto-construction."""
10863+ evals_module = evals .Evals (api_client_ = self .mock_api_client )
10864+
10865+ evals_module .create_evaluation_run (
10866+ dataset = agentplatform_genai_types .EvaluationRunDataSource (
10867+ evaluation_set = "projects/123/locations/us-central1/evaluationSets/789"
10868+ ),
10869+ metrics = [
10870+ agentplatform_genai_types .EvaluationRunMetric (
10871+ metric = "multi_turn_task_success_v1" ,
10872+ metric_config = agentplatform_genai_types .UnifiedMetric (
10873+ predefined_metric_spec = genai_types .PredefinedMetricSpec (
10874+ metric_spec_name = "multi_turn_task_success_v1" ,
10875+ )
10876+ ),
10877+ )
10878+ ],
10879+ dest = "gs://test-bucket/output" ,
10880+ agent = _TEST_AGENT_ENGINE ,
10881+ # No agent_info provided.
10882+ )
10883+
10884+ request_body = self ._get_create_run_body ()
10885+ agent_run_config = self ._agent_run_config (request_body )
10886+ assert agent_run_config ["agent_engine" ] == _TEST_AGENT_ENGINE
10887+ assert "gemini_agent_config" not in agent_run_config
10888+ # Default candidate name should match the constant.
10889+ inference_configs = request_body ["inferenceConfigs" ]
10890+ assert _evals_common ._DEFAULT_CANDIDATE_NAME in inference_configs
10891+
10892+ @mock .patch .object (_evals_common , "_resolve_dataset" )
10893+ def test_create_evaluation_run_uses_dataset_candidate_name (
10894+ self , mock_resolve_dataset
10895+ ):
10896+ """When dataset.candidate_name is set (e.g. from run_inference), the
10897+ inference_configs key should match it instead of using the default."""
10898+ mock_resolve_dataset .return_value = (
10899+ agentplatform_genai_types .EvaluationRunDataSource (
10900+ evaluation_set = "projects/123/locations/us-central1/evaluationSets/789"
10901+ )
10902+ )
10903+ evals_module = evals .Evals (api_client_ = self .mock_api_client )
10904+
10905+ evals_module .create_evaluation_run (
10906+ dataset = agentplatform_genai_types .EvaluationDataset (
10907+ eval_dataset_df = pd .DataFrame ({"prompt" : ["hello" ]}),
10908+ candidate_name = "my-agent-v2" ,
10909+ ),
10910+ metrics = [
10911+ agentplatform_genai_types .EvaluationRunMetric (
10912+ metric = "multi_turn_task_success_v1" ,
10913+ metric_config = agentplatform_genai_types .UnifiedMetric (
10914+ predefined_metric_spec = genai_types .PredefinedMetricSpec (
10915+ metric_spec_name = "multi_turn_task_success_v1" ,
10916+ )
10917+ ),
10918+ )
10919+ ],
10920+ dest = "gs://test-bucket/output" ,
10921+ agent = _TEST_GEMINI_AGENT ,
10922+ # No agent_info -- candidate name should come from dataset.
10923+ )
10924+
10925+ request_body = self ._get_create_run_body ()
10926+ inference_configs = request_body ["inferenceConfigs" ]
10927+ assert "my-agent-v2" in inference_configs
10928+ assert _evals_common ._DEFAULT_CANDIDATE_NAME not in inference_configs
1079110929
1079210930
1079310931class TestResolveInteractionsForDisplay :
0 commit comments