Deploy an ADK agent to Agent Runtime and optionally register it on Gemini Enterprise.
Reference: Google Agents CLI
- Python 3.10+
- Google Cloud SDK (
gcloudCLI) - A GCP project with 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-dotenvgcloud auth application-default login
gcloud auth application-default set-quota-project <YOUR_PROJECT_ID>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 (PROJECT_ID,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).
Create a .env file in the agent package directory:
GOOGLE_GENAI_USE_VERTEXAI=TRUE
PROJECT_ID=<YOUR_PROJECT_ID>
GOOGLE_CLOUD_PROJECT=<YOUR_PROJECT_ID>
LOCATION=<YOUR_REGION>A
.env.exampleis provided in the agent directory. Copy it to.envand fill in your values.
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.
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>Requires google-agents-cli:
pip install google-agents-cliagents-cli publish gemini-enterpriseThe 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
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-enterpriseFind your Gemini Enterprise App ID in the Google Cloud Console under Gemini Enterprise settings.
- 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)"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.
| 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 PROJECT_ID and GOOGLE_CLOUD_PROJECT |
| 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 |
gcloud auth application-default set-quota-project <YOUR_PROJECT_ID>