Skip to content

fix(memory): skip thought parts in in-memory search and preloaded memories - #1975

Merged
baptmont merged 2 commits into
google:mainfrom
Vivek1106-04:fix/memory-skip-thought-parts
Oct 27, 2026
Merged

baptmont merged 2 commits into
google:mainfrom
Vivek1106-04:fix/memory-skip-thought-parts

Conversation

@Vivek1106-04

Copy link
Copy Markdown
Contributor

Linked issue

2. Describe the change:

Problem:
The in-memory memory service indexed thought parts for search and returned them in entry content, and preloadmemorytool wrote them into the <PAST_CONVERSATIONS> instruction. So the model's old reasoning was matched on and fed back as conversation.

Solution:
Skip Thought parts in AddSessionToMemory (for words and for the stored content, which is now a copy with only the visible parts) and in preloadmemorytool's extractText. Same as adk-python b138b5a6a.

Behavior change

Search no longer matches words that only appear in thought parts, returned entries don't include thought parts, and the preloaded instruction leaves them out. An event with only thought text is no longer stored in memory.

Testing Plan

Unit Tests:

  • All unit tests pass locally.

Added Test_inMemoryService_SearchMemory_SkipsThoughtParts and two cases to TestPreloadMemoryTool_ProcessRequest (mixed entry, thought-only entry).

With your source change reverted and your tests kept, which test fails?

--- FAIL: Test_inMemoryService_SearchMemory_SkipsThoughtParts
    SearchMemory("secret plan") matched thought text, got 2 entries
--- FAIL: TestPreloadMemoryTool_ProcessRequest/thought_parts_are_omitted
--- FAIL: TestPreloadMemoryTool_ProcessRequest/thought-only_memory_entry

With the change, go test -race ./memory/... ./tool/... passes and golangci-lint is clean.

Manual End-to-End (E2E) Tests:

N/A, covered by the unit tests.

Checklist

  • I have read the CONTRIBUTING.md document.
  • I have performed a self-review of my own code.
  • I have commented my code, particularly in hard-to-understand areas.
  • I have added tests that prove my fix is effective or that my feature works.
  • New and existing unit tests pass locally with my changes.
  • I have manually tested my changes end-to-end.
  • Any dependent changes have been merged and published in downstream modules.

…ories

Thought parts are the model's reasoning, not conversation. The in-memory
service indexed them for search and returned them in entry content, and
preloadmemorytool wrote them into the PAST_CONVERSATIONS instruction.
Skip them in both places, matching adk-python b138b5a6a.

Closes: google#1974
@indurireddy-TF

Copy link
Copy Markdown
Contributor

Hi @Vivek1106-04 I verified the fix locally, and it correctly skips thought parts in both memory search results and the preload memory tool. Everything works as expected. Thanks for addressing this!
image

image image

@baptmont
baptmont merged commit 751c5ec into google:main Oct 27, 2026
14 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

memory: in-memory search and preloadmemorytool include the model's thought parts

3 participants