Firestore Session Manager for Google ADK
Project description
Google ADK Firestore Session
A specialized implementation of the BaseSessionService that uses Google Cloud Firestore for persisting application sessions, user states, and event logs.
Overview
This package provides the FirestoreSessionService class, which handles the lifecycle of sessions within the Google ADK (Agent Development Kit) framework. It organizes data in a hierarchical Firestore structure:
apps/{app_name}: Global application state.apps/{app_name}/users/{user_id}: Persistent user-specific state.apps/{app_name}/users/{user_id}/sessions/{session_id}: Individual session data and state.apps/{app_name}/users/{user_id}/sessions/{session_id}/events/{event_id}: Historical event logs for the session.
Installation
Using pip
pip install google-adk-firestore-session
Using uv
uv add google-adk-firestore-session
Configuration
The FirestoreSessionService can be configured via constructor arguments, environment variables, or through the built-in ADK factory.
Precedence
- Constructor Arguments: Explicit
projectanddatabasepassed to the class. - Environment Variables:
GOOGLE_CLOUD_PROJECTandGOOGLE_DATABASE. - Default Credentials: Standard Google Cloud application default credentials.
Usage with Google ADK
To use the FirestoreSessionService with Google ADK, register the provided factory with the ADK ServiceRegistry. This allows you to point your agents to Firestore using a simple URI.
1. Register the Service
In your main entry point (e.g., serving.py), import and register the factory.
from google.adk.cli.service_registry import get_service_registry
from firestore_session import firestore_session_service_factory
# Register the "firestore" scheme
get_service_registry().register_session_service(
"firestore",
firestore_session_service_factory
)
2. Configure the ADK App
Pass the URI to get_fast_api_app. The URI format is firestore://[project-id]/[database-name].
from google.adk.cli.fast_api import get_fast_api_app
app = get_fast_api_app(
agents_dir="path/to/agents",
# Connect to a specific project and database instance
session_service_uri="firestore://my-project-id/my-database",
web=True
)
Standalone Usage
from firestore_session import FirestoreSessionService
# Explicitly passing project/database
session_service = FirestoreSessionService(
project="my-project-id",
database="my-database"
)
# Or use environment variables (GOOGLE_CLOUD_PROJECT, etc.)
session_service = FirestoreSessionService()
Dependencies
google-adk: Core agent framework.google-cloud-firestore: Official Firestore client.
Development
Running Tests
Tests use pytest. Ensure you have a Firestore emulator or a project configured for testing.
pytest tests/
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_firestore_session-0.1.7.tar.gz.
File metadata
- Download URL: google_adk_firestore_session-0.1.7.tar.gz
- Upload date:
- Size: 173.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
45edd3abd34cbf3772c358e921dde6d208edc026af1d08fc44d7f608b1ce0436
|
|
| MD5 |
01c77e4580c22924dd3276eed635c365
|
|
| BLAKE2b-256 |
288011cbf544f76955aff563bbeb0c57a71af13f9118d971ac2134b86d2b2ebf
|
Provenance
The following attestation bundles were made for google_adk_firestore_session-0.1.7.tar.gz:
Publisher:
release.yml on mohammadshamma/google-adk-firestore-session
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
google_adk_firestore_session-0.1.7.tar.gz -
Subject digest:
45edd3abd34cbf3772c358e921dde6d208edc026af1d08fc44d7f608b1ce0436 - Sigstore transparency entry: 1059489236
- Sigstore integration time:
-
Permalink:
mohammadshamma/google-adk-firestore-session@ddcde2ee20cb18fea230b2377e81de70c1751b05 -
Branch / Tag:
refs/tags/v0.1.7 - Owner: https://github.com/mohammadshamma
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@ddcde2ee20cb18fea230b2377e81de70c1751b05 -
Trigger Event:
push
-
Statement type:
File details
Details for the file google_adk_firestore_session-0.1.7-py3-none-any.whl.
File metadata
- Download URL: google_adk_firestore_session-0.1.7-py3-none-any.whl
- Upload date:
- Size: 10.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
bdcb8649ba7d02361703a77d430346559e8477fb260cea2802fb898ec38440e9
|
|
| MD5 |
2d0e85d57175909c8137884177a0e398
|
|
| BLAKE2b-256 |
20cc04b5e34386b362ac67f12922fa046892c2f79ff3e7fc14d9ad0481c10b9f
|
Provenance
The following attestation bundles were made for google_adk_firestore_session-0.1.7-py3-none-any.whl:
Publisher:
release.yml on mohammadshamma/google-adk-firestore-session
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
google_adk_firestore_session-0.1.7-py3-none-any.whl -
Subject digest:
bdcb8649ba7d02361703a77d430346559e8477fb260cea2802fb898ec38440e9 - Sigstore transparency entry: 1059489242
- Sigstore integration time:
-
Permalink:
mohammadshamma/google-adk-firestore-session@ddcde2ee20cb18fea230b2377e81de70c1751b05 -
Branch / Tag:
refs/tags/v0.1.7 - Owner: https://github.com/mohammadshamma
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@ddcde2ee20cb18fea230b2377e81de70c1751b05 -
Trigger Event:
push
-
Statement type: