-
Notifications
You must be signed in to change notification settings - Fork 3.2k
adk deploy agent_engine fails on custom project structures due to hardcoded '.agent' import #5192
Description
Describe the Bug:
In ADK 2.0.0a2, the adk deploy agent_engine command copies the contents of the target directory into a temporary build context. However, the auto-generated agent_engine_app.py uses a hardcoded import: from .agent import root_agent. This assumes the user has strictly named their entry point agent.py or has an agent/init.py package at the root of their source directory. If the user's project is structured differently, the relative import fails, resulting in a ModuleNotFoundError during Vertex AI deployment.
Steps to Reproduce:
Please provide a numbered list of steps to reproduce the behavior:
Initialize an ADK project where the main agent code is in a custom-named file (e.g., core.py or adk_agent.py) instead of agent.py.
Do not include a root-level agent/init.py module.
Run the deployment command: adk deploy agent_engine
Observe the build/deployment logs in GCP.
Expected Behavior:
The deployment utility should either respect the user's project structure by dynamically updating agent_engine_app.py to import from the correct entry point, or the documentation should strictly mandate the required agent module structure.
Observed Behavior:
The deployment fails during the container build/initialization phase. The generated agent_engine_app.py attempts to execute from .agent import root_agent, but because the staging directory does not contain an agent.py or agent/ folder, Python throws a ModuleNotFoundError.
Environment Details:
ADK Library Version (pip show google-adk): 2.0.0a2
Desktop OS: macOS (Apple Silicon)
Python Version (python -V): 3.11.x
Model Information:
Are you using LiteLLM: N/A (Deployment infrastructure issue, independent of model)
Which model is being used: N/A
🟡 Optional Information
Providing this information greatly speeds up the resolution process.
Regression:
N/A - This appears to be a bug in the new Agent Engine deployment abstraction.
Logs:
Please attach relevant logs. Wrap them in code blocks (```) or attach a text file.
Plaintext
Traceback (most recent call last):
File ".../agent_engine_app.py", line X, in
from .agent import root_agent
ModuleNotFoundError: No module named 'agent'
Screenshots / Video:
If applicable, add screenshots or screen recordings to help explain
your problem.
Additional Context:
Add any other context about the problem here.
Minimal Reproduction Code:
Please provide a code snippet or a link to a Gist/repo that isolates the issue.
// Code snippet hereHow often has this issue occurred?:
- Always (100%)
- Often (50%+)
- Intermittently (<50%)
- Once / Rare