Skip to content

Commit b1378bb

Browse files
yifanyangcopybara-github
authored andcommitted
feat: surface the LRO name in Agent Engine create and update requests
PiperOrigin-RevId: 992557497
1 parent 4c045e1 commit b1378bb

3 files changed

Lines changed: 18 additions & 6 deletions

File tree

‎agentplatform/_genai/runtimes.py‎

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1913,6 +1913,7 @@ def create(
19131913
build_config=config.build_config,
19141914
)
19151915
operation = self._create(config=api_config)
1916+
logger.info(f"Create Agent Runtime backing LRO: {operation.name}")
19161917
reasoning_engine_id = _runtimes_utils._get_reasoning_engine_id(
19171918
operation_name=operation.name
19181919
)
@@ -1943,7 +1944,9 @@ def create(
19431944
f"runtime=client.runtimes.get(name='{runtime.api_resource.name}')"
19441945
)
19451946
elif operation.error:
1946-
raise RuntimeError(f"Failed to create Agent Runtime: {operation.error}")
1947+
raise RuntimeError(
1948+
f"Operation {operation.name} failed to create Agent Runtime: {operation.error}"
1949+
)
19471950
else:
19481951
logger.warning("The operation returned an empty response.")
19491952
if not self._is_lightweight_creation(agent, config):
@@ -2719,6 +2722,7 @@ def update(
27192722
build_config=config.build_config,
27202723
)
27212724
operation = self._update(name=name, config=api_config)
2725+
logger.info(f"Update Agent Runtime backing LRO: {operation.name}")
27222726
reasoning_engine_id = _runtimes_utils._get_reasoning_engine_id(
27232727
resource_name=name
27242728
)
@@ -2743,7 +2747,9 @@ def update(
27432747
f"runtime=client.runtimes.get(name='{runtime.api_resource.name}')"
27442748
)
27452749
elif operation.error:
2746-
raise RuntimeError(f"Failed to update Agent Runtime: {operation.error}")
2750+
raise RuntimeError(
2751+
f"Operation {operation.name} failed to update Agent Runtime: {operation.error}"
2752+
)
27472753
if runtime.api_resource.spec:
27482754
self._register_api_methods(runtime=runtime)
27492755
return runtime # type: ignore[no-any-return]

‎tests/unit/agentplatform/genai/test_agent_engines.py‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4167,7 +4167,7 @@ def test_create_runtime_error(
41674167
env_vars=_TEST_AGENT_ENGINE_ENV_VARS_INPUT,
41684168
),
41694169
)
4170-
assert "Failed to create agent engine" in str(excinfo.value)
4170+
assert "failed to create Agent Runtime" in str(excinfo.value)
41714171

41724172
@mock.patch.object(_runtimes_utils, "_await_operation")
41734173
def test_update_runtime_description(self, mock_await_operation):
@@ -4185,7 +4185,7 @@ def test_update_runtime_description(self, mock_await_operation):
41854185
description=_TEST_AGENT_ENGINE_DESCRIPTION,
41864186
),
41874187
)
4188-
assert "Failed to update agent engine" in str(excinfo.value)
4188+
assert "failed to update Agent Runtime" in str(excinfo.value)
41894189

41904190
@pytest.mark.parametrize(
41914191
"test_case_name, test_operation_schemas, want_log_output",

‎vertexai/_genai/agent_engines.py‎

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2008,6 +2008,7 @@ def create(
20082008
build_config=config.build_config,
20092009
)
20102010
operation = self._create(config=api_config)
2011+
logger.info(f"Create Agent Engine backing LRO: {operation.name}")
20112012
reasoning_engine_id = _agent_engines_utils._get_reasoning_engine_id(
20122013
operation_name=operation.name
20132014
)
@@ -2038,7 +2039,9 @@ def create(
20382039
f"agent_engine=client.agent_engines.get(name='{agent_engine.api_resource.name}')"
20392040
)
20402041
elif operation.error:
2041-
raise RuntimeError(f"Failed to create Agent Engine: {operation.error}")
2042+
raise RuntimeError(
2043+
f"Operation {operation.name} failed to create Agent Engine: {operation.error}"
2044+
)
20422045
else:
20432046
logger.warning("The operation returned an empty response.")
20442047
if not self._is_lightweight_creation(agent, config):
@@ -2820,6 +2823,7 @@ def update(
28202823
build_config=config.build_config,
28212824
)
28222825
operation = self._update(name=name, config=api_config)
2826+
logger.info(f"Update Agent Engine backing LRO: {operation.name}")
28232827
reasoning_engine_id = _agent_engines_utils._get_reasoning_engine_id(
28242828
resource_name=name
28252829
)
@@ -2844,7 +2848,9 @@ def update(
28442848
f"agent_engine=client.agent_engines.get(name='{agent_engine.api_resource.name}')"
28452849
)
28462850
elif operation.error:
2847-
raise RuntimeError(f"Failed to update Agent Engine: {operation.error}")
2851+
raise RuntimeError(
2852+
f"Operation {operation.name} failed to update Agent Engine: {operation.error}"
2853+
)
28482854
if agent_engine.api_resource.spec:
28492855
self._register_api_methods(agent_engine=agent_engine)
28502856
return agent_engine # type: ignore[no-any-return]

0 commit comments

Comments
 (0)