Conversation
|
Response from ADK Triaging Agent Hello @ScottMansfield, thank you for creating this PR! I see that this is a draft PR. When you are ready, please ensure you have read the contribution guide and filled out the PR template, including:
This information will help reviewers to review your PR more efficiently. Thanks! |
e3f5d6a to
49c7bf5
Compare
|
Looks like we have one open for the community repo: google/adk-python-community#104 |
|
Hi @ScottMansfield , Thank you for your contribution! We appreciate you taking the time to submit this pull request. |
|
Hi @ScottMansfield , is this PR still in draft? If not can you please fill in the details for the PR. |
These updates are derived from @anmolg1997 PR on the community repo: google/adk-python-community#104
|
I believe this is ready for review but I'm testing it with a real firestore instance |
This creates a new memories collection to hold indexed events.
tests/unittests/integrations/firestore/test_firestore_session_service.py
Show resolved
Hide resolved
src/google/adk/integrations/firestore/firestore_memory_service.py
Outdated
Show resolved
Hide resolved
src/google/adk/integrations/firestore/firestore_session_service.py
Outdated
Show resolved
Hide resolved
src/google/adk/integrations/firestore/firestore_session_service.py
Outdated
Show resolved
Hide resolved
| events_ref = session_ref.collection(self.events_collection) | ||
| query = events_ref.order_by("timestamp") | ||
|
|
||
| if config: |
There was a problem hiding this comment.
base_session_service.py (line 33). num_recent_events=0 is supposed to mean “return no events”, but this code checks truthiness, so 0 behaves like “no limit”.
i got 3 events for GetSessionConfig(num_recent_events=0).
| u_state = user_states_map.get(u_id, {}) | ||
| merged = self._merge_state(app_state, u_state, s_state) | ||
|
|
||
| sessions.append( |
There was a problem hiding this comment.
list_sessions() never sets _storage_update_marker or a real last_update_time, and append_event()
only does stale-writer protection when the marker exists
I was able to repro this: a session listed with state {'a': 1} appended successfully against storage revision 2 whose state was {'a': 1, 'b': 2}, and the transaction wrote {'a': 1} back, dropping b
Adding support for Firestore for both session and memory storage.
This started by copying the Firestore support from the Java ADK into the Python ADK and also takes inspiration from @anmolg1997's PR google/adk-python-community#104. It does things differently from both.
Firestore contains a hierarchical set of data for sessions:
The firestore memory service creates a top-level collection that hold indexed memories when sessions are added.
Link to Issue or Description of Change
This is from an existing customer request for firestore support.
Testing Plan
Unit Tests:
Manual End-to-End (E2E) Tests:
I created a demo app locally to test the session and memory storage with a real firebase instance. It successfully records sessions and memories, verified by manually checking the cloud console.
Memory did require an index, which will be created by the user the first time the memory session is used. Firestore has a specific deep link that it will create to give the exact index needed. After that, memory worked fine.
Checklist