Skip to content

fix(memory): forward committed entry identity to providers - #118903

Closed
ehz0ah wants to merge 1 commit into
NousResearch:mainfrom
ehz0ah:fix/memory-write-event-identity
Closed

ehz0ah wants to merge 1 commit into
NousResearch:mainfrom
ehz0ah:fix/memory-write-event-identity

Conversation

@ehz0ah

@ehz0ah ehz0ah commented Sep 22, 2026 •

Copy link
Copy Markdown
Contributor

What does this PR do?

Native memory providers receive the caller's old_text, but that search text does not identify the entry that Hermes changed. For example, removing the exact entry Prefers tea can make a provider with only a mapping for Prefers tea with milk delete the wrong remote entry.

Forward metadata.previous_content from the committed native-store result. Reuse existing replacement receipts and add matching removal receipts. Each batch operation captures its previous content under the store lock, after preceding operations; notifications remain gated on successful persistence of the entire write or batch. The hook signature and existing old_text metadata remain compatible.

Related Issue

Required by the external provider fix in volcengine/OpenViking#5281. Provider-specific matching and indexing handling remain in OpenViking.

Type of Change

  • Bug fix
  • Documentation update
  • Tests

Testing

Canonical runner with HERMES_TEST_FILE_RETRIES=0:

  • 82 native-store and event-bridge tests passed.
  • 80 provider, inline-dispatch, schema and import compatibility tests passed.
  • 11 regression cases fail on unchanged Hermes; they pass with this change.
  • Real native memory tool → external OpenViking provider → local server: replacement, refreshed search, restart deletion, A→B→A profile isolation, connection reload, and rejected native writes passed.

The event tests cover exact-over-substring selection, single and batched replace/remove, an add→replace→remove batch, and batches rejected for invalid operations, capacity, complete removal or disk-write failure. Tests verify selection under the store lock and no notifications before successful persistence.

The final installed external-plugin CLI run also passed capture, commit, extraction, fresh-session viking_search/viking_read, and real memory add/replace/remove calls. All five extraction tasks completed; the isolated bundled-provider removal was restored.

Ruff and git diff --check passed. Tested on macOS. The full repository suite was not run.

@alt-glitch alt-glitch added type/bug Something isn't working P3 Low — cosmetic, nice to have comp/agent Core agent runtime: loop, agent_init, prompt builder, context-compression, responses endpoint comp/plugins Plugin system and bundled plugins tool/memory Memory tool and memory providers area/memory sweeper:risk-session-state Sweeper risk: may lose/corrupt/mis-associate session or context state labels Sep 22, 2026
@ehz0ah
ehz0ah marked this pull request as ready for review September 22, 2026 08:38
teknium1 added a commit that referenced this pull request Sep 23, 2026
Keep the two tests that are red on unchanged main: previous_content comes
from the locked native-store result (single + batch replace/remove, batch
ordering) and never from caller arguments or build_metadata. Drop the
uncommitted-batch cases (they pass on main -- the no-notification gate on a
failed write predates this change) and the memory/user target axis (same
store code path).

Salvage of #118903 by @ehz0ah.
teknium1 added a commit that referenced this pull request Sep 23, 2026
Keep the two tests that are red on unchanged main: previous_content comes
from the locked native-store result (single + batch replace/remove, batch
ordering) and never from caller arguments or build_metadata. Drop the
uncommitted-batch cases (they pass on main -- the no-notification gate on a
failed write predates this change) and the memory/user target axis (same
store code path).

Salvage of #118903 by @ehz0ah.
@teknium1

Copy link
Copy Markdown
Collaborator

Landed on main via #120003 (rebase-merge, merge SHA 5908e1aaa8) with your commit eb980df intact and credited — thank you @ehz0ah. Providers now receive the exact committed entry as metadata["previous_content"] on single and batch replace/remove (the OpenViking#5281 case). The only change on top was trimming the regression tests to the two invariants that are red on unchanged main.

Closing in favour of the merged salvage.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp/agent Core agent runtime: loop, agent_init, prompt builder, context-compression, responses endpoint comp/plugins Plugin system and bundled plugins P3 Low — cosmetic, nice to have sweeper:risk-session-state Sweeper risk: may lose/corrupt/mis-associate session or context state tool/memory Memory tool and memory providers type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants