Deployment Guide
Deploy an ADK agent to Agent Runtime and optionally register it on Gemini Enterprise.
Content
Deployment Guide
Deploy an ADK agent to Agent Runtime and optionally register it on Gemini Enterprise.
Reference: Google Agents CLI
---
Prerequisites
- Python 3.11+
- Google Cloud SDK (
gcloudCLI) - A Google Cloud project with Agent Platform (Vertex AI) API enabled
- Python packages:
google-adk[vertexai],python-dotenv - (Optional)
google-agents-cli— required only for Gemini Enterprise registration
pip install "google-adk[vertexai]" python-dotenv
---
Step 1: Authenticate and set quota project
gcloud auth application-default login
gcloud auth application-default set-quota-project <YOUR_PROJECT_ID>
---
Step 2: Prepare the agent package
Agent Runtime uploads only the agent directory (the folder containing agent.py and __init__.py).
Key requirements:
requirements.txtmust exist inside the agent package directory (not the project root). Agent Runtime uses it to install dependencies in the container..envfile in the agent directory is auto-detected and deployed. Use it for runtime env vars (GOOGLE_CLOUD_PROJECT,GOOGLE_CLOUD_LOCATION, etc.). Alternatively, use--env_fileto point to a different file.- All imports must be relative (e.g.,
from .tools.tools import ...). Agent Runtime renames the package directory during deployment, which breaks absolute imports. - Minimize the
data/directory — any files inside the agent package are uploaded. Remove runtime outputs (logs, cache, temp files) before deploying. - Environment variable access must be lazy — Agent Runtime sets env vars *after* module import. Any
os.getenv()calls at module level will returnNone. Use a lazy initialization pattern (callos.getenv()inside a function on first use, not at import time).
.env file template
Create a .env file in the agent package directory:
GOOGLE_GENAI_USE_VERTEXAI=TRUE
GOOGLE_CLOUD_PROJECT=<YOUR_PROJECT_ID>
GOOGLE_CLOUD_LOCATION=<YOUR_REGION>
A.env.exampleis provided in the agent directory. Copy it to.envand fill in your values.
---
Step 3: Deploy to Agent Runtime
adk deploy agent_engine \
--project=<YOUR_PROJECT_ID> \
--region=<YOUR_REGION> \
--display_name="<AGENT_DISPLAY_NAME>" \
--description="<AGENT_DESCRIPTION>" \
<PATH_TO_AGENT_PACKAGE>
On success, the CLI outputs:
✅ Created agent engine: projects/<PROJECT_NUMBER>/locations/<REGION>/reasoningEngines/<RESOURCE_ID>
Save the <RESOURCE_ID> — you need it for updates and Gemini Enterprise registration.
---
Step 4: Update an existing deployment
To push changes without creating a new instance:
adk deploy agent_engine \
--project=<YOUR_PROJECT_ID> \
--region=<YOUR_REGION> \
--agent_engine_id=<RESOURCE_ID> \
<PATH_TO_AGENT_PACKAGE>
---
Step 5: Register on Gemini Enterprise (optional)
Requires google-agents-cli:
pip install google-agents-cli
Option A: Interactive (recommended)
agents-cli publish gemini-enterprise
The CLI will:
- Auto-detect the Agent Runtime ID from
deployment_metadata.json - List available Gemini Enterprise apps in your project
- Fetch the agent's display name and description
- Register the agent as a tool in Gemini Enterprise
- Print a console link to view the registered agent
Option B: Non-interactive
ID="projects/<PROJECT_NUMBER>/locations/global/collections/default_collection/engines/<GE_APP_ID>" \
AGENT_ENGINE_ID="projects/<PROJECT_NUMBER>/locations/<REGION>/reasoningEngines/<RESOURCE_ID>" \
GEMINI_DISPLAY_NAME="<AGENT_DISPLAY_NAME>" \
GEMINI_DESCRIPTION="<AGENT_DESCRIPTION>" \
agents-cli publish gemini-enterprise
Find your Gemini Enterprise App ID in the Google Cloud Console under Gemini Enterprise settings.
---
Step 6: Verify
- Console check: Open the Gemini Enterprise console and confirm your agent appears as an available tool
- Chat test: Select the agent and send a test message
- Logs: If something goes wrong, check Agent Runtime logs:
gcloud logging read \
"resource.type=aiplatform.googleapis.com/ReasoningEngine" \
--project=<YOUR_PROJECT_ID> \
--limit=20 \
--format="table(timestamp,textPayload)"
---
Updating configuration post-deployment
When rules, data files, or agent instructions change:
- Update the relevant files in the agent package
- Re-deploy using the update command (Step 4)
No need to re-register on Gemini Enterprise — the registration points to the Agent Runtime instance, which is updated in place.
---
Troubleshooting
"failed to start and cannot serve traffic"
| Cause | Fix | |-------|-----| | Missing requirements.txt in agent dir | Add requirements.txt inside the agent package directory | | Missing env vars | Ensure .env exists in the agent dir with GOOGLE_CLOUD_PROJECT and GOOGLE_CLOUD_LOCATION | | Large package size | Remove runtime outputs from data/ before deploying | | Absolute imports | Convert all imports to relative (. / ..) — Agent Runtime renames the package | | Module-level os.getenv() | Defer env var reads to call time using lazy initialization |
ADC quota warning
gcloud auth application-default set-quota-project <YOUR_PROJECT_ID>
---
Further Reading
Source and license
- Source
- Google Cloud Generative AI
- Original
- GoogleCloudPlatform/generative-ai/agents/invoice-processing/deployment
- License
- Apache-2.0