From c809d964d4e5765f1975341e976af7652586c520 Mon Sep 17 00:00:00 2001 From: kshitijk4poor <82637225+kshitijk4poor@users.noreply.github.com> Date: Thu, 20 Aug 2026 11:01:47 +0530 Subject: [PATCH] fix(memory): parse boolean config values consistently Use Hermes's shared truthy-value parser so quoted false memory flags disable both built-in stores as expected. --- tests/agent/test_builtin_memory_disabled_surface.py | 7 +++++++ tools/memory_tool.py | 6 +++--- 2 files changed, 10 insertions(+), 3 deletions(-) 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), )