Repository navigation
fix(memory): render fields without init_value as empty on init - #4213
Merged
Merged
Conversation
Previously initialize_memory_files only seeded template variables for
fields that declared an init_value. Fields without one were omitted from
extra_fields, so Jinja (DebugUndefined) wrote their literal "{{ field }}"
placeholders into initialized memory files such as identity.md.
Seed every field, defaulting a missing init_value to an empty string, so
placeholders resolve to empty instead of leaking into the file.
Fixes volcengine#4207
qin-ctx
approved these changes
Aug 24, 2026
2 tasks
frankyang2008-eng
pushed a commit
to frankyang2008-eng/OpenViking
that referenced
this pull request
Oct 9, 2026
…ngine#4213) Previously initialize_memory_files only seeded template variables for fields that declared an init_value. Fields without one were omitted from extra_fields, so Jinja (DebugUndefined) wrote their literal "{{ field }}" placeholders into initialized memory files such as identity.md. Seed every field, defaulting a missing init_value to an empty string, so placeholders resolve to empty instead of leaking into the file. Fixes volcengine#4207
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
initialize_memory_filesonly seeded template variables for fields that declared aninit_value. Fields without one were omitted fromextra_fields, so whenMemoryFileUtils.writerendered thecontent_template(viarender_template, which uses JinjaDebugUndefined), their{{ field }}placeholders were written verbatim into freshly initialized memory files such asidentity.md.The initialized file then enters the memory-extraction prompt as existing-memory context, and a smaller VLM can echo the placeholder text back, causing
parse_errorextraction failures.Human Involvement
Related Issue
Fixes #4207
Type of Change
Changes Made
openviking/session/memory/memory_type_registry.py,initialize_memory_filesnow seeds every schema field into the template variables, defaulting a missinginit_valueto an empty string. Fields without an explicitinit_valuetherefore render as empty instead of leaking the literal{{ field }}text.test_initialize_memory_files_renders_fields_without_init_value_as_emptyintests/unit/session/test_memory_policy.py.Testing
The fix was validated with a focused harness that exercises the project's own
TemplateUtils.render(the exact renderer path used byMemoryFileUtils.write). Before the change,{{ no_init }}/{{ also_no_init }}placeholders leaked into the rendered output; after the change, those fields render as empty with no placeholder leakage. The added unit test mirrors the existingtest_initialize_memory_files_respects_memory_type_filterpattern and will run in CI.Checklist
Screenshots (if applicable)
N/A
Additional Notes
This addresses the structural cause (option 1 from the issue): a missing
init_valueis now treated as an empty string during initialization rendering, which also covers any other memory type whosecontent_templatereferences a field without aninit_value— not justidentity.