Redis-backed session service for Google ADK
Project description
google-adk-redis
Redis-backed session service for Google ADK.
Install
From a Git repo:
pip install git+https://github.com/hucruz/google-adk-redis.git
From PyPI:
pip install google-adk-redis
Usage (programmatic)
from google_adk_redis import RedisMemorySessionService
session_service = RedisMemorySessionService(
host="localhost",
port=6379,
db=0,
expire=60 * 60,
max_transaction_retries=16,
)
Instances created with the same Redis configuration reuse the same underlying
async Redis client by default, so creating many services does not multiply
connection pools. You can opt out with share_cache=False or inject a custom
client with cache=....
If your application may attempt to load and create the same known session ID
concurrently, prefer get_or_create_session(...) over a manual
get_session(...) then create_session(...) sequence.
Each session is stored in its own Redis key using the shape
session:<app_name>:<user_id>:<session_id>, so different sessions for the same
user no longer overwrite each other through a shared JSON blob. If you still
expect concurrent writes to the same session across processes, increase
max_transaction_retries and, if needed, adjust
transaction_retry_base_delay / transaction_retry_max_delay.
Optional register for google.adk.sessions
import google_adk_redis
google_adk_redis.register()
from google.adk.sessions import RedisMemorySessionService
Usage with Google ADK (Runner)
import asyncio
from google.adk.agents.llm_agent import LlmAgent
from google.adk.runners import Runner
from google.genai import types
from google_adk_redis import RedisMemorySessionService
async def main():
session_service = RedisMemorySessionService(
host="localhost",
port=6379,
db=0,
expire=60 * 60,
)
agent = LlmAgent(
name="assistant",
model="gemini-2.0-flash",
instruction="You are a helpful assistant.",
)
async with Runner(
app_name="demo-app",
agent=agent,
session_service=session_service,
) as runner:
session = await session_service.create_session(
app_name="demo-app",
user_id="user-123",
)
async for event in runner.run_async(
user_id=session.user_id,
session_id=session.id,
new_message=types.Content(
role="user",
parts=[types.Part(text="Hola!")],
),
):
if event.content and event.content.parts:
text = "".join(part.text or "" for part in event.content.parts)
if text:
print(text)
asyncio.run(main())
Authors
- BloodBoy21 (original implementation, https://github.com/BloodBoy21)
- hucruz (upstream contributions, https://github.com/hucruz)
Maintainer
- hucruz (https://github.com/hucruz)
Attribution
Source repository: https://github.com/BloodBoy21/nerds-adk-python/tree/feat-redis-session
This repository packages and adapts the upstream implementation for standalone use.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file google_adk_redis-0.1.5.tar.gz.
File metadata
- Download URL: google_adk_redis-0.1.5.tar.gz
- Upload date:
- Size: 19.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3993ce72a6c4bf1e3476b6afb8a73ad9d3eecedc8e6259fe9ec6912ca0c98473
|
|
| MD5 |
dcf976e6cbc9c0a15f5b4f5f20d6d5f7
|
|
| BLAKE2b-256 |
560c976bba7b2abbf677b0ea61547fc1cce81029cae92c0cd66d031215c3a76a
|
Provenance
The following attestation bundles were made for google_adk_redis-0.1.5.tar.gz:
Publisher:
workflow.yml on hucruz/google-adk-redis
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
google_adk_redis-0.1.5.tar.gz -
Subject digest:
3993ce72a6c4bf1e3476b6afb8a73ad9d3eecedc8e6259fe9ec6912ca0c98473 - Sigstore transparency entry: 1300332739
- Sigstore integration time:
-
Permalink:
hucruz/google-adk-redis@6829644d72da6cd57bfe2cf280a518f93f765464 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/hucruz
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
workflow.yml@6829644d72da6cd57bfe2cf280a518f93f765464 -
Trigger Event:
workflow_dispatch
-
Statement type:
File details
Details for the file google_adk_redis-0.1.5-py3-none-any.whl.
File metadata
- Download URL: google_adk_redis-0.1.5-py3-none-any.whl
- Upload date:
- Size: 16.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d3230512472c5fbbe5a9a2680d9c982e0a8ba96e26451a96ada003fe9b088b00
|
|
| MD5 |
70b13656a69a987e6c75cfec9d501050
|
|
| BLAKE2b-256 |
5d151fa23ab4727ad82078c56ac36de55084647c63645c1546b7478f83c53787
|
Provenance
The following attestation bundles were made for google_adk_redis-0.1.5-py3-none-any.whl:
Publisher:
workflow.yml on hucruz/google-adk-redis
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
google_adk_redis-0.1.5-py3-none-any.whl -
Subject digest:
d3230512472c5fbbe5a9a2680d9c982e0a8ba96e26451a96ada003fe9b088b00 - Sigstore transparency entry: 1300332879
- Sigstore integration time:
-
Permalink:
hucruz/google-adk-redis@6829644d72da6cd57bfe2cf280a518f93f765464 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/hucruz
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
workflow.yml@6829644d72da6cd57bfe2cf280a518f93f765464 -
Trigger Event:
workflow_dispatch
-
Statement type: