@@ -10301,9 +10301,9 @@ def test_resolve_interactions_to_eval_cases_happy_path(self):
1030110301
1030210302 def mock_request (method , path , * args , ** kwargs ):
1030310303 resp = mock .MagicMock ()
10304- if path .startswith ("interactions/" ):
10304+ if path .endswith ("interactions/i1 " ):
1030510305 resp .body = interaction_body
10306- elif path .startswith ("agents/" ):
10306+ elif path .endswith ("agents/my-agent " ):
1030710307 resp .body = agent_body
1030810308 else :
1030910309 resp .body = None
@@ -10314,9 +10314,9 @@ def mock_request(method, path, *args, **kwargs):
1031410314 original_case = agentplatform_genai_types .EvalCase (
1031510315 interactions_data_source = agentplatform_genai_types .InteractionsDataSource (
1031610316 gemini_agent_config = agentplatform_genai_types .GeminiAgentConfig (
10317- gemini_agent = "projects/p/locations/l /agents/my-agent" ,
10317+ gemini_agent = "projects/p/locations/us-central1 /agents/my-agent" ,
1031810318 ),
10319- interaction = "projects/p/locations/l /interactions/i1" ,
10319+ interaction = "projects/p/locations/us-central1 /interactions/i1" ,
1032010320 ),
1032110321 )
1032210322
@@ -11119,7 +11119,12 @@ def mock_request(method, path, *args, **kwargs):
1111911119 # Verify the interaction and agent were fetched.
1112011120 assert mock_api_client .request .call_count == 2
1112111121 mock_api_client .request .assert_any_call ("get" , "interactions/test-id" , {}, None )
11122- mock_api_client .request .assert_any_call ("get" , "agents/my-agent" , {}, None )
11122+ mock_api_client .request .assert_any_call (
11123+ "get" ,
11124+ "projects/p/locations/l/agents/my-agent" ,
11125+ {},
11126+ None ,
11127+ )
1112311128
1112411129 def test_agents_map_populated_with_full_config (self ):
1112511130 """The agents dict includes instruction and tools from the Agent API."""
@@ -12072,6 +12077,40 @@ def test_mcp_server_kept_as_named_declaration(self):
1207212077 assert len (mcp_tool ) == 1
1207312078 assert "my-mcp" in mcp_tool [0 ].function_declarations [0 ].description
1207412079
12080+ def test_skips_fetch_when_location_mismatches (self ):
12081+ """Skips agent config fetch and logs warning if locations mismatch."""
12082+ mock_api_client = mock .MagicMock ()
12083+ mock_api_client .location = "us-central1"
12084+ mock_api_client .request .return_value = self ._make_api_response ({})
12085+
12086+ result = _evals_common ._fetch_agent_config_dict (
12087+ mock_api_client ,
12088+ "projects/p/locations/global/agents/my-agent" ,
12089+ )
12090+ assert result .agent_id == "my-agent"
12091+ assert result .instruction is None
12092+ mock_api_client .request .assert_not_called ()
12093+
12094+ def test_uses_full_resource_name_when_location_matches (self ):
12095+ """Uses full resource name in GET request when client location matches."""
12096+ agent_json = {"system_instruction" : "You are helpful." }
12097+ mock_api_client = mock .MagicMock ()
12098+ mock_api_client .location = "us-central1"
12099+ mock_api_client .request .return_value = self ._make_api_response (agent_json )
12100+
12101+ result = _evals_common ._fetch_agent_config_dict (
12102+ mock_api_client ,
12103+ "projects/p/locations/us-central1/agents/my-agent" ,
12104+ )
12105+ assert result .agent_id == "my-agent"
12106+ assert result .instruction == "You are helpful."
12107+ mock_api_client .request .assert_called_once_with (
12108+ "get" ,
12109+ "projects/p/locations/us-central1/agents/my-agent" ,
12110+ {},
12111+ None ,
12112+ )
12113+
1207512114 def test_catalog_in_sync_with_server (self ):
1207612115 """SDK catalog keys and function names match the server-side catalog.
1207712116
0 commit comments