Skip to content

Deprecated model alias (gemini-flash-latest) causes confusing 404 NOT_FOUND with no actionable guidance #6010

@pj0201

Description

@pj0201

Summary

When deploying an ADK application to Cloud Run (or any environment where a deprecated Gemini model alias is configured), all LlmAgent calls silently fail with a confusing 404 NOT_FOUND error that does not clearly indicate the root cause.

Environment

  • google-adk: 2.1.0
  • google-genai: latest
  • Platform: Google Cloud Run (asia-northeast1)
  • Python: 3.12

Steps to Reproduce

  1. Set GEMINI_MODEL=gemini-flash-latest in the environment (common in older ADK projects or tutorials that referenced this alias)
  2. Pass it to LlmAgent:
    MODEL = os.environ.get("GEMINI_MODEL", "gemini-flash-latest")
    agent = LlmAgent(name="MyAgent", model=MODEL, ...)
  3. Deploy to Cloud Run and invoke the agent

Actual Error

google.genai.errors.ClientError: 404 NOT_FOUND.
{'error': {'code': 404, 'message': 'This model models/gemini-2.0-flash is
no longer available. Please update your code to use a newer model for the
latest features and improvements.', 'status': 'NOT_FOUND'}}

Problem

The error message mentions models/gemini-2.0-flash — the resolved underlying model ID — but the user configured gemini-flash-latest. This disconnect makes diagnosis difficult:

  • The user sees gemini-2.0-flash in the error but never wrote that name anywhere
  • There is no hint that gemini-flash-latest is the problematic alias
  • The error surface is deep in the agent invocation chain, far from the configuration

This was particularly confusing during a hackathon where the app appeared to work locally (older cached responses / different routing) but failed 100% on Cloud Run.

Root Cause

gemini-flash-latest is a non-versioned alias that previously resolved to gemini-2.0-flash. Google has since deprecated gemini-2.0-flash (the specific model behind the alias), causing the alias to produce 404 errors.

Note: ADK 2.1.0 correctly uses DEFAULT_MODEL = 'gemini-2.5-flash' — the issue occurs when users explicitly pass an old alias via environment variable or hardcoded string.

Suggested Improvements

Option A — Startup validation warning
Before agent invocation, validate the model string against a known deprecated-alias list and emit a logging.warning:

DeprecationWarning: model alias 'gemini-flash-latest' is no longer available.
Please use 'gemini-2.5-flash' or a versioned model ID.

Option B — Improved error interception
Catch 404 NOT_FOUND errors from the Gemini API and re-raise with a user-friendly message:

ModelDeprecatedError: The model alias 'gemini-flash-latest' resolved to
'gemini-2.0-flash' which has been deprecated. Please update your model
configuration to 'gemini-2.5-flash'.

Option C — Documentation
Add a "Model Version Management" section to the ADK docs / README warning users against non-versioned aliases and recommending pinned model IDs.

Workaround

Replace any occurrence of gemini-flash-latest (or other non-versioned aliases) with a specific versioned model ID:

# Before (breaks silently when alias is deprecated)
MODEL = os.environ.get("GEMINI_MODEL", "gemini-flash-latest")

# After (stable, explicit)
MODEL = os.environ.get("GEMINI_MODEL", "gemini-2.5-flash")

This was discovered while building a multi-agent privacy tool (AI Shield Persona Agent) for the ADK Hackathon. Sharing in case it helps other hackathon participants and ADK users.

Metadata

Metadata

Labels

core[Component] This issue is related to the core interface and implementationrequest clarification[Status] The maintainer need clarification or more information from the authorv2Affects only 2.0 version

Type

No fields configured for Bug.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions