From d02a7da393a6bb8b1a9c462243b399b62911378c Mon Sep 17 00:00:00 2001 From: A Vertex SDK engineer Date: Tue, 4 Nov 2025 14:06:49 -0800 Subject: [PATCH] fix: GenAI Client(evals) - Remove requirement for `agent_info.agent` in `create_evaluation_run` in Vertex AI GenAI SDK evals. PiperOrigin-RevId: 828127361 --- vertexai/_genai/evals.py | 36 ++++++++++-------------------------- 1 file changed, 10 insertions(+), 26 deletions(-) diff --git a/vertexai/_genai/evals.py b/vertexai/_genai/evals.py index c21b186ecd..afc7868627 100644 --- a/vertexai/_genai/evals.py +++ b/vertexai/_genai/evals.py @@ -1397,15 +1397,6 @@ def create_evaluation_run( ) inference_configs = {} if agent_info: - if isinstance(agent_info, dict): - agent_info = types.evals.AgentInfo.model_validate(agent_info) - if ( - not agent_info.agent - or len(agent_info.agent.split("reasoningEngines/")) != 2 - ): - raise ValueError( - "agent_info.agent cannot be empty. Please provide a valid reasoning engine resource name in the format of projects/{project}/locations/{location}/reasoningEngines/{reasoning_engine}." - ) inference_configs[agent_info.name] = types.EvaluationRunInferenceConfig( agent_config=types.EvaluationRunAgentConfig( developer_instruction=genai_types.Content( @@ -1414,10 +1405,11 @@ def create_evaluation_run( tools=agent_info.tool_declarations, ) ) - labels = labels or {} - labels["vertex-ai-evaluation-agent-engine-id"] = agent_info.agent.split( - "reasoningEngines/" - )[-1] + if agent_info.agent: + labels = labels or {} + labels["vertex-ai-evaluation-agent-engine-id"] = agent_info.agent.split( + "reasoningEngines/" + )[-1] if not name: name = f"evaluation_run_{uuid.uuid4()}" @@ -2252,15 +2244,6 @@ async def create_evaluation_run( ) inference_configs = {} if agent_info: - if isinstance(agent_info, dict): - agent_info = types.evals.AgentInfo.model_validate(agent_info) - if ( - not agent_info.agent - or len(agent_info.agent.split("reasoningEngines/")) != 2 - ): - raise ValueError( - "agent_info.agent cannot be empty. Please provide a valid reasoning engine resource name in the format of projects/{project}/locations/{location}/reasoningEngines/{reasoning_engine}." - ) inference_configs[agent_info.name] = types.EvaluationRunInferenceConfig( agent_config=types.EvaluationRunAgentConfig( developer_instruction=genai_types.Content( @@ -2269,10 +2252,11 @@ async def create_evaluation_run( tools=agent_info.tool_declarations, ) ) - labels = labels or {} - labels["vertex-ai-evaluation-agent-engine-id"] = agent_info.agent.split( - "reasoningEngines/" - )[-1] + if agent_info.agent: + labels = labels or {} + labels["vertex-ai-evaluation-agent-engine-id"] = agent_info.agent.split( + "reasoningEngines/" + )[-1] if not name: name = f"evaluation_run_{uuid.uuid4()}"