Repository navigation
Conversation
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.
Link to Issue or Description of Change
Problem:
PreloadMemoryToolincludes parts markedthought=Truewhen it turns recalled memories into a<PAST_CONVERSATIONS>block. This presents the model's earlier reasoning as ordinary conversation text, even when that reasoning considers an option the final answer rejects.Steps to reproduce:
Consider a zeppelin, but reject that option.) and a visible answer (Take the train to Paris.).Parisin a later session usingPreloadMemoryTool.<PAST_CONVERSATIONS>; only the visible answer should.This reproduces with both
InMemoryMemoryServiceandSqliteMemoryServiceat128faabb6dddacf26e029aa8c28c903c3a7a6b61(ADK 2.11.0). The checks use an offline recording model, not LiteLLM or a live model API.Solution:
Skip thought-marked parts when extracting text for preloading, consistent with ADK's other visible-text extractors. Parts with
thought=Falseorthought=Noneare retained. Stored content, search behavior, structuredload_memoryresults, and timestamp formatting are unchanged.Testing Plan
Unit Tests:
Added six parameterized cases covering thought flags, unchanged memory content, and empty/non-text/thought-only entries without timestamps. Without the fix, two cases fail (
thought=Trueand thought-only); with the fix, the three focused tool and memory test files pass (98 tests on Windows, Python 3.12.13).Full-suite validation on Linux uses
toxfor Python 3.11 andtox -p 3 -e py312,py313,py314for the remaining versions:The four failures in every version are the order-dependent LiteLLM logging tests already tracked in #7461. A full run on the unmodified base using the same Python 3.11 environment reproduced exactly those failures (18,354 passed, 4 failed); the patch adds six passing cases. The full-suite checkboxes remain unchecked because the suite is not entirely green.
pre-commit run --files src/google/adk/tools/_memory_entry_utils.py tests/unittests/tools/test_preload_memory_tool.pyanduv buildpass.Manual End-to-End (E2E) Tests:
An offline recording
BaseLlm, anAgentwithPreloadMemoryTool, and a realRunnerexercise a new session against each memory backend. The checks verify that the request contains the visible answer but not thought text, and that searching the stored memory still returns its original thought part. No paid model calls are made.Built the wheel with
uv build, installed it withaiosqlitein a clean Linux Python 3.12.13 environment, and ran the script below outside the checkout:Offline Runner reproduction
Checklist