Skip to content

fix(memory): add write origin metadata#15315

Closed
helix4u wants to merge 1 commit into
NousResearch:mainfrom
helix4u:fix/memory-write-origin-metadata
Closed

fix(memory): add write origin metadata#15315
helix4u wants to merge 1 commit into
NousResearch:mainfrom
helix4u:fix/memory-write-origin-metadata

Conversation

@helix4u

@helix4u helix4u commented Apr 24, 2026

Copy link
Copy Markdown
Contributor

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 metadata argument 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

  • 🐛 Bug fix (non-breaking change that fixes an issue)
  • ✨ New feature (non-breaking change that adds functionality)
  • 🔒 Security fix
  • 📝 Documentation update
  • ✅ Tests (adding or improving test coverage)
  • ♻️ Refactor (no behavior change)
  • 🎯 New skill (bundled or hub)

Changes Made

  • agent/memory_provider.py: adds optional metadata to MemoryProvider.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.py and tests/run_agent/test_flush_memories_codex.py: cover opt-in metadata delivery, legacy compatibility, and flush provenance.

How to Test

  1. Targeted: ./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 4
  2. Result: 166 passed in 7.35s.
  3. Full suite: ./scripts/run_tests.sh tests/ -n 4
  4. Result: 54 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

  • I have read the Contributing Guide
  • My commit messages follow Conventional Commits
  • I searched for existing PRs to make sure this is not a duplicate
  • My PR contains only changes related to this fix/feature
  • I have run pytest tests/ -q and all tests pass
  • I have added tests for my changes
  • I have tested on my platform: Ubuntu/WSL2-style Linux workspace

Documentation & Housekeeping

  • I have updated relevant documentation/docstrings, or N/A
  • I have updated cli-config.yaml.example if I added/changed config keys, or N/A
  • I have updated CONTRIBUTING.md or AGENTS.md if I changed architecture or workflows, or N/A
  • I have considered cross-platform impact, or N/A
  • I have updated tool descriptions/schemas if I changed tool behavior, or N/A

Screenshots / Logs

Targeted memory-provider tests pass. Full suite currently has unrelated baseline failures listed above.

@helix4u helix4u marked this pull request as ready for review April 24, 2026 19:46
@alt-glitch alt-glitch added type/feature New feature or request P2 Medium — degraded but workaround exists comp/agent Core agent loop, run_agent.py, prompt builder comp/plugins Plugin system and bundled plugins tool/memory Memory tool and memory providers labels Apr 24, 2026
@teknium1

Copy link
Copy Markdown
Contributor

Merged via PR #15346 (#15346). Your commit was cherry-picked with authorship preserved — the salvage trimmed the bundled-plugin signature widenings so the core seam lands alone and 3rd-party providers opt in by adding metadata=None. Thanks for the clean implementation.

@teknium1 teknium1 closed this Apr 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp/agent Core agent loop, run_agent.py, prompt builder comp/plugins Plugin system and bundled plugins P2 Medium — degraded but workaround exists tool/memory Memory tool and memory providers type/feature New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add write-origin metadata for external memory provider writes

3 participants