adk-python icon indicating copy to clipboard operation
adk-python copied to clipboard

feat(runners): Add get_session_config property to RunConfig

Open nimanthadilz opened this issue 1 month ago • 2 comments

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. image

Manual End-to-End (E2E) Tests:

  1. Create a simple agent.
  2. Use SqliteSessionService as the session service.
  3. When running the agent using Runner.run_async, pass a RunConfig including a get_session_config.
  4. Use this patch and test the agent with debug logs enabled for aiosqlite package.
  5. You would see that the SQL statement executed has a LIMIT clause 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.

nimanthadilz avatar Nov 22 '25 10:11 nimanthadilz

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.

ryanaiagent avatar Nov 30 '25 03:11 ryanaiagent

Hi @wyf7107 , can you please review this

ryanaiagent avatar Nov 30 '25 04:11 ryanaiagent