The `vertexai` extra does not exist in google-adk's pyproject.toml, so `pip install google-adk[vertexai]` silently installs the base package without the Agent Platform dependencies. Readers following these snippets hit an ImportError when constructing VertexAiSessionService or VertexAiMemoryBankService. The correct extra is `gcp`, which pulls in google-cloud-aiplatform[agent-engines]. Follow-up to review feedback on #2031, which flagged the two occurrences in express-mode.md. The same stale extra appears once in sessions/session/index.md, fixed here too. Co-authored-by: Shahin Saadati <happyhuman@users.noreply.github.com>
5.9 KiB
catalog_title, catalog_description, catalog_icon, catalog_tags
| catalog_title | catalog_description | catalog_icon | catalog_tags | |
|---|---|---|---|---|
| Agent Platform Express Mode | Try development with Agent Platform services at no cost | /integrations/assets/agent-platform.svg |
Google Cloud Agent Platform express mode for ADK
Google Cloud Agent Platform express mode provides a no-cost access tier for prototyping and development, allowing you to use Agent Platform services without creating a full Google Cloud Project. This service includes access to many powerful Agent Platform services, including:
You can sign up for an express mode account using a Google account and receive an API key to use with the ADK. Obtain an API key through the Google Cloud Console. For more information, see Agent Platform express mode.
!!! example "Preview release" The Agent Platform express mode feature is a Preview release. For more information, see the launch stage descriptions.
??? info "Agent Platform express mode limitations"
Agent Platform express mode projects are only valid for 90 days and only select
services are available to be used with limited quota. For example, the number of
Agent Runtime instances are restricted to 10 and deployment to Agent Runtime requires paid
access. To remove the quota restrictions and use all of Agent Platform's services,
add a billing account to your express mode project.
Configure Agent Runtime container
When using Agent Platform express mode, create an AgentEngine object to enable
Agent Platform management of agent components such as Session and Memory objects.
With this approach, Session objects are handled as children of the
AgentEngine object. Before running your agent make sure your environment
variables are set correctly, as shown below:
GOOGLE_GENAI_USE_ENTERPRISE=TRUE
GOOGLE_API_KEY=PASTE_YOUR_ACTUAL_EXPRESS_MODE_API_KEY_HERE
Next, create your Agent Runtime instance using the Agent Platform SDK.
-
Import Agent Platform SDK.
import vertexai from vertexai import agent_engines -
Initialize the Agent Platform Client with your API key and create an agent engine instance.
# Create Agent Runtime with Gen AI SDK client = vertexai.Client( api_key="YOUR_API_KEY", ) agent_engine = client.agent_engines.create( config={ "display_name": "Demo Agent Runtime", "description": "Agent Runtime for Session and Memory", }) -
Get the Agent Runtime name and ID from the response to use with Memories and Sessions.
APP_ID = agent_engine.api_resource.name.split('/')[-1]
Manage Sessions with VertexAiSessionService
VertexAiSessionService
is compatible with Agent Platform Express Mode API Keys. You can instead initialize
the session object without any project or location.
# Requires: pip install google-adk[gcp]
# Plus environment variable setup:
# GOOGLE_GENAI_USE_ENTERPRISE=TRUE
# GOOGLE_API_KEY=PASTE_YOUR_ACTUAL_EXPRESS_MODE_API_KEY_HERE
from google.adk.sessions import VertexAiSessionService
# The app_name used with this service should be the Reasoning Engine ID or name
APP_ID = "your-reasoning-engine-id"
# Project and location are not required when initializing with Agent Platform express mode
session_service = VertexAiSessionService(agent_engine_id=APP_ID)
# Use REASONING_ENGINE_APP_ID when calling service methods, e.g.:
# session = await session_service.create_session(app_name=APP_ID, user_id= ...)
!!! info "Session Service Quotas"
For Free express mode Projects, `VertexAiSessionService` has the following quota:
- 10 Create, delete, or update Agent Runtime sessions per minute
- 30 Append event to Agent Runtime sessions per minute
Manage Memory with VertexAiMemoryBankService
VertexAiMemoryBankService
is compatible with Agent Platform express mode API Keys. You can instead initialize
the memory object without any project or location.
# Requires: pip install google-adk[gcp]
# Plus environment variable setup:
# GOOGLE_GENAI_USE_ENTERPRISE=TRUE
# GOOGLE_API_KEY=PASTE_YOUR_ACTUAL_EXPRESS_MODE_API_KEY_HERE
from google.adk.memory import VertexAiMemoryBankService
# The app_name used with this service should be the Reasoning Engine ID or name
APP_ID = "your-reasoning-engine-id"
# Project and location are not required when initializing with express mode
memory_service = VertexAiMemoryBankService(agent_engine_id=APP_ID)
# Generate a memory from that session so the Agent can remember relevant details about the user
# memory = await memory_service.add_session_to_memory(session)
!!! info "Memory Service Quotas"
For Free express mode Projects, `VertexAiMemoryBankService` has the following quota:
- 10 Create, delete, or update Agent Runtime memory resources per minute
- 10 Get, list, or retrieve from Agent Runtime Memory Bank per minute
Code Sample: Weather Agent with Session and Memory
This code sample shows a weather agent that utilizes both
VertexAiSessionService and VertexAiMemoryBankService for context management,
allowing your agent to recall user preferences and conversations.
- Weather Agent with Session and Memory using Agent Platform express mode