Skip to content

fix(memory): render fields without init_value as empty on init - #4213

Merged
qin-ctx merged 1 commit into
volcengine:mainfrom
c020627:fix-identity-init-placeholder
Aug 24, 2026
Merged

qin-ctx merged 1 commit into
volcengine:mainfrom
c020627:fix-identity-init-placeholder

Conversation

@c020627

@c020627 c020627 commented Aug 22, 2026

Copy link
Copy Markdown
Contributor

Description

initialize_memory_files only seeded template variables for fields that declared an init_value. Fields without one were omitted from extra_fields, so when MemoryFileUtils.write rendered the content_template (via render_template, which uses Jinja DebugUndefined), their {{ field }} placeholders were written verbatim into freshly initialized memory files such as identity.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_error extraction failures.

Human Involvement

  • A human participated in the implementation or review loop
  • This PR was generated entirely by AI agents without human participation in the loop

Related Issue

Fixes #4207

Type of Change

  • Bug fix (non-breaking change that fixes an issue)
  • New feature (non-breaking change that adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation update
  • Refactoring (no functional changes)
  • Performance improvement
  • Test update

Changes Made

  • In openviking/session/memory/memory_type_registry.py, initialize_memory_files now seeds every schema field into the template variables, defaulting a missing init_value to an empty string. Fields without an explicit init_value therefore render as empty instead of leaking the literal {{ field }} text.
  • Added a regression test test_initialize_memory_files_renders_fields_without_init_value_as_empty in tests/unit/session/test_memory_policy.py.

Testing

  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • I have tested this on the following platforms:
    • Linux
    • macOS
    • Windows

The fix was validated with a focused harness that exercises the project's own TemplateUtils.render (the exact renderer path used by MemoryFileUtils.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 existing test_initialize_memory_files_respects_memory_type_filter pattern and will run in CI.

Checklist

  • My code follows the project's coding style
  • I have performed a self-review of my code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • Any dependent changes have been merged and published

Screenshots (if applicable)

N/A

Additional Notes

This addresses the structural cause (option 1 from the issue): a missing init_value is now treated as an empty string during initialization rendering, which also covers any other memory type whose content_template references a field without an init_value — not just identity.

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
qin-ctx merged commit 0554308 into volcengine:main Aug 24, 2026
@github-project-automation github-project-automation Bot moved this from Backlog to Done in OpenViking project Aug 24, 2026
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

[Bug]: identity.md is initialized with literal Jinja placeholders when schema fields lack init_value

2 participants