[Bug]: experiences.content declares merge_op: replace, but the contract tells the model to edit() every content field
Issue Origin
Observed or reproduced in a real environment
Bug Description
The extraction contract instructs the model to change an existing field with obj.content.edit(search=..., replace=...), and even tells it to prefer edit()/drop() over rewriting the whole field. But the experiences memory type declares its content field with merge_op: replace, and the validator rejects edit()/drop() on any field that is not merge_op: patch.
Because MemoryField.merge_op defaults to PATCH, every other memory type accepts edit() on content. experiences is the only exception, and it is also the type whose content field is the longest structured text (a 3-section Situation/Approach/Reflect block), i.e. exactly the case where small in-place edits matter most.
So the contract's recommended operation is guaranteed to fail on the one type that needs it most, and the failure is not self-correcting:
- the error message gives no guidance on what to do instead, while the sibling error branch in the same function does;
- render_format_retry() has no branch for this error class, so the single format retry repeats the same rejected statement until the iteration budget is exhausted.
Result: the intended in-place edit is dropped, and every round burns its retry budget and VLM tokens on an operation the contract itself recommended.
Steps to Reproduce
Deterministic reproduction from a clean install (no private data, no network, no DB writes). Run the script provided in the "Minimal Reproducible Example" field:
python ov-issue-minimal-repro-edit-content.py
It loads the shipped schemas, builds an existing-object binding, then applies the identical statement to two memory types that both have a content field:
<var>.content.edit(search="old text", replace="new text")
To reproduce in a live pipeline instead:
- Have an existing
experiencesmemory loaded via sdk.existing(...). - Let the model emit a content edit on it, e.g.: experiences_1.content.edit(search="...", replace="...")
- Observe the parse failure and the exhausted retry: Failed to parse memory operations (iteration 2/2) failure_kind=parse_error error=Line 1: field 'content' does not support edit()/drop()
Expected Behavior
Any one of the following removes the contradiction:
-
experiences.content accepts edit()/drop(), i.e. its merge_op is aligned with the other content fields (which all inherit the PATCH default).
-
Or the contract text stops reading as universally applicable to every content field — e.g. it states that edit()/drop() apply only to fields whose merge_op is patch, and that a replace field must be written with update().
-
And in either case, the error message should tell the model how to recover, the way the sibling branch in the same function already does.
Actual Behavior
The identical statement is accepted for one memory type and rejected for another. Measured on 0.4.20 with the script below:
[experiences ] -> Line 1: field 'content' does not support edit()/drop()
[entities ] -> None (parsed successfully)
Full cross-type measurement of content.merge_op on 0.4.20:
memory type content.merge_op edit() accepted
------------- --------------------- ---------------
experiences replace (explicit) NO
entities default (patch) yes
preferences patch (explicit) yes
profile default (patch) yes
trajectories default (patch) yes
In production this appears as, for example:
2026-09-18 21:06:47.455 | ERROR | openviking.session.memory.extract_loop:run:420
- [7e2ed3cb4a784394a4af72ca33811ae0] Failed to parse memory operations (iteration
2/2) failure_kind=parse_error error=Line 1: field 'content' does not support
edit()/drop()
Observed repeatedly on 2026-09-18 (16:11, 21:06, 21:26), always at iteration 2/2 — the retry repeats the same statement and the budget is exhausted.
Impact scope, stated precisely: this is a partial degradation, not a lost round. At 21:26:11.201 the parse error was logged and the same round still reported "Extracted 3 memories" at 21:26:11.356. So extraction is not lost outright, but the specific in-place edit is silently dropped and the retry budget is wasted.
We are reporting a separate, more severe contract contradiction (field.update() argument shape) that DOES produce a fully silent round with "Extracted 0 memories". This report covers a different field/operation pair.
Minimal Reproducible Example
from pathlib import Path
from typing import Any, List
from pydantic import Field, create_model
import openviking
from openviking.session.memory.dataclass import MemoryFile
from openviking.session.memory.memory_type_registry import MemoryTypeRegistry
from openviking.session.memory.extraction_output_protocol.base import ExtractionOutputContext
from openviking.session.memory.extraction_output_protocol.python_protocol import (
PythonExtractionOutputProtocol,
)
TEMPLATES = Path(openviking.__file__).parent / "prompts" / "templates" / "memory"
class _PageIdMap:
def __init__(self, uri):
self._d = {uri: 1001}
def get_page_id(self, uri):
return self._d.get(uri)
def resolve(self, uri):
return None
def try_edit_on(memory_type):
registry = MemoryTypeRegistry()
registry.load_from_directory(str(TEMPLATES))
schemas = tuple(registry.list_all())
ops_model = create_model(
"Ops",
**{s.memory_type: (List[Any], Field(default_factory=list)) for s in schemas},
)
# An existing memory object is required, because edit() only patches existing content.
uri = f"viking://user/default/memories/{memory_type}/existing_one.md"
existing = MemoryFile(
uri=uri, content="## Situation\n- old text here\n", memory_type=memory_type
)
protocol = PythonExtractionOutputProtocol()
context = ExtractionOutputContext(
operations_model=ops_model,
schemas=schemas,
page_id_map=_PageIdMap(uri),
read_file_contents={uri: existing},
link_enabled=False,
)
# Generate the system-provided binding first, so we know the variable name (e.g. experiences_1).
protocol.render_new_bindings(context, source="repro")
var = list(protocol._uri_to_name.values())[0]
_ops, error = protocol.parse(
f'{var}.content.edit(search="old text", replace="new text")\n', context
)
return error
for mt in ("experiences", "entities"):
print(f"[{mt:<12}] -> {try_edit_on(mt)}")
[experiences ] -> Line 1: field 'content' does not support edit()/drop()
[entities ] -> None
Error Logs
2026-09-18 21:06:47.455 | ERROR | openviking.session.memory.extract_loop:run:420 - [7e2ed3cb4a784394a4af72ca33811ae0] Failed to parse memory operations (iteration 2/2) failure_kind=parse_error error=Line 1: field 'content' does not support edit()/drop() response_preview=' experiences_1.content.edit( search="- 规划输出:生成结构化规划稿,涵盖环境 隔离、分阶段验收、Skill 安装策略及回滚机制。", replace="""- 规划输出:生成结构化规划稿,涵盖环境隔离、分阶段验收、Skill 安装策略及回滚机制。 - 浏览器接管入库:IF 确认 zotero-mcp 不支持 linked_file THEN 采用“浏览器下载 + Zotero Connector 自动入库”方案,Ag...'
2026-09-18 21:26:11.201 | ERROR | openviking.session.memory.extract_loop:run:420 - [5a458f6da6ce4379b2dc9936e920ad49] Failed to parse memory operations (iteration 2/2) failure_kind=parse_error error=Line 1: field 'content' does not support edit()/drop() response_preview=' experiences_1.content.edit( search="""- 适用于集成前的技术选型验证、源码级 能力核实及多路径方案设计场景。""", replace="""- 适用于集成前的技术选型验证、源码级能力核实及多路径方案设计场景。 - 特别 适用于用户已有外部存储的文献库(如坚果云同步盘中的 linked_file 附件),需要评估自动化工具能否直接操作这些外部引用。""" ).edit( search="""- 获取权威源码:从 Git...'
OpenViking Version
0.4.20
Python Version
3.11.15
Operating System
Windows
Model Backend
Other
Additional Context
Exact locations (OpenViking 0.4.20), for reference.
The contract presents edit() as the general way to change a content field (_CONTRACT_PREAMBLE, python_protocol.py:81):
" - obj.content.edit(search=..., replace=...): replace one exact snippet in place.",
It is written against the literal field name content, which exists on many memory
types, so it reads as universally applicable.
The contract then actively prefers it over a full rewrite (python_protocol.py:87):
"For existing memories, prefer the smallest unique edit()/drop(). Do not rewrite
the entire field just to add or change a few facts; large full-content rewrites
are more likely to be truncated or malformed."
The validator rejects it unless the field is merge_op: patch (python_protocol.py:1114-1117):
if field_schema is None or not (
field_schema.merge_op == MergeOp.PATCH and field_schema.field_type == FieldType.STRING
):
self._error(node, f"field {name!r} does not support edit()/drop()")
And experiences is the only memory type that declares content as replace (openviking/prompts/templates/memory/experiences.yaml):
- name: content
type: string
description: |
Structured experience extraction in EXACTLY this 3-section format. ...
merge_op: replace # explicit; every other content field omits this
Secondary defect in the same function: the sibling error branch DOES tell the model how to recover (python_protocol.py:1111):
"field.edit()/drop() can only patch an existing memory; a memory created in this
program has no prior content — pass the complete value to field.update()"
but the branch this bug hits (python_protocol.py:1117) emits only the bare statement with no guidance. Consequently render_format_retry() (python_protocol.py:288) has dedicated branches for only two error classes:
if error and "sdk.existing() is reserved" in error: # binding guidance
if error and _is_string_literal_syntax_error(error): # quoting guidance
There is no branch for the "does not support edit()/drop()" class, so the retry prompt is generic boilerplate and the model cannot learn to switch to update() for this field.
Context on recurrence: we first hit this error class on 2026-09-13 and worked around it locally at that time. It reappeared unchanged on 2026-09-18, which suggests it is not a rare edge case but a straightforward template/contract inconsistency.
We can provide the full traces.jsonl spans, the affected archive metadata, or the archive memory_diff.json files if useful.