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

Support to configure Redis as the session storage

Open Colstuwjx opened this issue 1 year ago • 9 comments

** Please make sure you read the contribution guide and file the issues in the right place. ** Contribution guide.

Is your feature request related to a problem? Please describe. Currently, adk-python is using SQLAlchemy to save the session related data, I'm wondering if it's possible to store the session data in redis to accelerate the read performance ?

Describe the solution you'd like Able to use redis as the session cache and would use mysql / pg / sqlite as persistent storage.

Describe alternatives you've considered

Additional context

Colstuwjx avatar May 26 '25 07:05 Colstuwjx

This is already implemented here #789 , let's push the review forward

semoal avatar Jun 03 '25 09:06 semoal

Hi @Colstuwjx and thanks to everyone who participated in this thread.

We're currently doing some housekeeping on our issue tracker. Given the rapid pace of development and the number of updates since this was last active, there's a good chance this issue has been resolved in a newer version. To help us keep our backlog focused on current issues, we are closing this as stale.

If you're still facing this problem, could you please update to the very latest version of the library and confirm the issue still exists? If it does, please comment here, and we will be happy to reopen this issue and investigate further.

Thanks for your contribution and understanding!

surajksharma07 avatar Oct 07 '25 09:10 surajksharma07

Redis session class is released in adk-python-community repo, but adk-python still does not support redis session.

  • https://github.com/google/adk-python/blob/main/src/google/adk/cli/fast_api.py#L143
  • Either Vertex AI AgentEngine session or Database Session are supported in adk-python.

Do you have any plan to add this feature to adk-python?

ksmin23 avatar Oct 13 '25 05:10 ksmin23

Redis session class is released in adk-python-community repo, but adk-python still does not support redis session.

  • https://github.com/google/adk-python/blob/main/src/google/adk/cli/fast_api.py#L143
  • Either Vertex AI AgentEngine session or Database Session are supported in adk-python.

Do you have any plan to add this feature to adk-python?

This is very needed, please let's move this forward google dev team.

glyphiglyphi avatar Oct 19 '25 22:10 glyphiglyphi

Hi @glyphiglyphi and @ksmin23 , with https://github.com/google/adk-python/commit/391628fcdc7b950c6835f64ae3ccab197163c990, you will be able to register the redis session service to use it in adk web.

You can do something like:

from google.adk.cli import cli_tools_click
from google.adk.cli.service_registry import get_service_registry
from google.adk_community.sessions import redis_session_service



def redis_session_service_factory(uri: str, **kwargs):
  """Factory for creating a RedisSessionService."""
  kwargs_copy = kwargs.copy()
  kwargs_copy.pop("agents_dir", None)
  return redis_session_service.RedisSessionService(**kwargs_copy)

"""Registers custom services with the ADK global registry."""
registry = get_service_registry()
registry.register_session_service("redis", redis_session_service_factory)


if __name__ == '__main__':
  cli_tools_click.main()

To run this script:

  1. Install ADK-Community from git: pip install git+https://github.com/google/adk-python-community.git@main
  2. Run this script which registers the redisservice and runs the ADK CLI. python test_run.py web contributing/samples/ --session_service_uri=redis://local

DeanChensj avatar Oct 21 '25 23:10 DeanChensj

Hi @DeanChensj Thanks for your help. I tested the custom script for the ADK, and it works perfectly. Are there any plans to add this functionality directly to the adk command in the future?

ksmin23 avatar Oct 22 '25 14:10 ksmin23

Yes we are thinking of further simplify the flow

DeanChensj avatar Oct 22 '25 18:10 DeanChensj

Hello, is Redis as session storage supported by adk-python or we need to refer to the adk python community ?

rhajou avatar May 04 '26 14:05 rhajou

Hi @rhajou, you need to refer to the adk python community library. Please check the comment above: https://github.com/google/adk-python/issues/938#issuecomment-3429871364

ksmin23 avatar May 06 '26 00:05 ksmin23