Repository navigation
fix(firestore): keep thought parts out of FirestoreMemoryService - #7831
Closed
adityasingh2400 wants to merge 1 commit into
Closed
adityasingh2400 wants to merge 1 commit into
adityasingh2400 wants to merge 1 commit into
Conversation
Memory ingestion built search keywords from every part, including the model's thoughts, stored them in the memory content, and search returned them, so load_memory handed the model its own earlier reasoning and words that only appeared in it matched queries. Skip thought parts when writing memories, and drop them from search results so memories written before this change are clean too, as the in-memory, SQLite and Vertex RAG memory services already do. Fixes google#7830
copybara-service Bot
pushed a commit
that referenced
this pull request
Oct 31, 2026
Merge #7831 Keywords and stored content now come from non-thought parts only, an event whose only text is a thought is no longer stored, and search_memory drops thought parts from documents written before this change, skipping a document left with no parts. Part of #7830 PiperOrigin-RevId: 1010967300
Collaborator
|
Thank you @adityasingh2400 for your contribution! 🎉 Your changes have been successfully imported and merged via Copybara in commit af371b7. Closing this PR as the changes are now in the main branch. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Please ensure you have read the contribution guide before creating a pull request.
Link to Issue or Description of Change
1. Link to an existing issue (if applicable):
Problem:
FirestoreMemoryServicebuilt search keywords from every part of an event, including the model's thought parts. It stored those parts in the memory content, andsearch_memoryreturned them. Words that only appeared in the model's hidden reasoning made a memory match a query,load_memory/PreloadMemoryToolhanded that reasoning back to the model, and a thought-only event still got a memory document.Solution:
This matches the in-memory and Vertex RAG memory services (#7473) and SQLite (#7691). Parts with
thought=FalseorNoneare unchanged.Testing Plan
Unit Tests:
Added to
tests/unittests/integrations/firestore/test_firestore_memory_service.py:test_add_session_to_memory_keeps_thoughts_out: keywords and stored content come from the visible part only.test_add_session_to_memory_skips_thought_only_events: no document is written.test_search_memory_drops_stored_thought_parts: a document that already holds a thought part is returned without it.pre-commit runpasses on the changed files, andmypyreports no issues infirestore_memory_service.py.Manual End-to-End (E2E) Tests:
I don't have a Firestore instance or emulator. The tests drive the service through the mocked Firestore client the existing tests use, and assert on what
batch.setwrites and whatsearch_memoryreturns.Checklist
Additional context
None.