Skip to content

Commit 7edd7ea

Browse files
ishanrajsinghGWeale
authored andcommitted
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: #2941 Co-authored-by: George Weale <gweale@google.com> PiperOrigin-RevId: 838845022
1 parent 0094eea commit 7edd7ea

File tree

1 file changed

+14
-5
lines changed

1 file changed

+14
-5
lines changed

src/google/adk/memory/vertex_ai_memory_bank_service.py

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -48,14 +48,15 @@ def __init__(
4848
Args:
4949
project: The project ID of the Memory Bank to use.
5050
location: The location of the Memory Bank to use.
51-
agent_engine_id: The ID of the agent engine to use for the Memory Bank.
51+
agent_engine_id: The ID of the agent engine to use for the Memory Bank,
5252
e.g. '456' in
53-
'projects/my-project/locations/us-central1/reasoningEngines/456'.
53+
'projects/my-project/locations/us-central1/reasoningEngines/456'. To
54+
extract from api_resource.name, use:
55+
``agent_engine.api_resource.name.split('/')[-1]``
5456
express_mode_api_key: The API key to use for Express Mode. If not
5557
provided, the API key from the GOOGLE_API_KEY environment variable will
56-
be used. It will only be used if GOOGLE_GENAI_USE_VERTEXAI is true.
57-
Do not use Google AI Studio API key for this field. For more details,
58-
visit
58+
be used. It will only be used if GOOGLE_GENAI_USE_VERTEXAI is true. Do
59+
not use Google AI Studio API key for this field. For more details, visit
5960
https://cloud.google.com/vertex-ai/generative-ai/docs/start/express-mode/overview
6061
"""
6162
self._project = project
@@ -65,6 +66,14 @@ def __init__(
6566
project, location, express_mode_api_key
6667
)
6768

69+
if agent_engine_id and '/' in agent_engine_id:
70+
logger.warning(
71+
"agent_engine_id appears to be a full resource path: '%s'. "
72+
"Expected just the ID (e.g., '456'). "
73+
"Extract the ID using: agent_engine.api_resource.name.split('/')[-1]",
74+
agent_engine_id,
75+
)
76+
6877
@override
6978
async def add_session_to_memory(self, session: Session):
7079
if not self._agent_engine_id:

0 commit comments

Comments
 (0)