Google Cloud Vertex AI Custom Agent Build Error: Cannot Find 'analytics_package' Module

Issue Description

I’m having trouble deploying my custom agent application on Google Cloud’s Vertex AI Reasoning Engine through the Agent Builder SDK. My setup uses a wheel package file that contains all my agent code under a package called analytics_package.

The wheel file has the right structure with all necessary modules:

analytics_package/main_agent.py
analytics_package/helper_agents/...

My Configuration:

  • Deployment uses agent_engines.create(...) with extra_packages = [wheel_path] and adk_app = AdkApp.from_module("analytics_package.main_agent", "primary_agent")
  • Wheel file stored at gs://my_bot_storage/packages/analytics_package-0.1-py3-none-any.whl
  • Storage permissions are working fine - the service account has proper access

The Error

When I try to deploy remotely, I get this error message:

Pickle load failed: Missing module. Service terminating. ModuleNotFoundError: No module named 'analytics_package'

This happens even though the wheel file definitely contains analytics_package/main_agent.py

My deployment code looks like this:

app_config = AdkApp.from_module(
    agent_module_name="analytics_package.main_agent",
    agent_object_name="primary_agent"
)

deployed_agent = agent_engines.create(
    app_config,
    extra_packages=[wheel_path],
    requirements=[
        "vertexai==1.43.0",
        "cloudpickle==3.0.0",
        "pydantic==2.11.3",
        "google-adk"
    ],
    env_vars=environment_vars,
    verbose=True
)

What I’ve Checked

  • The wheel installs fine locally when I test it
  • My GCS bucket path is correct and accessible
  • The package structure looks right when I examine the wheel contents
  • Vertex AI has the right permissions to read from my storage bucket

Questions

  • Why can’t Vertex AI locate my analytics_package module from the wheel file?
  • Are there special requirements for how the package should be structured for remote deployment?
  • How can I get more detailed logs about what happens during the deployment process?

I’ve hit this same issue with Vertex AI deployments. Try uploading your wheel to a public GCS bucket first - the service account auth can get wonky during deployment even when testing works fine. Also double-check you’re using the full gs:// path, not relative ones. Vertex is way pickier about paths than local installs.

I’ve hit this exact problem with Vertex AI deployments. It’s usually a timing issue - Vertex tries to import your module before the wheel gets installed properly.

Here’s what fixed it for me:

Option 1: Use requirements.txt approach

Ditch the extra_packages parameter and put your wheel in requirements instead:

requirements=[
    "vertexai==1.43.0",
    "cloudpickle==3.0.0", 
    "pydantic==2.11.3",
    "google-adk",
    "gs://my_bot_storage/packages/analytics_package-0.1-py3-none-any.whl"
]

Option 2: Package structure fix

Check if your wheel has an __init__.py file in the analytics_package directory. I’ve had wheels work locally but fail on Vertex AI because of missing init files.

Option 3: Delay import pattern

Change your main_agent.py to use lazy imports:

def get_primary_agent():
    # Import inside function after package is available
    from analytics_package.helper_agents import whatever
    return YourAgentClass()

primary_agent = get_primary_agent()

I usually go with option 1 - it’s the most reliable since the wheel gets installed before any imports happen.

For debugging, add verbose=True and check Cloud Logging. You’ll see the actual pip install logs there.

Had this exact nightmare a few months back. The problem is how Vertex AI loads modules during container startup. Even when your wheel’s accessible, there’s usually a race condition - pickle tries to deserialize before pip finishes installing your package. What fixed it for me: ditch runtime wheel installation and use a base image approach instead. I built a custom container image with analytics_package pre-installed, then referenced that in my deployment config. No more timing issues since the module’s already there when the container starts. Alternatively, fix your wheel by adding a proper setup.py with install_requires dependencies. This forces pip to handle installation order correctly. Your current wheel structure might be missing dependency metadata that Vertex AI needs for proper sequencing. For debugging right now: check the container logs in Cloud Run (that’s where Vertex AI actually deploys your agent). Error messages there are way more detailed than what you’ll see through the Agent Builder SDK.