OpenViking icon indicating copy to clipboard operation
OpenViking copied to clipboard

[Bug]: create_experiences is rejected when the program omits the optional field supersedes (prose says "leave empty", validator requires every schema field)

Open feel-think opened this issue 1 month ago • 1 comments

Issue Origin

Observed or reproduced in a real environment

Bug Description

A memory-extraction program is rejected when it omits the supersedes field on an experience creation, even though the field's own description tells the model it may leave it empty.

The two sides disagree:

Validator — openviking/session/memory/extraction_output_protocol/python_protocol.py requires every schema field to be present in a create_* / set_* call:

missing_fields = [field.name for field in schema.fields if field.name not in kwargs]
if missing_fields:
    self._error(
        node,
        f"{verb} requires complete memory fields; missing: " + ", ".join(missing_fields),
    )

(lines 927 and 931 in 0.4.23; 911 and 915 in 0.5.1 — same code, unchanged)

Schema prose — openviking/prompts/templates/memory/experiences.yaml (line 50) says the opposite:

  - name: supersedes
    type: string
    description: |
      The experience_name of an existing experience that this one supersedes.
      Set ONLY when this experience replaces a narrower existing experience with a DIFFERENT name.
      The system will automatically delete the old experience and inherit its trajectory history.
      Leave empty for a new experience or when updating an experience with the same name.
    merge_op: replace

"Leave empty" reads as "you may omit it". The validator treats the omission as an incomplete program and rejects the whole response.

How often it happens. I scanned 8 days of captured requests on a self-hosted instance (2026-10-14 → 2026-10-21, OpenViking 0.4.23, OpenAI-compatible endpoint). Of 4,925 sdk.create_experiences(...) calls, 1,291 (26.2%) do not pass supersedes at all.

Impact on task outcomes. On 2026-10-21 this was the single largest failure cause: of 5 failed session_commit tasks, 4 ended on exactly this error after exhausting 4 extraction attempts.

Steps to Reproduce

  1. Self-hosted 0.4.23 (0.5.1 has the same code), OpenAI-compatible endpoint, any model that produces a valid program shape.
  2. Let a session commit run experience extraction against an existing experience set.
  3. Watch for a program like:
sdk.create_experiences(
    experience_name="组织命名与目录约定",
    content="""## Situation
...
""",
)
  1. The validator rejects it: Line 25: create requires complete memory fields; missing: supersedes.

Expected Behavior

One of the two sides should be authoritative. Either the validator treats a field described as "leave empty" as optional, or the description instructs the model to pass an explicit empty value (supersedes=""). Today the model is penalised for following the prose.

Actual Behavior

The program is rejected as invalid, the extraction attempt is wasted, and after the retry budget is exhausted the whole archive fails — its memories are never extracted (see #6227 for why a failed archive is not recovered).

Error Logs

2026-10-21 16:59:24 | ERROR | openviking.session.memory.extract_loop:run:428 - Failed to parse memory operations
(iteration 4/4) failure_kind=parse_error error=Line 27: create requires complete memory fields; missing: supersedes
response_preview='```python exp_a = sdk.create_experiences( experience_name="按…'

Same error, four separate failed tasks on the same day (16:55, 17:25, 18:15, 18:48 local time).

OpenViking Version

0.4.23. The validator and the schema prose are identical in 0.5.1 (checked at tag v0.5.1: python_protocol.py:911, experiences.yaml:50).

Python Version

3.14.6

Operating System

Ubuntu 24.04 (Linux x86_64)

Model Backend

OpenAI-compatible endpoint (OpenRouter via a local proxy); deepseek/deepseek-v4.1-flash-1017; reasoning.effort=low.

Additional Context

A second failure class points at the same field. In #6235 I reported a program that does not parse as Python at all; its root cause is a malformed empty value for this very field:

    supersedes="""",
                 ^ four quotes where an empty triple-quoted string was intended

That program fails one level earlier (syntax), reported six lines away from the real cause. So supersedes produces two different failure classes — one from omitting it, one from trying to express "empty" — which suggests the field's contract, not the model's behaviour, is the thing to fix.

Not covered by the in-flight PRs. #6286 fixes edit()/drop() on [replace] fields; #6347 changes how existing objects are rendered into the prompt. Neither touches field-completeness validation.

Possible fixes. Either is small:

  1. Give the schema template a way to mark a field optional (or derive it from the "leave empty" phrasing) and skip such fields in missing_fields.
  2. Keep the validator strict but rewrite the description to demand an explicit empty string, e.g. supersedes="".

Related: #6235 (closed; the two other patterns are covered by #6286 and #6347), #6227 (failed archives are not retried).

feel-think avatar Oct 21 '26 11:10 feel-think

Thanks for pointing this out, the bug has fixed.

yeshion23333 avatar Oct 22 '26 06:10 yeshion23333