Conversation
|
Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). View this failed invocation of the CLA check for more information. For the most up to date status, view the checks section at the bottom of the pull request. |
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:
InMemoryMemoryServiceshares mutable event content across its write and read boundaries. Mutating an event after either ingestion API silently changes future recall. Editing the Content in a search result can also erase the stored memory and modify the source session history.Solution: Snapshot each ingested Event's metadata and Content, then return a separate Content for each selected search result. The Event copy is shallow except for Content, so unrelated opaque outputs/actions are not traversed. Search-result copying happens after ranking and the top-ten limit. Existing session replacement, event-ID deduplication and search behavior stay intact.
Reproduction
On main
665ec9835bee154f6d30ff49fb5125d79ef57e8c, both printed counts are 0; with this patch, they are 1. ADK 2.9.0, macOS, Python 3.12.13; no model, LiteLLM or credentials. This reproduces consistently; whether it worked in an older release is not established.The same aliasing occurs with
add_events_to_memory. Four new regressions exercise both ingestion APIs and both mutation directions through actual public calls.Testing Plan
Unit tests:
All four new cases fail on the unmodified upstream service and pass with the fix. Changed-file pre-commit hooks pass. Mypy reports no issues in the changed production file; the repository's configured mypy scope excludes tests.
The configured
toxrun attempted Python 3.10–3.14 after generating a local lock withuv lock. It was not fully green:test_import_loading.pyand four cases intest_load_web_page.py. Running those exact five cases on pristine base665ec98, with the same interpreter/dependencies and proxy settings, reproduced all five failures.pypdfium2==5.13.0after TLS handshake EOF/retries.google-crc32c==1.8.0after TLS handshake EOF/retries.The 56-test memory/tool suite passed separately on Python 3.12; the memory service tests also passed within the 3.10 full run. The full-matrix checkboxes remain unchecked.
Manual end-to-end test:
An offline custom
BaseAgentusesload_memorytwice within a real Runner invocation, clearing the first response's Content between the calls. On upstream the Runner returnsMEMORY LOST; after the fix it recalls the original text, and the source session remains unchanged. Save the following asmemory_probe.pyand runpython memory_probe.pyin the development environment:Runner reproduction
Output after the fix:
Checklist
Additional context
#6380 protects iteration by copying dictionary/list containers. This change addresses the separate nested Content ownership issue. It introduces no new dependency or public API.