Support to configure Redis as the session storage
** 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
This is already implemented here #789 , let's push the review forward
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!
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?
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.
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:
- Install ADK-Community from git:
pip install git+https://github.com/google/adk-python-community.git@main - Run this script which registers the redisservice and runs the ADK CLI.
python test_run.py web contributing/samples/ --session_service_uri=redis://local
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?
Yes we are thinking of further simplify the flow
Hello, is Redis as session storage supported by adk-python or we need to refer to the adk python community ?
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