From b1378bb54566396506dfe17041f4e8d3fb715573 Mon Sep 17 00:00:00 2001 From: Yifan Yang Date: Fri, 2 Oct 2026 15:01:47 -0700 Subject: [PATCH] feat: surface the LRO name in Agent Engine create and update requests PiperOrigin-RevId: 992557497 --- agentplatform/_genai/runtimes.py | 10 ++++++++-- tests/unit/agentplatform/genai/test_agent_engines.py | 4 ++-- vertexai/_genai/agent_engines.py | 10 ++++++++-- 3 files changed, 18 insertions(+), 6 deletions(-) diff --git a/agentplatform/_genai/runtimes.py b/agentplatform/_genai/runtimes.py index 602805f1a6..ab235e3765 100644 --- a/agentplatform/_genai/runtimes.py +++ b/agentplatform/_genai/runtimes.py @@ -1913,6 +1913,7 @@ def create( build_config=config.build_config, ) operation = self._create(config=api_config) + logger.info(f"Create Agent Runtime backing LRO: {operation.name}") reasoning_engine_id = _runtimes_utils._get_reasoning_engine_id( operation_name=operation.name ) @@ -1943,7 +1944,9 @@ def create( f"runtime=client.runtimes.get(name='{runtime.api_resource.name}')" ) elif operation.error: - raise RuntimeError(f"Failed to create Agent Runtime: {operation.error}") + raise RuntimeError( + f"Operation {operation.name} failed to create Agent Runtime: {operation.error}" + ) else: logger.warning("The operation returned an empty response.") if not self._is_lightweight_creation(agent, config): @@ -2719,6 +2722,7 @@ def update( build_config=config.build_config, ) operation = self._update(name=name, config=api_config) + logger.info(f"Update Agent Runtime backing LRO: {operation.name}") reasoning_engine_id = _runtimes_utils._get_reasoning_engine_id( resource_name=name ) @@ -2743,7 +2747,9 @@ def update( f"runtime=client.runtimes.get(name='{runtime.api_resource.name}')" ) elif operation.error: - raise RuntimeError(f"Failed to update Agent Runtime: {operation.error}") + raise RuntimeError( + f"Operation {operation.name} failed to update Agent Runtime: {operation.error}" + ) if runtime.api_resource.spec: self._register_api_methods(runtime=runtime) return runtime # type: ignore[no-any-return] diff --git a/tests/unit/agentplatform/genai/test_agent_engines.py b/tests/unit/agentplatform/genai/test_agent_engines.py index 7e84a80ff2..08f8c37e60 100644 --- a/tests/unit/agentplatform/genai/test_agent_engines.py +++ b/tests/unit/agentplatform/genai/test_agent_engines.py @@ -4167,7 +4167,7 @@ def test_create_runtime_error( env_vars=_TEST_AGENT_ENGINE_ENV_VARS_INPUT, ), ) - assert "Failed to create agent engine" in str(excinfo.value) + assert "failed to create Agent Runtime" in str(excinfo.value) @mock.patch.object(_runtimes_utils, "_await_operation") def test_update_runtime_description(self, mock_await_operation): @@ -4185,7 +4185,7 @@ def test_update_runtime_description(self, mock_await_operation): description=_TEST_AGENT_ENGINE_DESCRIPTION, ), ) - assert "Failed to update agent engine" in str(excinfo.value) + assert "failed to update Agent Runtime" in str(excinfo.value) @pytest.mark.parametrize( "test_case_name, test_operation_schemas, want_log_output", diff --git a/vertexai/_genai/agent_engines.py b/vertexai/_genai/agent_engines.py index 7e40b697ca..e8aa8be81e 100644 --- a/vertexai/_genai/agent_engines.py +++ b/vertexai/_genai/agent_engines.py @@ -2008,6 +2008,7 @@ def create( build_config=config.build_config, ) operation = self._create(config=api_config) + logger.info(f"Create Agent Engine backing LRO: {operation.name}") reasoning_engine_id = _agent_engines_utils._get_reasoning_engine_id( operation_name=operation.name ) @@ -2038,7 +2039,9 @@ def create( f"agent_engine=client.agent_engines.get(name='{agent_engine.api_resource.name}')" ) elif operation.error: - raise RuntimeError(f"Failed to create Agent Engine: {operation.error}") + raise RuntimeError( + f"Operation {operation.name} failed to create Agent Engine: {operation.error}" + ) else: logger.warning("The operation returned an empty response.") if not self._is_lightweight_creation(agent, config): @@ -2820,6 +2823,7 @@ def update( build_config=config.build_config, ) operation = self._update(name=name, config=api_config) + logger.info(f"Update Agent Engine backing LRO: {operation.name}") reasoning_engine_id = _agent_engines_utils._get_reasoning_engine_id( resource_name=name ) @@ -2844,7 +2848,9 @@ def update( f"agent_engine=client.agent_engines.get(name='{agent_engine.api_resource.name}')" ) elif operation.error: - raise RuntimeError(f"Failed to update Agent Engine: {operation.error}") + raise RuntimeError( + f"Operation {operation.name} failed to update Agent Engine: {operation.error}" + ) if agent_engine.api_resource.spec: self._register_api_methods(agent_engine=agent_engine) return agent_engine # type: ignore[no-any-return]