Skip to main content

Firestore Session Manager for Google ADK

Project description

Python Tests Python 3.11+ License: Apache 2.0

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

You can include this package in your project's dependencies using the Git URL.

Using pip

pip install git+https://github.com/mohammadshamma/google-adk-firestore-session.git

Using uv (pyproject.toml)

dependencies = [
    "google-adk-firestore-session @ git+https://github.com/mohammadshamma/google-adk-firestore-session.git"
]

Configuration

The FirestoreSessionService can be configured via constructor arguments, environment variables, or through the built-in ADK factory.

Precedence

  1. Constructor Arguments: Explicit project and database passed to the class.
  2. Environment Variables: GOOGLE_CLOUD_PROJECT and GOOGLE_DATABASE.
  3. 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

google_adk_firestore_session-0.1.3.tar.gz (173.0 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_firestore_session-0.1.3-py3-none-any.whl (10.3 kB view details)

Uploaded Python 3

File details

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

File metadata

File hashes

Hashes for google_adk_firestore_session-0.1.3.tar.gz
Algorithm Hash digest
SHA256 19123cc9616d2edcfbeb2816e3aace957de79aa6a9fbca1752d25b7b6b43e68a
MD5 575460bdb30a3fb1078dc020fc0165e9
BLAKE2b-256 ccdeda234ceca1dbb83ae4fe946dd5298f6886706c18b1060f0bf0bc5266fe3a

See more details on using hashes here.

Provenance

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

Publisher: release.yml on mohammadshamma/google-adk-firestore-session

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_firestore_session-0.1.3-py3-none-any.whl.

File metadata

File hashes

Hashes for google_adk_firestore_session-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 f7807339376d72a1c6521d54059d0900d9556c71c5170aad80e4ff94d969be23
MD5 4ea33cac454627fb85c4f7461993cfdc
BLAKE2b-256 1cad99fe7ee397b18200fdbea196b66e3ac8785974c49e30d192520319e01752

See more details on using hashes here.

Provenance

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

Publisher: release.yml on mohammadshamma/google-adk-firestore-session

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