Skip to content

fix(skills): resolve SKILLS_DIR at call time, not at module load - #59040

Closed
Ahmett101 wants to merge 1 commit into
NousResearch:mainfrom
Ahmett101:fix/58908-skills-live-hermes-home-resolve
Closed

fix(skills): resolve SKILLS_DIR at call time, not at module load#59040
Ahmett101 wants to merge 1 commit into
NousResearch:mainfrom
Ahmett101:fix/58908-skills-live-hermes-home-resolve

Conversation

@Ahmett101

Copy link
Copy Markdown
Contributor

Summary

tools/skills_tool._find_all_skills() was resolving [SKILLS_DIR](file:///home/pstk/.hermes/profiles/merlin/skills) once at module import via [SKILLS_DIR = HERMES_HOME / "skills"](file:///home/pstk/.hermes/profiles/merlin/skills). A long-running gateway process (systemd unit, multi-profile setup) reads HERMES_HOME once at boot — when the env drift's between launch and tool calls later, the function silently returns a stale skill index that diverges from a fresh Python subprocess (80 vs 88 for a profile with 88 on-disk skills, spanning 8 entire categories: meta, hermes-config, content-creation, scheduled, thinking, tools, transfer, video).

get_skill_commands() (which the report confirms returns all 88) reads HERMES_HOME / "skills" per call. Converge to the same pattern in _find_all_skills() so the count from the gateway matches the count from any fresh subprocess.

The fix preserves backward compatibility for tests / callers that patch the module-level SKILLS_DIR: when patched, that override is honoured. When not patched (production runtime), the function re-reads HERMES_HOME via get_hermes_home() and rescans the current home root.

Changes

  • [tools/skills_tool.py](file:///data/data/com.termux/files/home/.hermes/hermes-agent/tools/skills_tool.py)_find_all_skills() resolves SKILLS_DIR per call via get_hermes_home(); falls back to the module-level SKILLS_DIR only when tests have patched it.
  • [tests/tools/test_skills_tool.py](file:///data/data/com.termux/files/home/.hermes/hermes-agent/tests/tools/test_skills_tool.py) — two regression pins:
    • test_find_all_skills_source_re_resolves_skills_dir pins the live-resolve behaviour by source inspection (a future refactor that goes back to module-level-only read silently regresses this fix without breaking any other test).
    • test_find_all_skills_results_use_call_time_skills_dir exercises the end-to-end behaviour: swapping the module-level SKILLS_DIR between two isolated home roots toggles which roots are scanned.

How to Test

venv/bin/python -m pytest tests/tools/test_skills_tool.py -q
# 90/91 passed (1 pre-existing inline-shell test fails on this host because
# /bin/bash isn't executable under our sandboxed runner; pre-existing on
# main and unrelated to this PR)

Risk & Impact

Low. The change only adds a per-call get_hermes_home() lookup, which is already the path get_skill_commands() and most other adapter entry-points take. The path is a single stat for a non-existent or shallow directory — negligible cost relative to the existing disk walk over iter_skill_index_files(...) for every skill subdirectory. No public API change.

The production scenarios where this matters are bounded:

  • Single-profile single-launch CLI invocations: HERMES_HOME is constant from start to exit — no behavioural change.
  • Multi-profile gateways with stable HERMES_HOME per profile across the process lifetime — same.
  • Long-running gateway whose gateway manager reloads an associated profile mid-process (the reported case) — _find_all_skills() would now match the fresh-subprocess count on the next call.

Type: Bug fix
Closes: #58908

@alt-glitch alt-glitch added type/bug Something isn't working tool/skills Skills system (list, view, manage) comp/agent Core agent runtime: loop, agent_init, prompt builder, context-compression, responses endpoint P3 Low — cosmetic, nice to have labels Jul 5, 2026
@teknium1

teknium1 commented Jul 7, 2026

Copy link
Copy Markdown
Contributor

Closing as duplicate: the same call-time skills-dir resolution fix was submitted earlier in #56689 by @jplew (Jul 1) and has now been merged via PR #60180 (#60180), which covers skills_list, skill_view, and skill_manage plus the TUI slash-worker subprocess env. Your diagnosis of the module-level SKILLS_DIR pin was spot on — thanks for the PR and the regression tests, sorry it collided with an earlier submission.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp/agent Core agent runtime: loop, agent_init, prompt builder, context-compression, responses endpoint P3 Low — cosmetic, nice to have tool/skills Skills system (list, view, manage) type/bug Something isn't working

Projects

None yet

3 participants