feat(runners): Add get_session_config property to RunConfig
Please ensure you have read the contribution guide before creating a pull request.
Link to Issue or Description of Change
1. Link to an existing issue (if applicable):
- Closes: https://github.com/google/adk-python/issues/3562
Problem:
Currenlty, there is no way to limit the number of events fetched from the session store when using Runner.run_async method. In some cases, this could cause to fetch a large num. of events from the session store.
Solution:
The BaseSessionService.get_session method accepts a config parameter of type GetSessionConfig. But this is not used inside Runner.run_async. This PR updates RunConfig to include an optional field to pass a GetSessionConfig object and use it in run_async, run_debug & run_live.
Testing Plan
Added new unit tests to verify that new optional field is properly passed down when calling get_session from Runner.
Unit Tests:
- [x] I have added or updated unit tests for my change.
- [x] All unit tests pass locally.
Please include a summary of passed pytest results.
Manual End-to-End (E2E) Tests:
- Create a simple agent.
- Use
SqliteSessionServiceas the session service. - When running the agent using
Runner.run_async, pass aRunConfigincluding aget_session_config. - Use this patch and test the agent with debug logs enabled for
aiosqlitepackage. - You would see that the SQL statement executed has a
LIMITclause matching the config you passed.
2025-11-22 16:19:16,321 - aiosqlite - DEBUG - operation functools.partial(<bound method Connection._execute_fetchall of <Connection(Thread-2, started 19364)>>, 'SELECT event_data FROM events WHERE app_name=? AND user_id=? AND session_id=? AND timestamp >= ? ORDER BY timestamp DESC LIMIT ?', ['jokes_agent', 'nimantha', '9789', 1763788716.0, 2]) completed
If you want a quick setup to test this change, I have a GitHub repo here.
Checklist
- [x] I have read the CONTRIBUTING.md document.
- [x] I have performed a self-review of my own code.
- [x] I have commented my code, particularly in hard-to-understand areas.
- [x] I have added tests that prove my fix is effective or that my feature works.
- [x] New and existing unit tests pass locally with my changes.
- [x] I have manually tested my changes end-to-end.
- [x] Any dependent changes have been merged and published in downstream modules.
Hi @nimanthadilz ,Thank you for your contribution! We appreciate you taking the time to submit this pull request. Your PR has been received by the team and is currently under review. We will provide feedback as soon as we have an update to share.
Hi @wyf7107 , can you please review this