Skip to content

Gemini Enterprise generates unique Session IDs for every request to Agent Engine #4510

@OrenRosen

Description

@OrenRosen

🔴 Required Information

Describe the Bug:
I'm not sure if it is a bug or expected behavior, (or an issue of Gemini Enterprise), but I've noticed that when Gemini Enterprise interacts with an ADK agent which is deployed to agent engine, every turn of a single conversation is with another session id. The impact is the the state isn't preserved during a conversation.

Steps to Reproduce:

  1. Deploy a pure ADK agent to Agent Engine. Can be the basic example from the agent-start-pack
  2. Connect the agent to gemini enterprise app
  3. Start a conversation in gemini enterprise. Have at least couple a messages in the same conversation (more then one turn)
  4. Notice in the traces tab in agent engine, that for each message, there is a new session id

Expected Behavior:
I would expect that all message within a single conversation will be under the same session id. When tested from the playground, it behaved like this.
Observed Behavior:
Each message from Gemini Enterprise towords the agent in the agent engine, caused the ADK to open a new session

Environment Details:

  • ADK Library Version (pip show google-adk): tried it on 1.21.0 and 1.25.0, happens in both
  • Desktop OS:** [e.g., macOS, Linux, Windows] na
  • Python Version (python -V): ">=3.10, <3.14"

Model Information:

  • Are you using LiteLLM: No

Screenshots / Video:

Traces Tab:

Image

Example with ADK:

I've installed the 'uvx agent-starter-pack create` command, and replaced the agent.py with this code

def work(tool_context: ToolContext):
    if get_dry_run(tool_context):
        return "Dry run is enabled. I won't work. Let the user know"

    """Starts working."""

    return "Worked Successfully."

def get_dry_run(tool_context: ToolContext):
    """
    Gets the is_dry_run flag from the tool context state.
    
    """

    if 'is_dry_run' not in tool_context.state:
        return False

    if tool_context.state['is_dry_run'] == 'true':
        return True
    else:
        return False


def set_dry_run(tool_context: ToolContext, is_dry_run: bool):
    """Sets the is_dry_run flag in the tool context state."""
    if is_dry_run:
        tool_context.state['is_dry_run'] = 'true'
    else:
        tool_context.state['is_dry_run'] = 'false'

    return f"Dry run was set to: {is_dry_run}"

root_agent = Agent(
    name="root_agent",
    model=Gemini(
        model="gemini-3-flash-preview",
        retry_options=types.HttpRetryOptions(attempts=3),
    ),
    instruction="""
    You are a helpful agent that can help the user with their tasks.
    You hace access to the following tools:
    - get_dry_run: Gets the dry run flag.
    - set_dry_run: Sets the dry run flag.
    - work: Start work. If the user asks you to start working, you should use this tool no matter what the dry run flag is.
    """,
    tools=[get_dry_run, set_dry_run, work],
)

app = App(
    root_agent=root_agent,
    name="app",
)

When talking with the agent via the playground, you can see that the state is preserved:

Image

When talking with the agent via Gemini Enterprise, you can note that is doesn't:

Image

** Additional context**
While the Gemini Enterprise browser URL remains constant (.../session/1623...), the backend calls result in a new UUID-based session_id for every turn, as verified in the Agent Engine Traces

How often has this issue occurred?:

  • Always (100%)

Metadata

Metadata

Assignees

No one assigned

    Labels

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

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions