Skip to main content

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,
)

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.

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

Maintainer

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

google_adk_redis-0.1.3.tar.gz (18.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

google_adk_redis-0.1.3-py3-none-any.whl (16.3 kB view details)

Uploaded Python 3

File details

Details for the file google_adk_redis-0.1.3.tar.gz.

File metadata

  • Download URL: google_adk_redis-0.1.3.tar.gz
  • Upload date:
  • Size: 18.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for google_adk_redis-0.1.3.tar.gz
Algorithm Hash digest
SHA256 479f00b78df23e25e12192af28104bd63d3446aeb6dd4ba8623d435c3b9d9e81
MD5 187bfeaa3c0d0befcf5359aa271be1bf
BLAKE2b-256 de76a762ec57452e3bfac8009de049de0cf08bda410980d56e80f6d0770b46ec

See more details on using hashes here.

Provenance

The following attestation bundles were made for google_adk_redis-0.1.3.tar.gz:

Publisher: workflow.yml on hucruz/google-adk-redis

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file google_adk_redis-0.1.3-py3-none-any.whl.

File metadata

File hashes

Hashes for google_adk_redis-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 1ceae74f6510bc56629bbbcbf4a9335583c2c770a86923761463f08d76b7fbec
MD5 5cae5de96979795ce90105044ed95ab7
BLAKE2b-256 599add1a2a669cf2d19dc357cff697b88388bf4c1bb73216de80ff37edd84ad6

See more details on using hashes here.

Provenance

The following attestation bundles were made for google_adk_redis-0.1.3-py3-none-any.whl:

Publisher: workflow.yml on hucruz/google-adk-redis

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page