Skip to content

feat(cli): Support custom service accounts for Agent Engine deploy - #6702

Open
a2105z wants to merge 1 commit into
google:mainfrom
a2105z:feat/agent-engine-service-account
Open

feat(cli): Support custom service accounts for Agent Engine deploy#6702
a2105z wants to merge 1 commit into
google:mainfrom
a2105z:feat/agent-engine-service-account

Conversation

@a2105z

@a2105z a2105z commented Aug 13, 2026

Copy link
Copy Markdown
Contributor

Summary

Implements custom runtime service account support for adk deploy agent_engine (#2951).

Why this is needed

Using a dedicated least-privilege service account is Cloud IAM best practice for Agent Engine. Today adk deploy agent_engine always falls back to the default Agent Engine service agent — there is no first-class CLI/config way to set the runtime identity that Vertex documents for Agent Engine deploy.

The Vertex Agent Engine SDK already accepts config.service_accountspec.service_account. ADK just never exposed it.

What we did

  • Added --service_account to adk deploy agent_engine
  • Accepted the same value from:
    • .agent_engine_config.json ("service_account": "...")
    • .env (GOOGLE_CLOUD_SERVICE_ACCOUNT=..., popped so it is not leaked into runtime env_vars)
  • Validated email format early with a clear error
  • Precedence: CLI > config file / .env (CLI wins)
  • Forwarded as top-level agent_config["service_account"] on client.agent_engines.update(...) (runtime identity — distinct from build_config.service_account used for Cloud Build)

How it fits

adk deploy agent_engine --service_account=my-agent@proj.iam.gserviceaccount.com
        │
        ▼
to_agent_engine(... service_account=...)
        │
        ▼
agent_config["service_account"] = <email>
        │
        ▼
vertexai.Client().agent_engines.update(config=agent_config)
        │
        ▼
Agent Engine runs as the custom runtime SA

Usage

adk deploy agent_engine \
  --project=my-project \
  --region=us-central1 \
  --service_account=my-agent@my-project.iam.gserviceaccount.com \
  my_agent

Or in .agent_engine_config.json:

{
  "service_account": "my-agent@my-project.iam.gserviceaccount.com"
}

Or in .env:

GOOGLE_CLOUD_SERVICE_ACCOUNT=my-agent@my-project.iam.gserviceaccount.com

Verification

  • Confirmed not previously implemented on main
  • Confirmed SDK mapping: config.service_accountspec.service_account
  • Unit tests for validation, CLI/config/.env sources, env-var non-leakage, and update-config forwarding
  • uv run pytest tests/unittests/cli/utils/test_cli_deploy.py60 passed

Fixes #2951

Test plan

  • Unit tests for _validate_service_account (valid + malformed)
  • Unit tests for _apply_service_account_to_agent_config (CLI, config, override)
  • to_agent_engine forwards service_account on agent_engines.update
  • .env GOOGLE_CLOUD_SERVICE_ACCOUNT is applied and not leaked into env_vars
  • CLI --service_account reaches to_agent_engine
  • Maintainer review of precedence / naming
  • Optional: end-to-end deploy with a custom SA in a GCP project

cc @yeesian @klateefa @wuliang229 @Jacksunwei @llalitkumarrr @GWeale

I claimed this on #2951 (self-assign needs triage permissions — please assign @a2105z if helpful). Ready for review.

@a2105z

a2105z commented Aug 13, 2026

Copy link
Copy Markdown
Contributor Author

Friendly ping for Agent Engine / CLI triage:

@yeesian @klateefa @wuliang229 @Jacksunwei @llalitkumarrr @GWeale — small focused follow-on in the Agent Engine deploy CLI for custom runtime service accounts (#2951). Happy to adjust naming or precedence if you prefer config-file-only / no .env support.

@adk-bot adk-bot added the cli [Component] This issue is related to cli label Aug 13, 2026
Enterprise deploys should use least-privilege runtime identities instead
of only the default Agent Engine service agent. Accept --service_account
(plus .env / config-file equivalents) and forward it as config.service_account.

Fixes google#2951
@a2105z
a2105z force-pushed the feat/agent-engine-service-account branch from 9155769 to 254aa02 Compare August 13, 2026 00:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cli [Component] This issue is related to cli

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add the ability to provide a custom service account email to "adk deploy agent_engine" command

3 participants