Skip to content

Session State Leakage: Multiple Sessions Showing Accumulated Data #3513

Closed

Description

@soonho2

When switching from Session A to Session B in the same user id, Session B shows outputs (summaries, PDFs, GAMS files) from both sessions instead of only Session B. I tried to create a new runner per each call with fresh session_service like the below codes. But it doesn't work. I am not sure that it is an issue from ADK or an issue from the front end. Any advice or tips would be very appreciated. ( I have struggling with this issue for three days)

from google.adk.agents import SequentialAgent
from google.adk.runners import Runner
from google.adk.artifacts import GcsArtifactService
from google.adk.sessions import InMemorySessionService

from app.config import config

Import sub-agents

from app.sub_agents.scenario_faciliatator.agent import scenario_faciliatator
from app.sub_agents.resource_identifier.agent import resource_identifier
from app.sub_agents.input_data_maker.agent import input_data_maker
from app.sub_agents.input_data_zipper.agent import input_data_zipper
from app.sub_agents.model_runner.agent import model_runner
from app.sub_agents.summary_generator.agent import summary_generator
from app.sub_agents.pdf_report_generator.agent import pdf_report_generator

Import data discovery utility (optional - for future use)

from app.utils.data_discovery import get_data_summary, get_data_files_for_prompt

--- ROOT AGENT DEFINITION ---

root_agent = SequentialAgent(
name=config.internal_agent_name,
description="Manager agent for the RIAPA CGE model",
sub_agents=[
scenario_faciliatator,
resource_identifier,
input_data_maker,
input_data_zipper,
model_runner,
summary_generator,
pdf_report_generator,
],
)

def create_new_runner(root_agent, config):
"""
Creates a new, isolated Runner instance for a fresh session.
"""
# 1. New InMemorySessionService instance
# This automatically resets the state by starting fresh.
session_service = InMemorySessionService()

# New Runner instance using the fresh services
runner = Runner(
    agent=root_agent,
    app_name=config.internal_agent_name,
    session_service=session_service,
    artifact_service=GcsArtifactService(
        bucket_name=config.artifacts_bucket_name
    ),
)
return runner

current_runner = create_new_runner(root_agent, config)

Activity

  1. added
    services[Component] This issue is related to runtime services, e.g. sessions, memory, artifacts, etc
    on Nov 12, 2025
  2. added theissue type on Nov 12, 2025
  3. self-assigned this
    on Nov 13, 2025
  4. added
    core[Component] This issue is related to the core interface and implementation
    on Nov 19, 2025
  5. adk-bot commented on Dec 3, 2025

    @adk-bot
    Collaborator

    Notification: The author has updated the issue description. Maintainers, please review.

  6. surajksharma07 commented on Dec 11, 2025

    @surajksharma07
    Collaborator

    @soonho2 This isn't a bug—it's by design.

    list_artifact_keys() returns both session-scoped and user-scoped artifacts for cross-session persistence.

    Your sub-agents (pdf_report_generator, summary_generator, etc.) are likely saving artifacts without session_id or using the "user:" prefix, making them persist across sessions.

    Check your sub-agent code: ensure save_artifact() always receives session_id=context.session.id and filenames don't start with "user:".
    That will properly isolate sessions.

    Thanks!

  7. added
    answered[Status] This issue has been answered by the maintainer
    on Dec 11, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

answered[Status] This issue has been answered by the maintainercore[Component] This issue is related to the core interface and implementationservices[Component] This issue is related to runtime services, e.g. sessions, memory, artifacts, etc

Type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions