Skip to content

Add explicit ttl / expire_time parameter to AdkApp.async_create_session for remote Agent Engine deployments #4594

@ivanparra-servi

Description

@ivanparra-servi

Feature request

Problem

When interacting with a deployed ADK agent via the Vertex AI SDK (client.agent_engines.get()), there is no documented or explicit way to set a session TTL through adk_app.async_create_session().

The current signature is:

async_create_session(*, user_id, session_id=None, state=None, **kwargs)

While VertexAiSessionService.create_session() does support expire_time via **kwargs (which merges them into the config dict), this only works in the local execution path. When calling async_create_session on a remote AgentEngine instance (obtained via client.agent_engines.get()), the call goes through a REST proxy (reasoningEngines/{id}:query), and there is no guarantee or documentation that arbitrary kwargs like expire_time or ttl are forwarded correctly to the server-side session service.

As a result, to set session TTL on a deployed agent, users must bypass adk_app.async_create_session() entirely and use the lower-level Sessions API:

session = client.agent_engines.sessions.create(
    name=agent_resource_name,
    user_id=user_id,
    config={"expire_time": "7200s"},
)
session_id = session.name.split("/")[-1]

This works but breaks the consistency of the adk_app.* API surface and requires mixing two different APIs (adk_app for querying, client.agent_engines.sessions for session creation).

"Solution"

Add explicit ttl and/or expire_time parameters to AdkApp.async_create_session():

session = await adk_app.async_create_session(
    user_id="user_123",
    ttl="7200s",          # Session auto-deletes after 2 hours
    # or
    expire_time="2026-03-01T00:00:00Z",  # Session expires at this time
)

This should work both locally (direct call) and remotely (through the REST proxy), ensuring the TTL parameter is included in the serialized input payload and properly forwarded to the underlying VertexAiSessionService.

Alts

  1. Using **kwargs pass-through: adk_app.async_create_session(user_id="u_123", expire_time="7200s"). This works locally because VertexAiSessionService.create_session() merges kwargs into config. However, it's undocumented for the remote proxy path and may silently fail (session created without TTL).

  2. Using the Sessions API directly: client.agent_engines.sessions.create(config={"expire_time": "7200s"}). This works but requires mixing two API surfaces and wrapping the synchronous call in asyncio.to_thread() for async backends.

Additional context

  • The Manage sessions with ADK documentation shows TTL support via VertexAiSessionService.create_session(ttl=...) but not via AdkApp.async_create_session().
  • The Use an ADK agent documentation does not mention TTL at all for the remote adk_app API.
  • Source reference: VertexAiSessionService.create_session already documents expire_time in its kwargs docstring, but this is not surfaced through AdkApp.

Metadata

Metadata

Assignees

No one assigned

    Labels

    agent engine[Component] This issue is related to Vertex AI Agent Engine

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions