Repository navigation
Conversation
…s users
f"{index}_{user_id}" is ambiguous: index="app"/user="u1_x" and
index="app_u1"/user="x" both become app_u1_x and share memories.
Scope each user with a sanitized, digest-tagged OpenSearch index name.
This branch has not been deployed
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.
Summary
OpensearchLTMBackendbuilt per-user OpenSearch indexes asf"{self.index}_{user_id}". That join is ambiguous wheneverindexoruser_idcontains_:indexuser_idappu1_xapp_u1_xapp_u1xapp_u1_xTwo distinct
(index, user_id)pairs therefore share one index and leak memories. This is the OpenSearch counterpart of the Redis prefix collision fixed in #1201 (RediSearch prefix matching); here the collision is an exact index-name clash.Fix
Introduce
_user_scoped_index(user_id):self.index/user_idfor OpenSearch naming rulesu1_xvsu1-x) stay distinctveadk-ltm-{index_part}-{user_part}save_memory/search_memoryboth use that helper.Note: existing memories stored under the old
{index}_{user_id}names will not be found after this change; re-ingest or rename indexes if you rely on prior OpenSearch LTM data.How to reproduce
New tests in
tests/memory/long_term_memory_backends/test_opensearch_ltm_backend.pyfail on main (collision assertion) and pass with this change (6 passed). Related memory suite: 68 passed.Test plan
pytest tests/memory/long_term_memory_backends/test_opensearch_ltm_backend.py— 6 passedpytest tests/memory/long_term_memory_backends/ tests/test_long_term_memory.py tests/test_openviking_long_term_memory.py— 68 passed