fix(memory): profile-scoped memory isolation and clone support#4845
Merged
fix(memory): profile-scoped memory isolation and clone support#4845
Conversation
Three fixes for memory+profile isolation bugs:
1. memory_tool.py: Replace module-level MEMORY_DIR constant with
get_memory_dir() function that calls get_hermes_home() dynamically.
The old constant was cached at import time and could go stale if
HERMES_HOME changed after import. Internal MemoryStore methods now
call get_memory_dir() directly. MEMORY_DIR kept as backward-compat
alias.
2. profiles.py: profile create --clone now copies MEMORY.md and USER.md
from the source profile. These curated memory files are part of the
agent's identity (same as SOUL.md) and should carry over on clone.
3. holographic plugin: initialize() now expands $HERMES_HOME and
${HERMES_HOME} in the db_path config value, so users can write
'db_path: $HERMES_HOME/memory_store.db' and it resolves to the
active profile directory, not the default home.
Tests updated to mock get_memory_dir() alongside the legacy MEMORY_DIR.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Three fixes for memory + profile isolation bugs:
1. Dynamic memory directory resolution (
memory_tool.py)MEMORY_DIRwas a module-level constant cached at import time. If HERMES_HOME changed after import (edge case but architecturally fragile), all memory reads/writes would go to the wrong profile. Nowget_memory_dir()resolves dynamically viaget_hermes_home()on every call. InternalMemoryStoremethods (load_from_disk,_path_for,save_to_disk) use it directly. The oldMEMORY_DIRconstant is kept as a backward-compatible alias.2. Clone includes memory files (
profiles.py)profile create --clonecopiedconfig.yaml,.env, andSOUL.mdbut NOTMEMORY.md/USER.md. These curated memory files are just as much part of the agent's identity as SOUL.md. New_CLONE_SUBDIR_FILESlist handles subdirectory files.3. Holographic plugin $HERMES_HOME expansion (
holographic/__init__.py)The
db_pathconfig value only expanded~viaPath.expanduser(). Users following the docstring (db_path: $HERMES_HOME/memory_store.db) got a literal$HERMES_HOMEstring. Nowinitialize()expands both$HERMES_HOMEand${HERMES_HOME}to the active profile directory.4. Gateway flush updated (
gateway/run.py)The memory flush path now uses
get_memory_dir()instead of importing the cachedMEMORY_DIRconstant.Files changed
tools/memory_tool.py—get_memory_dir()function, internal usages updatedhermes_cli/profiles.py—_CLONE_SUBDIR_FILES, clone logicplugins/memory/holographic/__init__.py— $HERMES_HOME expansion in db_pathgateway/run.py— useget_memory_dir()tests/tools/test_memory_tool.py— mockget_memory_dirtests/gateway/test_flush_memory_stale_guard.py— mockget_memory_dirTest plan