Skip to content

GetSessionConfig ignored in A2aAgentExecutor._prepare_session() #6410

Description

@vnykdfd

Environment

  • ADK Version: 2.4.0 (latest main branch)
  • Python: 3.10-3.14
  • Operating System: All platforms
  • Component: [Component] a2a

Bug Description

_prepare_session() in A2aAgentExecutor ignores GetSessionConfig(num_recent_events=N) by not forwarding it to session_service.get_session(), causing the entire event history to be loaded instead of respecting the configured limit.

Reproduction Steps

from google.adk.agents.run_config import RunConfig
from google.adk.sessions.base_session_service import GetSessionConfig
from google.adk.a2a.executor.a2a_agent_executor import A2aAgentExecutor

# Configure to load only 10 recent events
run_config = RunConfig(
    get_session_config=GetSessionConfig(num_recent_events=10)
)

# When A2A request is processed:
# _prepare_session() calls get_session() WITHOUT config parameter
# Result: ALL events loaded (e.g., 291 events instead of 10)

Expected Behavior

Session service should load at most 10 events when num_recent_events=10 is configured.

Observed Behavior

Session service loads ALL events regardless of get_session_config setting, causing:

  • 10-100x more database I/O than configured
  • 200-300ms added latency per request (observed in production)
  • Higher memory usage (~300KB vs ~10KB)
  • Higher token costs (sending excessive context to LLM)

Root Cause

File: src/google/adk/a2a/executor/a2a_agent_executor.py
Function: _prepare_session() (lines 310-339)

Line 320 calls session_service.get_session() without passing config=:

# CURRENT (BUG)
session = await runner.session_service.get_session(
    app_name=runner.app_name,
    user_id=user_id,
    session_id=session_id,
    # ← Missing: config=get_session_config
)

Proposed Solution

Extract get_session_config from run_request.run_config and forward it:

# FIX
get_session_config = None
if run_request.run_config:
    get_session_config = run_request.run_config.get_session_config

session = await runner.session_service.get_session(
    app_name=runner.app_name,
    user_id=user_id,
    session_id=session_id,
    config=get_session_config,  # ← ADDED
)

Impact

  • Severity: High for production A2A agents with chat mode
  • Affected Users: Anyone using A2A protocol with session history and GetSessionConfig
  • Workaround: None (config is silently ignored)

Willingness to Contribute

Yes, I have a fix ready with:

  • 4-line code change
  • 3 new unit tests
  • All 372 A2A tests passing
  • Pre-commit hooks passing

I will submit a PR shortly.

Additional Context

This only affects the legacy A2aAgentExecutor path. The newer _A2aAgentExecutor implementation doesn't have this issue.

Metadata

Metadata

Labels

a2a[Component] This issue is related a2a support inside ADK.request clarification[Status] The maintainer need clarification or more information from the author

Type

Fields

No fields configured for Bug.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions