fix(memory): add write origin metadata#15315
Closed
helix4u wants to merge 1 commit into
Closed
Conversation
Contributor
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.
What does this PR do?
Adds backwards-compatible write-origin metadata to external memory provider mirrors for built-in memory writes. Providers that opt into the new
metadataargument can distinguish foreground assistant memory-tool writes from background review writes and memory-flush writes without parsing memory text.The manager still supports existing third-party providers that implement the old 3-argument
on_memory_write(action, target, content)hook.Related Issue
Fixes #15219
Type of Change
Changes Made
agent/memory_provider.py: adds optionalmetadatatoMemoryProvider.on_memory_write(...).agent/memory_manager.py: forwards metadata to opt-in providers while preserving old 3-arg provider compatibility.run_agent.py: builds write provenance metadata for foreground memory tools, background review agents, and memory flush writes.plugins/memory/*: updates bundled provider hook signatures; Supermemory includes the provenance in its memory metadata.tests/agent/test_memory_provider.pyandtests/run_agent/test_flush_memories_codex.py: cover opt-in metadata delivery, legacy compatibility, and flush provenance.How to Test
./scripts/run_tests.sh tests/agent/test_memory_provider.py tests/run_agent/test_flush_memories_codex.py tests/plugins/memory/test_supermemory_provider.py tests/plugins/test_retaindb_plugin.py -n 4166 passed in 7.35s../scripts/run_tests.sh tests/ -n 454 failed, 15434 passed, 40 skipped, 185 warnings in 306.60s. The failures are broad pre-existing repo/environment failures in gateway, Dingtalk, Codex response, backup/profile wrapper, and Tirith tests, not in the targeted memory-provider coverage.Checklist
Code
pytest tests/ -qand all tests passDocumentation & Housekeeping
cli-config.yaml.exampleif I added/changed config keys, or N/ACONTRIBUTING.mdorAGENTS.mdif I changed architecture or workflows, or N/AScreenshots / Logs
Targeted memory-provider tests pass. Full suite currently has unrelated baseline failures listed above.