Self-evolving Context Database for AI Agents. Unify Agent Memory, Knowledge RAG and Skills.
Python agent-contextagent-memoryagent-pluginsagentic-ragcontext-databasedsh-pluginknowledge-basememorymemory-managementself-evolvingvector-database
change switch name of template (#2185)
fujiajie66698cc00b6576b
diff --git a/benchmark/.gitignore b/benchmark/.gitignoreindex 2d43f88d4..fbca22537 100644--- a/benchmark/.gitignore+++ b/benchmark/.gitignore@@ -1,4 +1 @@results/-/vaka/vikingbot/analysis/-/vaka/vikingbot/result*/-/vaka/vikingbot/docs\ No newline at end of filediff --git a/openviking/prompts/templates/memory/vaka/entities.yaml b/openviking/prompts/templates/memory/experimental_memory/entities.yamlsimilarity index 100%rename from openviking/prompts/templates/memory/vaka/entities.yamlrename to openviking/prompts/templates/memory/experimental_memory/entities.yamldiff --git a/openviking/prompts/templates/memory/vaka/profile.yaml b/openviking/prompts/templates/memory/experimental_memory/profile.yamlsimilarity index 100%rename from openviking/prompts/templates/memory/vaka/profile.yamlrename to openviking/prompts/templates/memory/experimental_memory/profile.yamldiff --git a/openviking/session/memory/memory_type_registry.py b/openviking/session/memory/memory_type_registry.pyindex c674158a5..865a7d98e 100644--- a/openviking/session/memory/memory_type_registry.py+++ b/openviking/session/memory/memory_type_registry.py@@ -57,12 +57,18 @@ 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}")+ # Load experimental memory templates when the experimental memory switch is enabled.+ if getattr(config.memory, "experimental_memory_switch", False):+ experimental_memory_dir = str(Path(memory_templates_dir) / "experimental_memory")+ if os.path.exists(experimental_memory_dir):+ experimental_memory_loaded = self.load_from_directory(+ experimental_memory_dir, replace=True+ )+ logger.info(+ "Loaded %s experimental memory schemas from: %s",+ experimental_memory_loaded,+ experimental_memory_dir,+ )if custom_dir:custom_dir_expanded = os.path.expanduser(custom_dir)diff --git a/openviking/session/memory/session_extract_context_provider.py b/openviking/session/memory/session_extract_context_provider.pyindex 67978cf87..49cddb1c5 100644--- a/openviking/session/memory/session_extract_context_provider.py+++ b/openviking/session/memory/session_extract_context_provider.py@@ -524,10 +524,12 @@ After exploring, analyze the conversation and output ALL memory write/edit/deletconfig = get_openviking_config()custom_dir = config.memory.custom_templates_dirself._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 getattr(config.memory, "experimental_memory_switch", False):+ experimental_memory_dir = os.path.join(+ memory_templates_dir, "experimental_memory"+ )+ if os.path.exists(experimental_memory_dir):+ self._schema_directories.append(experimental_memory_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.pyindex 3ef871705..130aea7c0 100644--- a/openviking_cli/utils/config/memory_config.py+++ b/openviking_cli/utils/config/memory_config.py@@ -2,7 +2,7 @@# SPDX-License-Identifier: AGPL-3.0from typing import Any, Dict-from pydantic import BaseModel, Field, field_validator+from pydantic import BaseModel, Field, field_validator, model_validatorclass MemoryConfig(BaseModel):@@ -49,6 +49,14 @@ class MemoryConfig(BaseModel):"into higher-level experience memories."),)+ experimental_memory_switch: bool = Field(+ default=False,+ description=(+ "Experimental memory switch for experimental testing. When enabled, "+ "experimental memory templates are loaded and agent_memory_enabled defaults "+ "to true unless explicitly configured."+ ),+ )eager_prefetch: bool = Field(default=True,description=(@@ -75,13 +83,6 @@ 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=(@@ -101,6 +102,14 @@ class MemoryConfig(BaseModel):model_config = {"extra": "forbid"}+ @model_validator(mode="before")+ @classmethod+ def default_agent_memory_for_experimental_switch(cls, data: Any) -> Any:+ if isinstance(data, dict) and data.get("experimental_memory_switch") is True:+ data = data.copy()+ data.setdefault("agent_memory_enabled", True)+ return data+@field_validator("agent_scope_mode")@classmethoddef validate_agent_scope_mode(cls, value: str) -> str:diff --git a/tests/integration/test_agent_memory_e2e.py b/tests/integration/test_agent_memory_e2e.pyindex 1acbdb0c6..e75cbfc6d 100644--- a/tests/integration/test_agent_memory_e2e.py+++ b/tests/integration/test_agent_memory_e2e.py@@ -17,6 +17,8 @@ Prerequisites-------------- ~/.openviking/ov.conf has:"memory": { "version": "v2", "agent_memory_enabled": true }+ or:+ "memory": { "version": "v2", "experimental_memory_switch": true }Run---diff --git a/tests/test_config_loader.py b/tests/test_config_loader.pyindex e1db79a12..4aa9189bb 100644--- a/tests/test_config_loader.py+++ b/tests/test_config_loader.py@@ -188,6 +188,35 @@ def test_openviking_config_warns_when_agent_scope_mode_is_configured(monkeypatchOpenVikingConfigSingleton.reset_instance()+def test_openviking_config_memory_experimental_switch_defaults_agent_memory(monkeypatch):+ monkeypatch.setenv(OPENVIKING_CONFIG_ENV, "/tmp/codex-no-config.json")++ from openviking_cli.utils.config.open_viking_config import (+ OpenVikingConfig,+ OpenVikingConfigSingleton,+ )++ default_config = OpenVikingConfig.from_dict({})+ experimental_config = OpenVikingConfig.from_dict(+ {"memory": {"experimental_memory_switch": True}}+ )+ agent_only_config = OpenVikingConfig.from_dict({"memory": {"agent_memory_enabled": True}})+ explicit_agent_disabled_config = OpenVikingConfig.from_dict(+ {"memory": {"experimental_memory_switch": True, "agent_memory_enabled": False}}+ )++ assert default_config.memory.experimental_memory_switch is False+ assert default_config.memory.agent_memory_enabled is False+ assert experimental_config.memory.experimental_memory_switch is True+ assert experimental_config.memory.agent_memory_enabled is True+ assert agent_only_config.memory.experimental_memory_switch is False+ assert agent_only_config.memory.agent_memory_enabled is True+ assert explicit_agent_disabled_config.memory.experimental_memory_switch is True+ assert explicit_agent_disabled_config.memory.agent_memory_enabled is False++ OpenVikingConfigSingleton.reset_instance()++def test_openviking_config_retrieval_hotness_alpha_defaults_to_zero(monkeypatch):monkeypatch.setenv(OPENVIKING_CONFIG_ENV, "/tmp/codex-no-config.json")diff --git a/tests/test_prompt_manager.py b/tests/test_prompt_manager.pyindex 519491c79..4a02950fc 100644--- a/tests/test_prompt_manager.py+++ b/tests/test_prompt_manager.py@@ -205,7 +205,7 @@ def test_memory_type_registry_loads_schemas_from_prompt_manager_resolved_templatmonkeypatch.setattr("openviking_cli.utils.config.get_openviking_config",lambda: SimpleNamespace(- memory=SimpleNamespace(custom_templates_dir="", enable_vaka_template=False)+ memory=SimpleNamespace(custom_templates_dir="", experimental_memory_switch=False)),)@@ -256,7 +256,7 @@ def test_memory_type_registry_prefers_custom_memory_dir_over_prompt_manager_temp"openviking_cli.utils.config.get_openviking_config",lambda: SimpleNamespace(memory=SimpleNamespace(- custom_templates_dir=str(custom_memory_dir), enable_vaka_template=False+ custom_templates_dir=str(custom_memory_dir), experimental_memory_switch=False)),)@@ -286,7 +286,7 @@ def test_context_provider_schema_directories_use_prompt_manager_resolved_templatcustom_templates_dir="",eager_prefetch=False,prefetch_search_topn=5,- enable_vaka_template=False,+ experimental_memory_switch=False,link_enabled=True,)),@@ -319,7 +319,7 @@ def test_context_provider_schema_directories_prefer_custom_memory_dir_over_prompcustom_templates_dir=str(custom_memory_dir),eager_prefetch=False,prefetch_search_topn=5,- enable_vaka_template=False,+ experimental_memory_switch=False,link_enabled=False,)),@@ -338,32 +338,34 @@ def test_context_provider_schema_directories_prefer_custom_memory_dir_over_promp]-def test_memory_type_registry_loads_vaka_templates_when_enabled(monkeypatch):- """When enable_vaka_template is True, vaka templates override defaults."""+def test_memory_type_registry_loads_experimental_templates_when_switch_enabled(monkeypatch):+ """When experimental_memory_switch is True, experimental templates override defaults."""monkeypatch.setattr("openviking_cli.utils.config.get_openviking_config",lambda: SimpleNamespace(- memory=SimpleNamespace(custom_templates_dir="", enable_vaka_template=True)+ memory=SimpleNamespace(custom_templates_dir="", experimental_memory_switch=True)),)registry = MemoryTypeRegistry(load_schemas=True)- # entities and profile should be loaded (overridden by vaka versions)+ # entities and profile should be loaded (overridden by experimental versions)entities = registry.get("entities")profile = registry.get("profile")assert entities is not Noneassert profile is not None- # Vaka entities has specific description mentioning Zettelkasten+ # Experimental entities has specific description mentioning Zettelkastenassert "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."""+def test_memory_type_registry_does_not_load_experimental_templates_when_switch_disabled(+ monkeypatch,+):+ """When experimental_memory_switch 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)+ memory=SimpleNamespace(custom_templates_dir="", experimental_memory_switch=False)),)@@ -373,8 +375,8 @@ def test_memory_type_registry_does_not_load_vaka_when_disabled(monkeypatch):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."""+def test_context_provider_includes_experimental_dir_when_switch_enabled(monkeypatch):+ """When experimental_memory_switch is True, schema directories include experimental subdir."""monkeypatch.setattr("openviking.session.memory.session_extract_context_provider.get_openviking_config",lambda: SimpleNamespace(@@ -382,7 +384,7 @@ def test_context_provider_includes_vaka_dir_when_enabled(monkeypatch):custom_templates_dir="",eager_prefetch=False,prefetch_search_topn=5,- enable_vaka_template=True,+ experimental_memory_switch=True,link_enabled=False,)),@@ -392,6 +394,8 @@ def test_context_provider_includes_vaka_dir_when_enabled(monkeypatch):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")+ experimental_memory_dir = str(+ PromptManager._get_bundled_templates_dir() / "memory" / "experimental_memory"+ )assert bundled_memory_dir in dirs- assert vaka_dir in dirs+ assert experimental_memory_dir in dirs