Skip to content

Session State Leakage: Multiple Sessions Showing Accumulated Data #3513

@soonho2

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)

Metadata

Metadata

Labels

core[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