Skip to content

Commit f084853

Browse files
committed
feat: add FirestoreSessionService for serverless session persistence
Adds a BaseSessionService implementation backed by Google Cloud Firestore, providing persistent, serverless session storage suitable for Cloud Run, Cloud Functions, and other GCP environments. Key design decisions: - Events stored in Firestore subcollections to avoid 1MB doc limit - Three-tier state management (app/user/session) matching ADK conventions - Atomic state updates via Firestore transactions (race-condition safe) - Batch writes for bulk event deletion (500-doc chunks) - Server-side query limits via limit_to_last() for num_recent_events - google-cloud-firestore as an optional dependency Includes 19 unit tests with a lightweight in-memory Firestore mock. Fixes google#103 Ref: google/adk-python#3776, google/adk-python#4439
1 parent 0d10dd9 commit f084853

4 files changed

Lines changed: 975 additions & 1 deletion

File tree

‎pyproject.toml‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,9 @@ changelog = "https://github.com/google/adk-python-community/blob/main/CHANGELOG.
4141
documentation = "https://google.github.io/adk-docs/"
4242

4343
[project.optional-dependencies]
44+
firestore = [
45+
"google-cloud-firestore>=2.16.0",
46+
]
4447
test = [
4548
"pytest>=8.4.2",
4649
"pytest-asyncio>=1.2.0",

‎src/google/adk_community/sessions/__init__.py‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414

1515
"""Community session services for ADK."""
1616

17+
from .firestore_session_service import FirestoreSessionService
1718
from .redis_session_service import RedisSessionService
1819

19-
__all__ = ["RedisSessionService"]
20+
__all__ = ["FirestoreSessionService", "RedisSessionService"]

0 commit comments

Comments
 (0)