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.
Environment
Bug Description
_prepare_session()inA2aAgentExecutorignoresGetSessionConfig(num_recent_events=N)by not forwarding it tosession_service.get_session(), causing the entire event history to be loaded instead of respecting the configured limit.Reproduction Steps
Expected Behavior
Session service should load at most 10 events when
num_recent_events=10is configured.Observed Behavior
Session service loads ALL events regardless of
get_session_configsetting, causing:Root Cause
File:
src/google/adk/a2a/executor/a2a_agent_executor.pyFunction:
_prepare_session()(lines 310-339)Line 320 calls
session_service.get_session()without passingconfig=:Proposed Solution
Extract
get_session_configfromrun_request.run_configand forward it:Impact
GetSessionConfigWillingness to Contribute
Yes, I have a fix ready with:
I will submit a PR shortly.
Additional Context
This only affects the legacy
A2aAgentExecutorpath. The newer_A2aAgentExecutorimplementation doesn't have this issue.