Merged
Conversation
🛡️ Jit Security Scan Results✅ No security findings were detected in this PR
Security scan by Jit
|
Contributor
There was a problem hiding this comment.
Pull request overview
This PR removes deprecated Redis sorted-set (sessions:*) writes for working-memory session metadata, consolidating session listing to Redis Search only, and adds an explicit opt-in cleanup path via the migrate-working-memory CLI command.
Changes:
- Removed legacy
ZADD/ZREMwrites fromset_working_memory()anddelete_working_memory(). - Added
cleanup_deprecated_sessions_zsets()and wired it intoagent-memory migrate-working-memory(skipped on--dry-run). - Added regression tests to ensure legacy session zsets are not recreated and that cleanup/migration behavior works as intended.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
agent_memory_server/working_memory.py |
Removes deprecated zset session indexing writes and adds a cleanup helper for legacy sessions/sessions:* zsets. |
agent_memory_server/cli.py |
Updates migrate-working-memory to optionally clean legacy session zsets (not on dry-run). |
tests/test_working_memory_strategies.py |
Ensures strategy-based working-memory writes do not call deprecated zadd. |
tests/test_working_memory.py |
Adds integration tests for “no legacy zset creation” and for cleanup correctness. |
tests/test_cli.py |
Adds CLI tests verifying cleanup runs (and that dry-run skips it) and command registration includes migrate-working-memory. |
docs/cli.md |
Updates CLI docs for migration commands (with one remaining command-name mismatch noted in comments). |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
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.
Problem:
Working-memory session metadata was being written to two places on every save/delete:
working_memory:*JSON docssessions:{namespace}sorted setsOnly Redis Search was actually used by
list_sessions(). The legacy sorted sets were dead write-onlystorage, which caused:
sessions:*entries when working-memory keys expired by TTLThis happened because sorted sets were originally used for session listing, then Redis Search replaced
that read path, and a later unrelated commit accidentally reintroduced the old ZADD/ZREM writes
without restoring any read dependency on them.
Solution:
set_working_memory()delete_working_memory()sessions:*zsets via agent-memory migrate-working-memory--dry-rundoes notOther details:
mechanism
Note
Medium Risk
Moderate risk because it changes Redis write/delete behavior for working memory sessions and adds a cleanup routine that deletes keys matching
sessions/sessions:*when they are zsets. Should be safe if no consumers still rely on those legacy sorted sets, but misclassification or unexpected key usage could remove data.Overview
Working memory session persistence no longer writes to the deprecated
sessions/sessions:*sorted sets.set_working_memory()anddelete_working_memory()now only set/delete theworking_memory:*JSON key, relying entirely on the search index for session listing.Adds an opt-in cleanup path for legacy zsets. A new
cleanup_deprecated_sessions_zsets()deletessessionsandsessions:*keys only when they are zsets, andagent-memory migrate-working-memoryruns this cleanup (skipped on--dry-run) before marking migration complete when no string keys remain.Docs and tests are updated to reflect the new
migrate-working-memorycommand and to prevent regressions (nozadd/zremcalls, CLI cleanup behavior, and selective zset deletion).Written by Cursor Bugbot for commit 5b1a7dd. This will update automatically on new commits. Configure here.