Repository navigation
Conversation
…__unknown_session_id__ InMemoryMemoryService stored events added without a session ID under the string '__unknown_session_id__'. A session with that literal ID shared the bucket, so add_session_to_memory replaced the sessionless memories. Key the sessionless bucket by None, which no session ID can alias.
Closed
9 tasks done
|
Please keep this PR open. I have a local candidate for #7711, but I haven't submitted a PR. I'll leave the implementation with you and won't open a competing one. I haven't independently reviewed or tested your patch. |
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
1. Link to an existing issue (if applicable):
Problem:
InMemoryMemoryService.add_events_to_memory()stores events added without a session ID under the string__unknown_session_id__.InMemorySessionServiceaccepts that literal as an ordinary session ID, soadd_session_to_memory()for such a session replaces the sessionless bucket and silently removes earlier sessionless memories.Solution:
Key the private sessionless bucket by
Noneinstead of a string. Caller-provided session IDs are alwaysstr, so they can no longer alias it. Ordinary session IDs, replacement and deletion behave as before, and empty/omitted IDs still map to the same bucket. OnlyInMemoryMemoryServiceis changed; the SQLite and MongoDB services use the same string constant but are out of scope for this issue.Testing Plan
Unit Tests:
Added
test_add_session_to_memory_keeps_sessionless_memories(parametrized withordinary-sessionand__unknown_session_id__). The__unknown_session_id__case fails onmainand passes with this change.Manual End-to-End (E2E) Tests:
Ran the reproduction script from #7711 (Python 3.12):
Checklist
Additional context
@widechaos commented on #7711 asking to take it on. I found no PR or branch for it and no maintainer reply, so I opened this; happy to close it in favour of theirs if they already have one in progress. Tested on Python 3.12 only; full supported-version tox run not done.