@@ -100,7 +100,7 @@ def _get_api_client_with_location(
100100
101101def _get_agent_engine_instance (
102102 agent_name : str , api_client : BaseApiClient
103- ) -> Union [types .AgentEngine , Any ]:
103+ ) -> Union [types .Runtime , Any ]:
104104 """Gets or creates an agent engine instance for the current thread."""
105105 if not hasattr (_thread_local_data , "agent_engine_instances" ):
106106 _thread_local_data .agent_engine_instances = {}
@@ -556,31 +556,12 @@ def _resolve_inference_configs(
556556 return inference_configs
557557
558558
559- def _is_gemini_agent_resource (agent : str ) -> bool :
560- """Returns True if `agent` is a Gemini Agent resource name.
561-
562- A Gemini Agent resource name has the format
563- `projects/{project}/locations/{location}/agents/{agent}`, as opposed to an
564- Agent Engine resource name which uses `.../reasoningEngines/{id}`.
565- """
566- parts = agent .split ("/" )
567- return (
568- len (parts ) == 6
569- and parts [0 ] == "projects"
570- and parts [2 ] == "locations"
571- and parts [4 ] == "agents"
572- and bool (parts [1 ])
573- and bool (parts [3 ])
574- and bool (parts [5 ])
575- )
576-
577-
578559def _add_evaluation_run_labels (
579560 labels : Optional [dict [str , str ]] = None ,
580561 agent : Optional [str ] = None ,
581562) -> Optional [dict [str , str ]]:
582563 """Adds labels to the evaluation run."""
583- if agent and "reasoningEngines/" in agent and not _is_gemini_agent_resource ( agent ) :
564+ if agent :
584565 labels = labels or {}
585566 labels ["vertex-ai-evaluation-agent-engine-id" ] = agent .split (
586567 "reasoningEngines/"
@@ -614,7 +595,7 @@ def _execute_inference_concurrently(
614595 model_or_fn : Optional [Union [str , Callable [[Any ], Any ]]] = None ,
615596 gemini_config : Optional [genai_types .GenerateContentConfig ] = None ,
616597 inference_fn : Optional [Callable [..., Any ]] = None ,
617- agent_engine : Optional [Union [str , types .AgentEngine ]] = None ,
598+ agent_engine : Optional [Union [str , types .Runtime ]] = None ,
618599 agent : Optional ["LlmAgent" ] = None , # type: ignore # noqa: F821
619600 user_simulator_config : Optional [types .evals .UserSimulatorConfig ] = None ,
620601) -> list [
@@ -1404,7 +1385,7 @@ def _execute_inference(
14041385 api_client : BaseApiClient ,
14051386 src : Union [str , pd .DataFrame ],
14061387 model : Optional [Union [Callable [[Any ], Any ], str ]] = None ,
1407- agent_engine : Optional [Union [str , types .AgentEngine ]] = None ,
1388+ agent_engine : Optional [Union [str , types .Runtime ]] = None ,
14081389 agent : Optional ["LlmAgent" ] = None , # type: ignore # noqa: F821
14091390 dest : Optional [str ] = None ,
14101391 config : Optional [genai_types .GenerateContentConfig ] = None ,
@@ -1499,7 +1480,7 @@ def _execute_inference(
14991480 f"Unsupported agent_engine type: { type (agent_engine )} . Expecting a"
15001481 " string (agent engine resource name in"
15011482 " 'projects/{project_id}/locations/{location_id}/reasoningEngines/{reasoning_engine_id}'"
1502- " format) or a types.AgentEngine instance."
1483+ " format) or a types.Runtime instance."
15031484 )
15041485 if (
15051486 _evals_constant .INTERMEDIATE_EVENTS in prompt_dataset .columns
@@ -2102,7 +2083,7 @@ def _create_agent_results_dataframe(
21022083
21032084def _run_agent_internal (
21042085 api_client : BaseApiClient ,
2105- agent_engine : Optional [Union [str , types .AgentEngine ]],
2086+ agent_engine : Optional [Union [str , types .Runtime ]],
21062087 agent : Optional ["LlmAgent" ], # type: ignore # noqa: F821
21072088 prompt_dataset : pd .DataFrame ,
21082089 user_simulator_config : Optional [types .evals .UserSimulatorConfig ] = None ,
@@ -2153,7 +2134,7 @@ def _run_agent_internal(
21532134
21542135def _run_agent (
21552136 api_client : BaseApiClient ,
2156- agent_engine : Optional [Union [str , types .AgentEngine ]],
2137+ agent_engine : Optional [Union [str , types .Runtime ]],
21572138 agent : Optional ["LlmAgent" ], # type: ignore # noqa: F821
21582139 prompt_dataset : pd .DataFrame ,
21592140 user_simulator_config : Optional [types .evals .UserSimulatorConfig ] = None ,
@@ -2224,7 +2205,7 @@ def _run_agent(
22242205
22252206def _create_agent_engine_session (
22262207 * ,
2227- agent_engine : types .AgentEngine ,
2208+ agent_engine : types .Runtime ,
22282209 user_id : str ,
22292210 session_state : Optional [dict [str , Any ]] = None ,
22302211) -> Any :
@@ -2271,7 +2252,7 @@ def _create_agent_engine_session(
22712252 operation = agent_engine .api_client .sessions .create (
22722253 name = agent_engine .api_resource .name ,
22732254 user_id = user_id ,
2274- config = types .CreateAgentEngineSessionConfig (
2255+ config = types .CreateRuntimeSessionConfig (
22752256 session_state = session_state ,
22762257 ),
22772258 )
@@ -2293,7 +2274,7 @@ def _create_agent_engine_session(
22932274def _execute_agent_run_with_retry (
22942275 row : pd .Series ,
22952276 contents : Union [genai_types .ContentListUnion , genai_types .ContentListUnionDict ],
2296- agent_engine : types .AgentEngine ,
2277+ agent_engine : types .Runtime ,
22972278 max_retries : int = 3 ,
22982279) -> Union [list [dict [str , Any ]], dict [str , Any ]]:
22992280 """Executes agent run over agent engine for a single prompt."""
@@ -2340,7 +2321,7 @@ def _execute_agent_run_with_retry(
23402321 author = ag_event .author or "user" ,
23412322 invocation_id = "history" ,
23422323 timestamp = base_ts + datetime .timedelta (seconds = i ),
2343- config = types .AppendAgentEngineSessionEventConfig (
2324+ config = types .AppendRuntimeSessionEventConfig (
23442325 content = ag_event .content ,
23452326 ),
23462327 )
0 commit comments