Skip to content

Bug: Unable to create session for Agent Engine deployment when deploying with event compaction/context caching #3715

@juszzz

Description

@juszzz

Describe the bug
When trying to create a session after deploying an agent with event compaction and/or context caching (which requires creating an App that gets passed to AdkApp), session creation fails due to an invalid app_name. This seems to occur because Pydantic expects you to supply a name when creating an App (note that the problem will occur even if you set name=None), however this name is not a valid reasoning engine resource name (e.g., projects/1234567/locations/us-central1/reasoningEngines/456789) and so attempts to create a session fail.

To Reproduce

  1. Deploy an agent to Agent Engine using an App to configure event compaction and/or context caching:

    app = google.adk.apps.App(
        root_agent=my_agent,
        name="my_agent_name",
        events_compaction_config=EventsCompactionConfig(),
        context_cache_config=ContextCacheConfig(),
    )
    
    adk_app = vertexai.agent_engines.AdkApp(
        app=app,
        enable_tracing=False,
    )
    
    vertexai.agent_engines.create(
        agent_engine=adk_app,
        ...
    )
    
  2. Attempt to create a session:

    remote_agent: vertexai.agent_engines.AgentEngine = agent_engines.get(resource_name="projects/12345/...")
    remote_session = await remote_agent.async_create_session(user_id="my_user_id")
    

Actual behavior
The async_create_session() call fails with the error message:

Error Details: {"detail":"Agent Engine Error: An error occurred during invocation. Exception: App name my_agent_name is not valid. It should either be the full ReasoningEngine resource name, or the reasoning engine id.\nRequest Data: {'user_id': 'my_user_id'}"}"

Expected behavior
A session is successfully created, with Agent Engine supplying the necessary resource name as-needed in order for session creation to occur.

Desktop (please complete the following information):

  • OS: macOS
  • Python version(python -V): 3.11
  • ADK version(pip show google-adk): 1.18.0

Model Information:

  • Are you using LiteLLM: No
  • Which model is being used: N/A

Additional context
Add any other context about the problem here.

Metadata

Metadata

Assignees

No one assigned

    Labels

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

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions