Skip to content

Self-evolving Context Database for AI Agents. Unify Agent Memory, Knowledge RAG and Skills.

Support Vaka memory templates via a switch (#2130)

fujiajie666fc5ed5458a15
diff --git a/benchmark/.gitignore b/benchmark/.gitignore
index 68bcbc960..2d43f88d4 100644
--- a/benchmark/.gitignore
+++ b/benchmark/.gitignore
@@ -1 +1,4 @@
-results/
\ No newline at end of file
+results/
+/vaka/vikingbot/analysis/
+/vaka/vikingbot/result*/
+/vaka/vikingbot/docs
\ No newline at end of file
diff --git a/openviking/prompts/templates/memory/vaka/entities.yaml b/openviking/prompts/templates/memory/vaka/entities.yaml
new file mode 100644
index 000000000..7e7872403
--- /dev/null
+++ b/openviking/prompts/templates/memory/vaka/entities.yaml
@@ -0,0 +1,59 @@
+memory_type: entities
+description: |
+ Wikipedia article - manages page using Zettelkasten method.
+ Each page represents an article with relative path links to events.
+ Entity should be rich and distributed - avoid putting all info in one entity.
+directory: "viking://user/{{ user_space }}/memories/entities"
+filename_template: "{{ category }}/{{ name }}.md"
+enabled: true
+
+overview_template: |-
+ # Entities Overview
+ {% if items %}**Category:** {{ items[0].file_content.category }}{% endif %}
+ {% for item in items %}
+ - [{{ item.file_content.name }}](./{{ item.file_name }})
+ {% endfor %}
+
+fields:
+ - name: category
+ type: string
+ description: |
+ - Category name in Chinese or English. If English, use lowercase with underscores, max 3 words.
+ merge_op: immutable
+
+ - name: name
+ type: string
+ description: |
+ - Entity name in Chinese or English. If English, use lowercase with underscores, max 3 words.
+ merge_op: immutable
+
+ - name: content
+ type: string
+ description: |
+ - Detailed Zettelkasten card content in markdown format.
+ - Keep the card self-contained, factual, neutral, and useful after retrieval.
+ - For people or evaluative content, do not output only an "Issue" field. Pair any evaluation, risk, weakness, or recommendation with "Evidence".
+ - Prefer objective facts, metrics, dates, user-provided context, or quoted requirements over labels.
+ - If evidence is missing or weak, omit the judgment or write "Insufficient information, needs verification"; do not overgeneralize.
+ - Avoid hostile or blaming wording such as "dragging down", "very poor", "not good", or "incapable"; prefer neutral wording such as "output below target/peer level" or "needs further observation".
+
+ Preferred shape for evaluative person entities:
+ # <Entity Name>
+ - Evaluation conclusion: <neutral conclusion, if supported by evidence>
+ - Evidence:
+ - <objective fact, metric, date/context, or quoted requirement>
+ - Concerns/Risks: <neutral risk statement, optional; include only if supported>
+
+ Bad example:
+ # Kevin D. Wallace
+ - Evaluation level: Needs improvement
+ - Issue: Since Q4, work efficiency has declined noticeably; other colleagues in the same group have stable output, while his state has fluctuated significantly, dragging the team down.
+
+ Good example:
+ # Kevin D. Wallace
+ - Evaluation conclusion: Current performance needs further attention
+ - Evidence:
+ - User mentioned that his work efficiency has declined noticeably since Q4
+ - User mentioned that other colleagues in the same group have stable output, while his state has fluctuated significantly
+ - Concerns/Risks: Team output pace may be affected; needs to be reviewed with the latest performance data
+ merge_op: patch
\ No newline at end of file
diff --git a/openviking/prompts/templates/memory/vaka/profile.yaml b/openviking/prompts/templates/memory/vaka/profile.yaml
new file mode 100644
index 000000000..b7e639b5b
--- /dev/null
+++ b/openviking/prompts/templates/memory/vaka/profile.yaml
@@ -0,0 +1,54 @@
+memory_type: profile
+description: |
+ # Task Objective
+ User profile memory - captures relatively stable information about "who the user is" and how the user works.
+ Extract stable personal/work attributes that help future answers understand the user's role, work scope, communication style, and recurring work habits.
+ Include: profession, stable work scope, experience level, technical/business background, communication style, work habits, recurring delivery preferences, etc.
+
+ Do NOT include one-off project events, temporary conversation details, or temporary mood states.
+
+ # Rules
+ - Each item: self-contained, declarative sentence, < 30 words
+ - Extract only facts stated/confirmed by user; no guesses
+ - Focus on persistent information, not temporary situations
+ - Do not narrow the user's whole profile to one recent topic if broader repeated evidence shows multiple workstreams
+ - If multiple conversations show the user repeatedly works across several domains or delivery types, summarize this as stable work scope
+ - Do not copy dated project history into profile; specific dated project progress belongs in events/entities
+ - Forbidden: only-assistant content, sensitive/private info, trivial updates
+ - Merge similar items; keep latest only when the same stable attribute truly conflicts
+
+directory: "viking://user/{{ user_space }}/memories"
+filename_template: "profile.md"
+enabled: true
+fields:
+ - name: content
+ type: string
+ description: |
+ User profile content in Markdown format describing relatively stable information about the user.
+
+ Should include stable attributes such as:
+ - Current occupation or broad role
+ - Stable work scope
+ - Recurring work mode
+ - Communication style
+ - Work habits
+ - Long-term delivery preferences
+
+ If multiple conversations repeatedly show the user working across different domains, audiences, or delivery types, profile may summarize that as broad stable work scope.
+ Do not collapse the user into a single narrow domain only because the latest conversation is about one topic.
+
+ Good example:
+ # User Personal Information
+ - Profession/Work scope: The user frequently handles work across different domains, audiences, or delivery types, and should not be reduced to a single business scenario.
+ - Work habits: Values first determining the task stage, then deciding whether to continue exploring, wrap up and verify, deliver, or hand off.
+ - Communication style: Prefers answers with clear conclusions, clear evidence, and risk points raised upfront.
+
+ Bad example:
+ # User Personal Information
+ - Profession: A single role corresponding to a recent topic
+
+ The bad example is too narrow if it is only supported by one recent topic while broader memories show many workstreams.
+
+ Only record objective or repeatedly supported statuses.
+ For changeable statuses, include the last updated time in the format: (as of YYYY-MM-DD).
+ merge_op: patch
\ No newline at end of file
diff --git a/openviking/session/memory/memory_type_registry.py b/openviking/session/memory/memory_type_registry.py
index 51427663b..a4e81077b 100644
--- a/openviking/session/memory/memory_type_registry.py
+++ b/openviking/session/memory/memory_type_registry.py
@@ -57,6 +57,13 @@ class MemoryTypeRegistry:
)
logger.info(f"Loaded {loaded} memory schemas from templates: {memory_templates_dir}")
+ # Load vaka templates if enabled (overrides default for matching memory_types)
+ if config.memory.enable_vaka_template:
+ vaka_dir = str(Path(memory_templates_dir) / "vaka")
+ if os.path.exists(vaka_dir):
+ vaka_loaded = self.load_from_directory(vaka_dir, replace=True)
+ logger.info(f"Loaded {vaka_loaded} vaka memory schemas from: {vaka_dir}")
+
if custom_dir:
custom_dir_expanded = os.path.expanduser(custom_dir)
if os.path.exists(custom_dir_expanded):
diff --git a/openviking/session/memory/session_extract_context_provider.py b/openviking/session/memory/session_extract_context_provider.py
index c296636a2..1829fe39e 100644
--- a/openviking/session/memory/session_extract_context_provider.py
+++ b/openviking/session/memory/session_extract_context_provider.py
@@ -478,6 +478,10 @@ After exploring, analyze the conversation and output ALL memory write/edit/delet
config = get_openviking_config()
custom_dir = config.memory.custom_templates_dir
self._schema_directories = [memory_templates_dir]
+ if config.memory.enable_vaka_template:
+ vaka_dir = os.path.join(memory_templates_dir, "vaka")
+ if os.path.exists(vaka_dir):
+ self._schema_directories.append(vaka_dir)
if custom_dir:
custom_dir_expanded = os.path.expanduser(custom_dir)
if os.path.exists(custom_dir_expanded):
diff --git a/openviking_cli/utils/config/memory_config.py b/openviking_cli/utils/config/memory_config.py
index d4811992f..698b36be4 100644
--- a/openviking_cli/utils/config/memory_config.py
+++ b/openviking_cli/utils/config/memory_config.py
@@ -75,6 +75,13 @@ class MemoryConfig(BaseModel):
"stateless deployments."
),
)
+ enable_vaka_template: bool = Field(
+ default=False,
+ description=(
+ "When enabled, use vaka-specific memory templates (entities, profile) "
+ "from the bundled vaka/ subdirectory to override default templates."
+ ),
+ )
enable_role_id_memory_isolate: bool = Field(
default=False,
description=(
diff --git a/tests/test_prompt_manager.py b/tests/test_prompt_manager.py
index b1ba8e1ab..5b7bf456a 100644
--- a/tests/test_prompt_manager.py
+++ b/tests/test_prompt_manager.py
@@ -159,7 +159,9 @@ def test_memory_type_registry_loads_schemas_from_prompt_manager_resolved_templat
)
monkeypatch.setattr(
"openviking_cli.utils.config.get_openviking_config",
- lambda: SimpleNamespace(memory=SimpleNamespace(custom_templates_dir="")),
+ lambda: SimpleNamespace(
+ memory=SimpleNamespace(custom_templates_dir="", enable_vaka_template=False)
+ ),
)
registry = MemoryTypeRegistry(load_schemas=True)
@@ -208,7 +210,9 @@ def test_memory_type_registry_prefers_custom_memory_dir_over_prompt_manager_temp
monkeypatch.setattr(
"openviking_cli.utils.config.get_openviking_config",
lambda: SimpleNamespace(
- memory=SimpleNamespace(custom_templates_dir=str(custom_memory_dir))
+ memory=SimpleNamespace(
+ custom_templates_dir=str(custom_memory_dir), enable_vaka_template=False
+ )
),
)
@@ -223,6 +227,7 @@ def test_context_provider_schema_directories_use_prompt_manager_resolved_templat
):
resolved_templates_dir = tmp_path / "resolved-prompts"
expected_memory_dir = resolved_templates_dir / "memory"
+ expected_memory_dir.mkdir(parents=True)
monkeypatch.setattr(
PromptManager,
@@ -232,13 +237,22 @@ def test_context_provider_schema_directories_use_prompt_manager_resolved_templat
monkeypatch.setattr(
"openviking.session.memory.session_extract_context_provider.get_openviking_config",
lambda: SimpleNamespace(
- memory=SimpleNamespace(custom_templates_dir="", eager_prefetch=False)
+ memory=SimpleNamespace(
+ custom_templates_dir="",
+ eager_prefetch=False,
+ prefetch_search_topn=5,
+ enable_vaka_template=False,
+ )
),
)
provider = SessionExtractContextProvider(messages=[])
- assert provider.get_schema_directories() == [str(expected_memory_dir)]
+ bundled_memory_dir = str(PromptManager._get_bundled_templates_dir() / "memory")
+ dirs = provider.get_schema_directories()
+ # Bundled is always first; resolved is appended when different from bundled
+ assert dirs[0] == bundled_memory_dir
+ assert str(expected_memory_dir) in dirs
def test_context_provider_schema_directories_prefer_custom_memory_dir_over_prompt_manager_root(
@@ -258,6 +272,8 @@ def test_context_provider_schema_directories_prefer_custom_memory_dir_over_promp
memory=SimpleNamespace(
custom_templates_dir=str(custom_memory_dir),
eager_prefetch=False,
+ prefetch_search_topn=5,
+ enable_vaka_template=False,
)
),
)
@@ -273,3 +289,61 @@ def test_context_provider_schema_directories_prefer_custom_memory_dir_over_promp
str(PromptManager._get_bundled_templates_dir() / "memory"),
str(custom_memory_dir),
]
+
+
+def test_memory_type_registry_loads_vaka_templates_when_enabled(monkeypatch):
+ """When enable_vaka_template is True, vaka templates override defaults."""
+ monkeypatch.setattr(
+ "openviking_cli.utils.config.get_openviking_config",
+ lambda: SimpleNamespace(
+ memory=SimpleNamespace(custom_templates_dir="", enable_vaka_template=True)
+ ),
+ )
+
+ registry = MemoryTypeRegistry(load_schemas=True)
+
+ # entities and profile should be loaded (overridden by vaka versions)
+ entities = registry.get("entities")
+ profile = registry.get("profile")
+ assert entities is not None
+ assert profile is not None
+ # Vaka entities has specific description mentioning Zettelkasten
+ assert "Zettelkasten" in entities.description
+
+
+def test_memory_type_registry_does_not_load_vaka_when_disabled(monkeypatch):
+ """When enable_vaka_template is False, default templates are used as-is."""
+ monkeypatch.setattr(
+ "openviking_cli.utils.config.get_openviking_config",
+ lambda: SimpleNamespace(
+ memory=SimpleNamespace(custom_templates_dir="", enable_vaka_template=False)
+ ),
+ )
+
+ registry = MemoryTypeRegistry(load_schemas=True)
+
+ entities = registry.get("entities")
+ assert entities is not None
+
+
+def test_context_provider_includes_vaka_dir_when_enabled(monkeypatch):
+ """When enable_vaka_template is True, schema directories include vaka subdir."""
+ monkeypatch.setattr(
+ "openviking.session.memory.session_extract_context_provider.get_openviking_config",
+ lambda: SimpleNamespace(
+ memory=SimpleNamespace(
+ custom_templates_dir="",
+ eager_prefetch=False,
+ prefetch_search_topn=5,
+ enable_vaka_template=True,
+ )
+ ),
+ )
+
+ provider = SessionExtractContextProvider(messages=[])
+ dirs = provider.get_schema_directories()
+
+ bundled_memory_dir = str(PromptManager._get_bundled_templates_dir() / "memory")
+ vaka_dir = str(PromptManager._get_bundled_templates_dir() / "memory" / "vaka")
+ assert bundled_memory_dir in dirs
+ assert vaka_dir in dirs