mirror of
https://github.com/volcengine/OpenViking.git
synced 2026-10-01 01:38:07 +08:00
When a memory has no existing content (current_value is None), PatchOp routed
the write through _extract_replace_when_no_original, which returned only the
FIRST block's replace text — via StrPatch.get_first_replace() for objects, and
blocks[0] for the dict (JSON-parsed) form.
The StrPatch schema instructs the model to split non-adjacent edits into
separate blocks, so a brand-new memory routinely arrives as a multi-block
patch (e.g. one block per extracted fact or preference). Taking only blocks[0]
silently discarded every subsequent block — entire facts/preferences extracted
from the session were dropped with no log, warning, telemetry, or
caller-visible signal. The existing-content path (apply_str_patch) already
iterates all blocks; the no-original branch was an asymmetric omission.
Concatenate every block's replace content (joined by newline) in both the
StrPatch and dict forms. The common single-block case is unchanged
("\n".join([x]) == x), and the existing-content path is untouched.
Add regression tests covering multi-block StrPatch and dict-form patches
(silent loss before the fix), plus single-block and existing-content cases
to pin the unchanged behaviour.