mirror of
https://github.com/NousResearch/hermes-agent.git
synced 2026-04-25 00:51:20 +00:00
fix: make display_hermes_home imports lazy to prevent ImportError during hermes update (#3776)
When a user runs 'hermes update', the Python process caches old modules in sys.modules. After git pull updates files on disk, lazy imports of newly-updated modules fail because they try to import display_hermes_home from the cached (old) hermes_constants which doesn't have the function. This specifically broke the gateway auto-restart in cmd_update — importing hermes_cli/gateway.py triggered the top-level 'from hermes_constants import display_hermes_home' against the cached old module. The ImportError was silently caught, so the gateway was never restarted after update. Users with a running gateway then hit the ImportError on their next Telegram/Discord message when the stale gateway process lazily loaded run_agent.py (new version) which also had the top-level import. Fixes: - hermes_cli/gateway.py: lazy import at call site (line 940) - run_agent.py: lazy import at call site (line 6927) - tools/terminal_tool.py: lazy imports at 3 call sites - tools/tts_tool.py: static schema string (no module-level call) - hermes_cli/auth.py: lazy import at call site (line 2024) - hermes_cli/main.py: reload hermes_constants after git pull in cmd_update Also fixes 4 pre-existing test failures in test_parse_env_var caused by NameError on display_hermes_home in terminal_tool.py.
This commit is contained in:
parent
442888a05b
commit
c62cadb73a
7 changed files with 36 additions and 16 deletions
|
|
@ -2971,6 +2971,17 @@ def cmd_update(args):
|
|||
print()
|
||||
print("✓ Code updated!")
|
||||
|
||||
# After git pull, source files on disk are newer than cached Python
|
||||
# modules in this process. Reload hermes_constants so that any lazy
|
||||
# import executed below (skills sync, gateway restart) sees new
|
||||
# attributes like display_hermes_home() added since the last release.
|
||||
try:
|
||||
import importlib
|
||||
import hermes_constants as _hc
|
||||
importlib.reload(_hc)
|
||||
except Exception:
|
||||
pass # non-fatal — worst case a lazy import fails gracefully
|
||||
|
||||
# Sync bundled skills (copies new, updates changed, respects user deletions)
|
||||
try:
|
||||
from tools.skills_sync import sync_skills
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue