OpenViking icon indicating copy to clipboard operation
OpenViking copied to clipboard

[Bug]: Plain-text case memories from remember API always fail case embedding_template — Missing embedding template variables

Open heliveth opened this issue 3 months ago • 1 comments

Summary

Saving a case-category memory via the public viking_remember API (plain-text content) produces a memory file whose MEMORY_FIELDS contain only version, so the case schema's embedding_template variables are all missing. Vectorization then falls back to plain content with a WARNING. Data is not lost, but the case-type structured embedding contract is silently broken for any case memory that did not come from the compressor's CaseSpec path.

Environment

  • OpenViking server: v0.4.15 (Docker deployment, single host, healthy)
  • Models: local llama.cpp multi-model routing (8B LLM / 4B embedding / 0.6B reranker)
  • Memory written via: MCP remember tool, category=case, plain-text content (no structured fields)

Reproduction

  1. viking_remember(content=<plain text conclusion note>, category=case)
  2. The server writes memories/cases/mem_<id>.md whose MEMORY_FIELDS block is:
{
  "version": 1
}
  1. During vectorization of the written file, memory_updater.py (~line 1413, v0.4.15) looks up the case schema's embedding_template and finds all template variables missing:
2026-08-18 23:42:27,592 - openviking.session.memory.memory_updater - WARNING - [] Missing embedding template variables for viking://user/hermes/peers/hermes/memories/cases/mem_e845325baa51.md, falling back to plain content: ['case_name', 'input', 'rubric', 'task_signature']

The case schema template (prompts/templates/memory/cases.yaml, v0.4.15)

embedding_template: |-
  {{ case_name }}

  {{ task_signature }}

  {{ input }}

  {{ rubric }}

The template (and the overview_template, which also references item.file_content.case_name / task_signature) is only satisfiable by memories produced by the compressor's structured CaseSpec path. The public remember API accepts category=case with arbitrary plain text and writes it as a bare case memory, so the template is guaranteed to fail for those files.

Expected behavior

One of:

  1. The remember API path fills the case schema fields (or at least case_name / task_signature) when category=case and content is plain text, so the template renders; or
  2. Template variables in embedding_template are treated as optional (render as empty/omitted when missing), so plain-text case memories vectorize without the warning and the overview template degrades gracefully instead of rendering missing-field placeholders; or
  3. The remember API rejects / warns on category=case for plain-text content that does not include the required case fields, so users get an immediate signal instead of a later WARNING.

Option 1 or 2 preferred — the current fallback works (embedding is produced from plain content) but the structured contract is silently bypassed, and overview_template for the cases folder will render undefined-style placeholders for these files.

Related

  • No prior issue found covering this (searched "embedding template", "case_name rubric").
  • Same area as #3598 (case/overview rendering) but distinct: that one is about # Summary heading regex; this one is about template variables for plain-text case memories written via the remember API.

Happy to test a fix build against the same deployment if useful.

heliveth avatar Aug 19 '26 01:08 heliveth

Adding a second, independent reproduction of the same symptom on a different code path, in case it helps establish this is systematic rather than specific to the remember API.

Environment

  • OpenViking v0.4.21 (uv tool install, macOS), server on 127.0.0.1:1933
  • Path: openviking.session.memory.memory_updater (memory file update, not the remember API)
  • Trigger: bulk link updates on existing memory files

Evidence

2026-09-15 21:13:55,596 - openviking.session.memory.memory_updater - WARNING -
  Missing embedding template variables for
  viking://user/default/memories/events/2026/09/15/OpenViking未修复清单盘点.md,
  falling back to plain content
2026-09-15 21:13:55,598 - ... viking://user/default/memories/events/2026/09/15/link_enabled生效结论纠正.md
2026-09-15 21:14:06,249 - ... viking://user/default/memories/entities/软件项目/openviking.md,
  falling back to plain content: ['category']
2026-09-16 09:11:05,804 - ... viking://user/default/memories/events/2026/09/16/openviking日志问题排查.md

Missing variable sets observed: ['event_name', 'goal'] and ['category'] — i.e. event-type and entity-type schemas, not only case.

How it differs from the original report

  • Not the remember API; no CaseSpec involved.
  • The files already existed with valid metadata and had been embedded before. The variables go missing after a subsequent update, which is consistent with the metadata block being overwritten during batch link updates rather than never being set in the first place.
  • Same terminal symptom: embedding_template cannot render → plain-content fallback + WARNING. Data is not lost, but the structured embedding contract for these memories is silently broken, which degrades retrieval quality for exactly the files that were just updated.

Happy to provide full log excerpts or the affected memory files if useful.

za8209 avatar Sep 22 '26 10:09 za8209