feat: refine agent memory management operations - #31
Open
faj-design5260 wants to merge 2 commits into
Open
faj-design5260 wants to merge 2 commits into
faj-design5260 wants to merge 2 commits into
Conversation
Collaborator
Author
|
Ready-to-merge validation completed on b49f1e6.
No merge performed. |
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
Agent management already exposes record/correct and automatic relation maintenance. This PR tightens the existing correction operation boundary: explicit relationships must point to distinct active memories, CLI and MCP can replace or clear the full list, and concurrent corrections cannot overwrite each other's edits.
Why
These are correctness fixes to existing operations. A correction that reads before acquiring the writer lock can silently lose another writer's update. A relationship correction that accepts a missing or invalid target can leave canonical memory in an inconsistent state. Differing CLI and MCP contracts make that state dependent on the entry point.
Implementation
Store.correctandStore.writeshare one locked persistence path, with no nested lock.mem correctand MCPmemory_correctto the same Store operation. CLI--linkrepeats to specify the complete replacement list, while--clear-linksmatches MCPlinks: []. MCP rejects malformed arrays before dispatch.Validation
uv run --no-sync --offline pytest -q, using the worktree source paths and existing Python 3.12 environment).--cov=agent_memory --cov-report=term-missing --cov-fail-under=85).git diff --check: PASS.origin/main(34d12a2f): yes; rebase reported up to date.Scope and non-goals
This PR only refines existing Manage/correction boundaries. It does not add RBAC, approval or confirmation workflow, standalone unlink, archive management, retrieval improvements, answer-level benchmark optimization, general rollback, new lifecycle behavior, or feedback redesign. Existing automatic linking and proposal controls remain.
The change was split from #29 for independent review and requires no API from #29.
Follow-ups
Store.feedbackreturns an adjusted weight without persisting it; tracked indocs/TODO.md, outside this correction PR.Store.write; that broader case remains for a separate change. Related to Store.correct() has a TOCTOU race between find and write #16; this PR fixes concurrentcorrectcalls but does not claim to close the issue's Manage scenario.Checklist