You've already forked adk-python
mirror of
https://github.com/encounter/adk-python.git
synced 2026-03-30 10:57:20 -07:00
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 <gweale@google.com> PiperOrigin-RevId: 838845022
This commit is contained in:
committed by
Copybara-Service
parent
0094eea3ca
commit
7edd7ea9b7
@@ -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:
|
||||
|
||||
Reference in New Issue
Block a user