Skip to content

FirestoreMemoryService indexes, stores and returns the model's thought parts #7830

Closed

Description

@adityasingh2400

🔴 Required Information

Describe the Bug:
FirestoreMemoryService treats the model's thought parts (Part.thought=True) as conversation text in three places:

  1. It builds an event's search keywords from every part, including thoughts, so words that only appear in the model's hidden reasoning make the memory match a query.
  2. It stores the full content, thoughts included.
  3. search_memory returns that content as-is, so load_memory / PreloadMemoryTool hand the model its own earlier reasoning back as a "memory".

An event whose only text is a thought still gets a memory document.

The other memory services already exclude thoughts. InMemoryMemoryService skips them when scoring and drops them from results, and VertexAiRagMemoryService skips them at ingest (#7473). SqliteMemoryService drops them from search results (#7691).

Steps to Reproduce:

  1. add_session_to_memory with a session holding a model event whose parts are [Part(text="weighing the hidden escalation", thought=True), Part.from_text(text="quick brown fox")].
  2. Look at the document written by batch.set, then search_memory(query="fox").

Expected Behavior:
Keywords come from quick brown fox only, the stored and returned content hold only the visible part, and a thought-only event is not stored.

Observed Behavior:
The keywords include weighing, hidden and escalation. The stored and returned content include the thought part, and a thought-only event is stored.

Environment Details:

  • ADK Library Version (pip show google-adk): 2.13.0 (also on main at 75fb788)
  • Desktop OS: macOS
  • Python Version (python -V): 3.11.16

Model Information:

  • Are you using LiteLLM: No
  • Which model is being used: any thinking model (e.g. Gemini with include_thoughts=True)

🟡 Optional Information

Additional Context:
In src/google/adk/integrations/firestore/firestore_memory_service.py:

  • _write_memories does text = " ".join([part.text for part in event.content.parts if part.text]) and stores event.content.model_dump(...).
  • _search_by_keyword validates and returns the stored content unchanged.

I verified this with the mocked Firestore client the existing tests use; I don't have a Firestore instance.

How often has this issue occurred?:

  • Always (100%), with thinking models

Activity

  1. adk-bot commented on Oct 31, 2026

    @adk-bot
    Collaborator

    Resolved by #7831 (imported and merged in commit af371b7). Closing issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions