Skip to content

adk deploy agent_engine silently creates a duplicate Agent Runtime on every re-run; add a duplicate-display-name warning and an opt-in --update_if_exists #8061

Description

@hlzuo

Is your feature request related to a problem?

Without --agent_engine_id, every adk deploy agent_engine run creates a brand-new Agent Runtime (cli_deploy.py: if not resource_name: runtime = client.runtimes.create()). This happens even when an engine with the same display_name already exists in the project and region, and nothing warns about it. The only place this is documented is the --agent_engine_id flag help. The deploy guide (docs/deploy/agent-runtime/deploy.md) does not mention updating or --agent_engine_id at all.

Teams that redeploy from a shell script or CI without knowing about the flag accumulate orphan engines. They also have to propagate a new resource ID into their app config on every release, because the app breaks if it still points at the previous engine.

In one engagement we found 88 engines deployed with only 15 in use on one project, 37 deployed / 16 in use on a second, and 88 on a third. Another 93 were left in a region the team no longer uses: a missing region setting fell back to us-central1, so region-scoped cleanup never saw them.

To reproduce (google-adk 2.9.0; same code on main @ 2.14.0):

  1. adk deploy agent_engine --project P --region us-central1 --display_name my-agent ./my_agent prints Created a new instance: projects/P/locations/us-central1/reasoningEngines/111….
  2. Run the same command again. It prints Created a new instance: …/reasoningEngines/222…, with no warning.
  3. client.runtimes.list(config={"filter": 'display_name="my-agent"'}) returns 2 engines.

Expected: a re-run with the same display name either warns that it is about to create a duplicate, or can be told to update the existing engine in place.
Actual: a silent duplicate. The app keeps calling the old engine until someone copies the new ID over.

Describe the solution you'd like

  1. Warning (default behaviour unchanged): before runtimes.create(), list engines with the same display_name in the project and region. If any exist, print a warning that lists their resource names and update_time, with a hint to use --agent_engine_id or --update_if_exists. Best-effort: never fail the deploy if list fails.
  2. Opt-in --update_if_exists: with exactly 1 match, update it in place; with 0, create; with ≥2, fail with the ambiguous candidates listed. Mutually exclusive with --agent_engine_id. On a failed update of a pre-existing engine, do not delete it. Today the cleanup is keyed on agent_engine_id is None, which would delete it.
  3. Docs: a "Redeploy / update an existing agent" section in the Agent Runtime deploy guide, plus a cleanup recipe.
  4. (Nice to have) --output=json with resource_name and action: created|updated, so scripts don't have to regex stdout.

This matches what agents-cli deploy already does (deploy/agent_runtime.py _resolve_target_agent: recorded ID first, else an unambiguous display-name match). Agent Starter Pack's deploy.py does the same. adk deploy agent_engine is the only Google deploy path that duplicates by default.

The lookup has to run after display_name is final, i.e. after the .agent_engine_config.json merge (related: #7619 / #7620).

Describe alternatives you've considered

  • Always passing --agent_engine_id from a pinned ID map, plus a prune script that diffs the project against that map. This is our current workaround. It works, but every team has to rediscover the need for it and rebuild it.
  • Making upsert the default. Rejected because some users intentionally keep several engines with the same name.

Additional context

  • The server allows duplicate display names, and CreateReasoningEngineRequest has no user-specified ID, so idempotency has to come from the client (or from a separate API FR).
  • I'm happy to send the change. A sketch with tests is ready.

Activity

  1. added
    agent engine
    on Nov 12, 2026
  2. sanketpatil06 commented on Nov 12, 2026

    @sanketpatil06

    Hi @hlzuo, thank you for the feature request! Since you already have a solution in mind, please feel free to open a PR. Our team would be happy to review it.

  3. added
    needs review
    on Nov 12, 2026
  4. hlzuo commented on Nov 13, 2026

    @hlzuo
    Author

    Thanks @sanketpatil06. We have a CL for this (--update_if_exists, duplicate display_name warning, and the created_here cleanup guard) currently out for internal review with unit and live Agent Engine tests, which will mirror to main via Copybara with Fixes #8061. Holding off on a duplicate GitHub PR so reviewers don't review it twice, though happy to mirror a tracking PR if your triage flow needs one.

  5. added a commit that references this issue on Nov 24, 2026
    84cb074
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

agent engineneeds review

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions