-
Notifications
You must be signed in to change notification settings - Fork 2.7k
firestore session service added for session management #3540
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
firestore session service added for session management #3540
Conversation
|
Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). View this failed invocation of the CLA check for more information. For the most up to date status, view the checks section at the bottom of the pull request. |
Summary of ChangesHello @Hariharan0309, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request introduces a new Highlights
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code Review
This pull request introduces a new FirestoreSessionService to provide persistent session management using Google Cloud Firestore. This is a valuable addition, especially for serverless deployments like Cloud Run, addressing the limitations of in-memory session services. The implementation correctly leverages asyncio.to_thread for synchronous Firestore client calls within an asynchronous environment and uses batch operations for efficiency.
However, there are several critical and high-severity issues identified related to data consistency, adherence to the base class contract, and correct deserialization of event data. These issues should be addressed to ensure the service functions reliably and correctly persists all session data.
|
Hi @Hariharan0309 , Thank you for your contribution! |
session_id check commented Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
persistance of state change Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
app_name check also added in the _delete_in_firestore function Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
Hi @ryanaiagent I have resolved all the failing unit test cases . Can you please check |
|
Hi @ryanaiagent can you check the PR |
|
Hi @ryanaiagent can you now check the PR |
|
Hi @ryanaiagent updated the PR . |
|
Hi @ryanaiagent can you check the PR |
|
Hi @Hariharan0309 , Your PR has been received by the team and is currently under review. We will provide feedback as soon as we have an update to share. |
|
Hi @ankursharmas , can you please review this. |
|
Hi @ankursharmas Could you please review this |
Okay @ryanaiagent |
|
Hi @ankursharmas @ryanaiagent Could you please review this |
|
I'm honestly surprised there is no native support for Fire Store |
Link to Issue or Description of Change
1. Link to an existing issue (if applicable):
2. Or, if no issue exists, describe the change:
This change adds a new FirestoreSessionService to the ADK.
It's designed to solve a key problem: the default in-memory session manager loses all data on serverless platforms like Cloud Run. This new service uses Google Firestore to persistently save session history, making it possible to build reliable, stateful agents that don't lose their memory on a container restart.
Problem:
While the ADK includes persistent session services for specific platforms (like VertexAISessionService or SQLSessionService), it lacks a simple, serverless, and persistent session manager ideal for deployments on Google Cloud Run.
The SQLSessionService requires developers to manage a separate SQL database, which adds significant operational overhead. The default InMemorySessionService is unsuitable for production on Cloud Run, as all session history is lost on container restarts or scaling events.
This leaves a gap for developers wanting to build stateful agents on a serverless, NoSQL stack.
Solution:
This pull request bridges that gap by introducing FirestoreSessionService, a new session service implementation that uses Google Cloud Firestore as a persistent, serverless, and highly-scalable backend.
This service is a drop-in replacement that perfectly complements a Cloud Run deployment, allowing developers to maintain session state with zero database management overhead.
This implementation has been field-tested across multiple projects (including the VentureAI agent) and is confirmed to work perfectly in a containerized production environment, managing complex session states and history.
Testing Plan
Please describe the tests that you ran to verify your changes. This is required
for all PRs that are not small documentation or typo fixes.
Testing Plan
Unit Tests:
(Unit tests for this service would require mocking the Google Cloud Firestore client. The primary validation relies on live, end-to-end integration testing as described below.)
Manual End-to-End (E2E) Tests:
This test plan verifies that the
FirestoreSessionServicecan successfully authenticate with Google Cloud, create a new session in Firestore using anapp_name, and then retrieve that same session.1. Environment Setup
Install Dependencies:
Authenticate with Google Cloud:
Run the following
gcloudcommand to set up Application Default Credentials (ADC). The Firestore client library will automatically find and use these credentials.Enable Firestore API:
Ensure the Cloud Firestore API is enabled on your project (replace
YOUR_PROJECT_ID):2. Manual Test Script
Create a Python file (e.g.,
test_session_service.py) and paste the following code. You must update the import path to match your new service's location.####3. Execution
PROJECT_IDandDATABASE_IDin the test_session_service.py script.4. Verification
Check the script output: The script will print success messages for each step (✅ Success: Session '...' created in Firestore.).
Check your Firestore Console: Log in to your Google Cloud project and navigate to Firestore. You will see a new top-level collection named my_test_app (or your APP_NAME). Inside that collection, you will find a document with the session_id from the test.
Checklist