From 7edd7ea9b77fa19433f1e04a7eefccb47ab08b02 Mon Sep 17 00:00:00 2001 From: Ishan Raj Singh Date: Mon, 1 Dec 2025 10:51:07 -0800 Subject: [PATCH] chore: Add warning for full resource path in VertexAiMemoryBankService agent_engine_id This change updates the docstring for `agent_engine_id` to clarify that only the resource ID is expected. It also adds a warning log if the provided `agent_engine_id` contains a '/' character, suggesting it might be a full resource path, and provides guidance on how to extract the ID. Unit tests are added to verify the warning behavior. Merge: https://github.com/google/adk-python/pull/2941 Co-authored-by: George Weale PiperOrigin-RevId: 838845022 --- .../memory/vertex_ai_memory_bank_service.py | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/src/google/adk/memory/vertex_ai_memory_bank_service.py b/src/google/adk/memory/vertex_ai_memory_bank_service.py index b8f434c5..5df012e0 100644 --- a/src/google/adk/memory/vertex_ai_memory_bank_service.py +++ b/src/google/adk/memory/vertex_ai_memory_bank_service.py @@ -48,14 +48,15 @@ class VertexAiMemoryBankService(BaseMemoryService): Args: project: The project ID of the Memory Bank to use. location: The location of the Memory Bank to use. - agent_engine_id: The ID of the agent engine to use for the Memory Bank. + agent_engine_id: The ID of the agent engine to use for the Memory Bank, e.g. '456' in - 'projects/my-project/locations/us-central1/reasoningEngines/456'. + 'projects/my-project/locations/us-central1/reasoningEngines/456'. To + extract from api_resource.name, use: + ``agent_engine.api_resource.name.split('/')[-1]`` express_mode_api_key: The API key to use for Express Mode. If not provided, the API key from the GOOGLE_API_KEY environment variable will - be used. It will only be used if GOOGLE_GENAI_USE_VERTEXAI is true. - Do not use Google AI Studio API key for this field. For more details, - visit + be used. It will only be used if GOOGLE_GENAI_USE_VERTEXAI is true. Do + not use Google AI Studio API key for this field. For more details, visit https://cloud.google.com/vertex-ai/generative-ai/docs/start/express-mode/overview """ self._project = project @@ -65,6 +66,14 @@ class VertexAiMemoryBankService(BaseMemoryService): project, location, express_mode_api_key ) + if agent_engine_id and '/' in agent_engine_id: + logger.warning( + "agent_engine_id appears to be a full resource path: '%s'. " + "Expected just the ID (e.g., '456'). " + "Extract the ID using: agent_engine.api_resource.name.split('/')[-1]", + agent_engine_id, + ) + @override async def add_session_to_memory(self, session: Session): if not self._agent_engine_id: