Skip to main content

Encrypted session persistence for Google ADK agents

Project description

CI Coverage PyPI Python License Ruff docs vetted

adk-secure-sessions

The compliance gateway for Google ADK — add encrypted sessions in 5 minutes.

ADK's built-in session services store all data unencrypted. If your agents handle PHI, PII, or financial data, that's a compliance gap. adk-secure-sessions is an encrypted session service wrapping ADK's DatabaseSessionService that encrypts state and conversation history at rest, so you can close the encryption-at-rest gap without changing your agent code.

Install

pip install adk-secure-sessions

Or with uv:

uv add adk-secure-sessions

2 direct runtime dependencies: google-adk, cryptography.

Quick Start

# Before (ADK default — unencrypted):
from google.adk.sessions import DatabaseSessionService
session_service = DatabaseSessionService(db_url="sqlite+aiosqlite:///sessions.db")

# After (encrypted — swap the import and constructor):
from adk_secure_sessions import EncryptedSessionService, FernetBackend
session_service = EncryptedSessionService(
    db_url="sqlite+aiosqlite:///sessions.db", backend=FernetBackend("your-secret-key")
)

Use session_service exactly like any ADK session service — create_session, get_session, list_sessions, delete_session, and append_event all work the same way. Wrap in async with for automatic cleanup — see Documentation for details.

Migration note (v1.1.0): The constructor API changed from (db_path, backend, backend_id) to (db_url, backend). Existing databases from v1.0.x are incompatible — create a fresh database when upgrading.

What Gets Encrypted

Data Encrypted Rationale
state values (user_state, app_state, session_state) Yes Contains sensitive user/app data
events (conversation history) Yes Contains user messages, tool outputs, PII
session_id, app_name, user_id No Needed for lookups and filtering
create_time, update_time No Needed for expiration/cleanup

Examples

See examples/ for runnable scripts. The basic usage example runs a multi-turn ADK agent conversation with Ollama and proves that state and conversation history are encrypted at rest.

uv run python examples/basic_usage.py

Requires OLLAMA_API_BASE in your environment or .env file.

Links

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

adk_secure_sessions-1.2.0.tar.gz (17.9 kB view details)

Uploaded Source

Built Distribution

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

adk_secure_sessions-1.2.0-py3-none-any.whl (23.7 kB view details)

Uploaded Python 3

File details

Details for the file adk_secure_sessions-1.2.0.tar.gz.

File metadata

  • Download URL: adk_secure_sessions-1.2.0.tar.gz
  • Upload date:
  • Size: 17.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.10.9 {"installer":{"name":"uv","version":"0.10.9","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for adk_secure_sessions-1.2.0.tar.gz
Algorithm Hash digest
SHA256 819bd7210451c11dc8c5583d13b18da69addd58c5f736961028b223d6fab9b58
MD5 41149c9b3b7be9c8b6d2fdd06350ab86
BLAKE2b-256 24e8c8deb8345ba28c4763fb6567fb44207e12b081113a37183289e800685aac

See more details on using hashes here.

File details

Details for the file adk_secure_sessions-1.2.0-py3-none-any.whl.

File metadata

  • Download URL: adk_secure_sessions-1.2.0-py3-none-any.whl
  • Upload date:
  • Size: 23.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.10.9 {"installer":{"name":"uv","version":"0.10.9","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for adk_secure_sessions-1.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 0831dac62431023f78503dbef0e37ea6b1489c1112f6f282262ce57b593ea7ca
MD5 58d64fd82e11ad3625c79cf6daf2ff50
BLAKE2b-256 5cc410e4e2393b06084835ed4c6954794ed7c688626dd4f551e0650a1072c9cf

See more details on using hashes here.

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