Template variables in memory-template field descriptions abort ALL extraction with opaque 'unknown_variable' error
Symptom
Every memory extraction fails with DescriptionTemplateError: unknown_variable (line 4) / ContentTemplateError: unknown_variable (line 4). Observed 160+ consecutive failures in server logs (since 2026-11-17), on openviking 0.5.2 AND 0.5.5, and with two different VLM providers (a synthetic-route provider and an OpenAI-compatible endpoint) - so it is independent of provider and mostly independent of version.
Trigger
A template variable reference inside a memory-template field description. In our custom entities.yaml category-reuse contract paragraph we had written search viking://user/{{ user_space }}/memories/entities/ ... inside fields.category.description. {{ user_space }} renders fine in directory: / filename_template: contexts, but inside a field description the render raises unknown_variable and the whole extraction aborts (path: schema_model_generator.create_flat_data_model -> _render_description), before any model output is parsed.
Pain point
The error names neither the offending template file, nor the memory type, nor the variable. Diagnosing a 160-failure streak meant bisecting templates by hand (disable custom templates -> extraction passes -> restore paragraph without the variable -> passes again).
Asks
- Include the template file, memory type and variable name in the
unknown_variableerror. - Either document the allowed-variable scope per render context (
directory:/filename_template:vs field descriptions), or render field descriptions with the same variable scope so{{ user_space }}is usable consistently.
Repro
Add {{ user_space }} anywhere inside a field description: of a custom entities template; submit any memory via the client; extraction fails with unknown_variable (line N). Removing the variable from descriptions fixes it immediately (verified end-to-end: abstract/overview/archive/vectordb writes all complete).
Environment
- openviking 0.5.2 and 0.5.5 (quick_local deployment), Linux x86_64, custom
memory_templates/entities.yamlviamemory.custom_templates_dir
Opened #8018 for the diagnosability ask: the unknown_variable error now names the memory type, the field and the variable, e.g. memory type 'entities' fields.category.description: unknown_variable 'user_space' (line 1). The allowed-variable scope question for field descriptions is left alone.
Thanks — the format in #8018 (memory type + field + variable) is exactly what we asked for. Our workaround (keeping the custom entities contract variable-free) has been stable in production since the 0.5.5 upgrade, so no urgency on the variable-scope part from our side.
Thanks for the repro and for confirming the workaround. I opened #8400 to document the variable scope for each memory schema template position, including when the variables are available and what happens when one is missing.
For the example here, user_space is available in storage path templates, and type and field descriptions receive language. The PR adds verified Entities and Events examples to both the English and Chinese guides.
Load-time validation and isolation of invalid deployment templates are still open follow-up work.