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.
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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),
|
||||
)
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user