-
Environmentgoogle-cloud-aiplatform Problem DescriptionI'm encountering persistent ModuleNotFoundError: No module named 'agents' when deploying a multi-agent ADK system to Vertex AI Agent Engine, despite the code working perfectly locally. This appears related to #2044 but with additional complexity due to multi-agent architecture. Project Structure
The IssueTools in
The supervisor agent imports sub-agents:
Deployment Attempt
Error Log
What I've TriedDifferent extra_packages configurations:
sys.path manipulation (breaks cloudpickle serialization)
|
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
Response from ADK Answering Agent (experimental, answer may be inaccurate) TLDR: The most robust way to resolve this is to build your project into a standard Python wheel ( Hello @this-dave, thank you for the detailed question. This is a great question about Python packaging and deployment, which can be tricky. Here’s a breakdown of the issue and our recommended solution. The Problem: Python Path on Agent EngineWhen you run your code locally, your environment (like Poetry or your IDE) often adds your project's However, when you deploy to Vertex AI Agent Engine, the remote environment receives your code but doesn't automatically know about your specific project structure. It doesn't add The Solution: Package Your Code as a WheelThe Here is the recommended approach: 1. Configure Your [tool.setuptools.package-dir]
"" = "src"
[tool.setuptools.packages.find]
where = ["src"] 2. Build the Wheel From your project root, generate the wheel file. You can use # If you are using Poetry
poetry build
# Or using the standard 'build' package
# pip install build
python -m build --wheel This will create a 3. Update Your Deployment Script Now, modify your # deploy_agents.py
import os
# Assuming your script is in ops/scripts/
project_root = os.path.abspath(os.path.join(os.path.dirname(__file__), '..', '..'))
# NOTE: Update the wheel file name to match the one you generated.
wheel_path = os.path.join(project_root, 'dist', 'your_project_name-0.1.0-py3-none-any.whl')
remote_agent = agent_engines.create(
agent_engine=app,
requirements=AGENT_REQUIREMENTS,
# Pass the path to the built wheel file
extra_packages=[wheel_path],
display_name=f"supervisor-agent-{environment}",
# ...
) When you run this, Answering Your Other Questions
I hope this helps you resolve the deployment issue! Let us know if you have any other questions. |
Beta Was this translation helpful? Give feedback.
Response from ADK Answering Agent (experimental, answer may be inaccurate)
TLDR: The most robust way to resolve this is to build your project into a standard Python wheel (
.whl
) file and pass the path to that wheel in theextra_packages
argument ofagent_engines.create()
. This ensures youragents
andcore
modules are properly installed in the deployment environment.Hello @this-dave, thank you for the detailed question. This is a great question about Python packaging and deployment, which can be tricky. Here’s a breakdown of the issue and our recommended solution.
The Problem: Python Path on Agent Engine
When you run your code locally, your environment (like Poetry or your IDE) often add…