Skip to content

fix(deploy): add --agent_module flag to adk deploy agent_engine#5227

Open
RudrenduPaul wants to merge 5 commits intogoogle:mainfrom
RudrenduPaul:fix/agent-engine-configurable-module-name
Open

fix(deploy): add --agent_module flag to adk deploy agent_engine#5227
RudrenduPaul wants to merge 5 commits intogoogle:mainfrom
RudrenduPaul:fix/agent-engine-configurable-module-name

Conversation

@RudrenduPaul
Copy link
Copy Markdown

Fixes #5192

adk deploy agent_engine auto-generates agent_engine_app.py with a hardcoded from .agent import <object>. This assumes the user's entry point is always named agent.py. Any other filename (e.g. core.py, adk_agent.py) causes a ModuleNotFoundError at deployment time — silently, in the container build on Vertex AI, where it is hard to debug.

Changes

  • cli_deploy.py — Add agent_module: Optional[str] = None parameter to to_agent_engine(). Defaults to 'agent' for backward compatibility. Pass it through to _AGENT_ENGINE_APP_TEMPLATE and _validate_agent_import.
  • cli_deploy.py — Update _validate_agent_import to check {agent_module}.py instead of hardcoded agent.py, and improve the error message to reference --agent_module.
  • cli_tools_click.py — Add --agent_module CLI option to adk deploy agent_engine. Pass it through to to_agent_engine().

Usage

# Default behaviour unchanged
adk deploy agent_engine --project=my-project my_agent/

# Custom entry point
adk deploy agent_engine --project=my-project --agent_module=core my_agent/
adk deploy agent_engine --project=my-project --agent_module=adk_agent my_agent/

Backward compatibility

Default is agent, so all existing deployments continue to work without any changes.

Testing

Verified the generated agent_engine_app.py contains from .core import root_agent when --agent_module=core is passed, and from .agent import root_agent when the flag is omitted.

@google-cla
Copy link
Copy Markdown

google-cla bot commented Apr 9, 2026

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

@adk-bot adk-bot added the tools [Component] This issue is related to tools label Apr 9, 2026
@adk-bot
Copy link
Copy Markdown
Collaborator

adk-bot commented Apr 9, 2026

Response from ADK Triaging Agent

Hello @RudrenduPaul, thank you for your contribution!

It looks like the Contributor License Agreement (CLA) check has failed. Before we can proceed with reviewing this PR, could you please sign the CLA? You can find more information and sign it at https://cla.developers.google.com/.

Thanks!

@RudrenduPaul
Copy link
Copy Markdown
Author

I have read the CLA Document, and I hereby sign the CLA.

@RudrenduPaul
Copy link
Copy Markdown
Author

I have read the CLA Document and I hereby sign the CLA.

@RudrenduPaul RudrenduPaul reopened this Apr 9, 2026
The generated agent_engine_app.py hardcoded `from .agent import ...`,
breaking deployments where the entry point is not named agent.py
(e.g. core.py, adk_agent.py). Fixes google#5192.

Changes:
- Add `agent_module` param to `to_agent_engine()` (default: 'agent')
- Add `--agent_module` CLI option to `adk deploy agent_engine`
- Pass `agent_module` through to the app template and import validation
- Update error message in `_validate_agent_import` to reference the
  configurable module name and suggest --agent_module on failure

Built by Rudrendu Paul, developed with Claude Code
@RudrenduPaul RudrenduPaul force-pushed the fix/agent-engine-configurable-module-name branch from a1a6dee to d742c9e Compare April 9, 2026 10:10
@rohityan rohityan self-assigned this Apr 9, 2026
rohityan and others added 2 commits April 9, 2026 13:12
…n type

- Add missing agent_module key to test_agent_engine_app_template_compiles_with_windows_paths
  so the template.format() call includes all required variables
- Add -> None return annotation to cli_deploy_agent_engine to satisfy
  mypy strict [untyped-decorator] check

Built by Rudrendu Paul, developed with Claude Code
@RudrenduPaul
Copy link
Copy Markdown
Author

I have read the CLA document and signed it. It's shown as covered in the previous message.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

tools [Component] This issue is related to tools

Projects

None yet

Development

Successfully merging this pull request may close these issues.

adk deploy agent_engine fails on custom project structures due to hardcoded '.agent' import

3 participants