replace overwrote the whole matched entry, and models used it as a
find-and-swap, wiping the sibling facts in multi-fact entries (NVIDIA:
19/40 tasks on Opus 4.8). patch does everything replace did (old_text =
the whole entry rewrites it) without that failure, so the tool now
offers add / patch / remove only.
- A replace call, single or inside a batch, is refused with a pointer to
patch and writes nothing. Writes staged for approval before this change
still pin, display and replay through the store's replace.
- The schema loses the replace warnings, explains patch once, and drops
the added target prose: target is already an enum in `required`, the
runtime refusal teaches a missing or nested target, and batch items now
set additionalProperties: false so a nested target cannot be expressed.
- Net tool tokens per session: 13,264 on main -> 13,188 (-76); the PR
head before this commit was 13,446.
- Model-facing hints that said "shorten (replace)" now say patch.
Reverses the whole-entry replace contract from #117952 by maintainer
decision; the tests that drove replace through the tool now drive patch,
and one new test pins the refusal.
notify_memory_tool_write forwarded a patch as action "patch" with only
the replacement span as content. Providers know add/replace/remove, so
they skipped it (byterover mirrors only add and replace) or would have
stored the span as a fact. Since patch takes over the edits replace used
to make, external memory stopped receiving those updates.
Mirror a patch as what it is to a provider: a replace whose content is
the whole entry after the edit, with the entry before it as
previous_content. Single results carry patched_entry_after; for a batch,
redo the store's splice on that op's entry before the edit.
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.
The success/staged gating and op-expansion for mirroring built-in memory
writes to external providers lived in a standalone agent/memory_write_bridge.py
helper called inline from two core call sites (tool_executor.py,
agent_runtime_helpers.py). That left the mirror decision-making in the agent
loop, outside the memory-provider interface.
Fold it into a new MemoryManager.notify_memory_tool_write() entry point: the
loop now hands over the raw tool result + args and a metadata callback, and the
manager decides whether/what to mirror. Both core call sites collapse to a
single call; the orphan module is removed. No MemoryProvider ABC change.
Tests rewritten as behavior tests against the manager method.
Mirror built-in memory writes to external providers only after the native memory tool succeeds and is not staged for approval. Keep OpenViking's built-in memory mirroring add-only, since Hermes native memory entries do not yet have stable OpenViking file URIs for replace/remove.
Add a narrow viking_forget tool for exact user memory file deletion and document the current OpenViking write/delete behavior.