diff --git a/tests/agent/test_builtin_memory_disabled_surface.py b/tests/agent/test_builtin_memory_disabled_surface.py index 6978232926..547d5ec347 100644 --- a/tests/agent/test_builtin_memory_disabled_surface.py +++ b/tests/agent/test_builtin_memory_disabled_surface.py @@ -80,6 +80,13 @@ class TestBuiltinMemoryToolAvailability: assert get_builtin_memory_store_flags({"memory": {}}) == (True, True) assert get_builtin_memory_store_flags({}) == (True, True) + def test_quoted_false_flags_are_disabled(self): + from tools.memory_tool import get_builtin_memory_store_flags + + assert get_builtin_memory_store_flags( + {"memory": {"memory_enabled": "false", "user_profile_enabled": "false"}} + ) == (False, False) + def test_config_flip_updates_tool_without_manual_cache_clear(self, hermes_home): _write_memory_config( hermes_home, memory_enabled=False, user_profile_enabled=False diff --git a/tools/memory_tool.py b/tools/memory_tool.py index b489511db6..226ca67fae 100644 --- a/tools/memory_tool.py +++ b/tools/memory_tool.py @@ -31,7 +31,7 @@ from pathlib import Path from hermes_constants import get_hermes_home from typing import Dict, Any, List, Optional, Tuple -from utils import atomic_write_text +from utils import atomic_write_text, is_truthy_value from tools.registry import no_cache_check_fn # fcntl is Unix-only; on Windows use msvcrt for file locking @@ -1164,8 +1164,8 @@ def get_builtin_memory_store_flags(config: Optional[Dict[str, Any]] = None) -> T if not isinstance(section, dict): return True, True return ( - bool(section.get("memory_enabled", True)), - bool(section.get("user_profile_enabled", True)), + is_truthy_value(section.get("memory_enabled"), default=True), + is_truthy_value(section.get("user_profile_enabled"), default=True), )