fix(a2a): forward get_session_config in _prepare_session()#6412
Open
vnykdfd wants to merge 2 commits into
Open
fix(a2a): forward get_session_config in _prepare_session()#6412vnykdfd wants to merge 2 commits into
vnykdfd wants to merge 2 commits into
Conversation
Add 3 unit tests to verify _prepare_session() forwards get_session_config: - test_prepare_session_passes_get_session_config - test_prepare_session_none_run_config - test_prepare_session_no_get_session_config Also update existing tests to use RunConfig() instances instead of Mock(spec=RunConfig) which doesn't expose Pydantic v2 fields.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Link to Issue
Closes: #6410
Problem Description
Environment
Bug Summary
_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
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.Root Cause
_prepare_session()(line 320-324) callssession_service.get_session()without passingconfig=parameter:Impact
For sessions with hundreds of events:
Solution
Extract
get_session_configfromrun_request.run_configand forward it tosession_service.get_session():Testing Plan
Unit Tests Added
test_prepare_session_passes_get_session_config- Verifies config is forwarded correctlytest_prepare_session_none_run_config- Handlesrun_config=Nonegracefullytest_prepare_session_no_get_session_config- Handles missingget_session_configTest Results
Local pytest (Python 3.13):
$ pytest tests/unittests/a2a/executor/test_a2a_agent_executor.py -v ==================== 29 passed, 1 skipped in 1.50s ====================Full A2A test suite:
$ pytest tests/unittests/a2a/ -v ==================== 372 passed, 17 skipped in 2.54s ====================Pre-commit hooks:
Manual E2E Verification
Reproduction script confirms the fix works (script available on request).
Changes Made
Files Modified
src/google/adk/a2a/executor/a2a_agent_executor.py (+4 lines)
get_session_configfrom run requestsession_service.get_session(config=...)tests/unittests/a2a/executor/test_a2a_agent_executor.py (+103 insertions, -14 deletions)
Mock(spec=RunConfig)withRunConfig()instances(Pydantic v2 fields not accessible via class-level Mock spec)
Backward Compatibility
✅ Fully backward compatible - no breaking changes
✅ Existing behavior unchanged when
get_session_configisNone✅ All 372 A2A tests pass
Checklist
Additional Context
This bug only affects the legacy
A2aAgentExecutorpath. The newer_A2aAgentExecutorimplementation already handles session loading more efficiently by passingnum_recent_events=0during existence checks.Tested locally on Python 3.13. CI will verify compatibility with Python 3.10-3.14.