Skip to content

Agent Engine Session / Memory URI Construction Incorrectly Relies on GOOGLE_CLOUD_LOCATION #1760

Description

@eliasecchig

Affected Files:

Description:
When constructing the Agent Engine session URI, the ADK fast_api.py module incorrectly assumes that the Agent Engine's location can be reliably derived from os.environ["GOOGLE_CLOUD_LOCATION"]. This assumption leads to issues when the default global region (often associated with Gemini, which uses GOOGLE_CLOUD_LOCATION as a default) does not match the specific region where the Agent Engine session or memory is actually deployed.

Context:
This issue was identified during the integration of AE Managed sessions into Cloud Run ADK deployments.

Current Behavior:
The current implementation implicitly uses os.environ["GOOGLE_CLOUD_LOCATION"] to build parts of the session_service_uri. This forces developers to manually extract the Agent Engine's bare ID from its full resource name when trying to use it, like so:

agent_engine = agent_engines.create(display_name=agent_name)
session_service_uri = f"agentengine://{agent_engine.resource_name.split('/')[-1]}"

Expected Behavior:
ADK should allow developers to directly pass the full Agent Engine resource name (e.g., projects/PROJECT_ID/locations/LOCATION/agents/AGENT_ID) to the session_service_uri without relying on os.environ["GOOGLE_CLOUD_LOCATION"] for its internal construction.

Ideally, the code should allow:

session_service_uri = f"agentengine://{agent_engine.resource_name}"

And fetch the location from the full ID

Proposed Solution:
Modify the fast_api.py module (specifically around lines 293 and 311) to accept and utilize the full Agent Engine resource name when constructing the session_service_uri, rather than attempting to derive parts of it from os.environ["GOOGLE_CLOUD_LOCATION"].

Activity

  1. eliasecchig commented on Jul 2, 2025

    @eliasecchig
    Author
  2. added
    core
    on Jul 2, 2025
  3. changed the title [-]Agent Engine Session URI Construction Incorrectly Relies on `GOOGLE_CLOUD_LOCATION`[/-] [+]Agent Engine Session / Memory URI Construction Incorrectly Relies on `GOOGLE_CLOUD_LOCATION`[/+] on Jul 9, 2025
  4. added
    services
    and removed
    core
    on Jul 11, 2025
  5. added
    wip
    on Jul 17, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

serviceswip

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions