fix(agent): refresh skills prompt cache when disabled skills change

This commit is contained in:
Dusk1e
2026-04-11 03:54:51 +03:00
committed by Teknium
parent 7e3b356574
commit fd119a1c4a
2 changed files with 20 additions and 2 deletions

View File

@@ -613,12 +613,14 @@ def build_skills_system_prompt(
or get_session_env("HERMES_SESSION_PLATFORM")
or ""
)
disabled = get_disabled_skill_names()
cache_key = (
str(skills_dir.resolve()),
tuple(str(d) for d in external_dirs),
tuple(sorted(str(t) for t in (available_tools or set()))),
tuple(sorted(str(ts) for ts in (available_toolsets or set()))),
_platform_hint,
tuple(sorted(disabled)),
)
with _SKILLS_PROMPT_CACHE_LOCK:
cached = _SKILLS_PROMPT_CACHE.get(cache_key)
@@ -626,8 +628,6 @@ def build_skills_system_prompt(
_SKILLS_PROMPT_CACHE.move_to_end(cache_key)
return cached
disabled = get_disabled_skill_names()
# ── Layer 2: disk snapshot ────────────────────────────────────────
snapshot = _load_skills_snapshot(skills_dir)

View File

@@ -354,6 +354,24 @@ class TestBuildSkillsSystemPrompt:
assert "web-search" in result
assert "old-tool" not in result
def test_rebuilds_prompt_when_disabled_skills_change(self, monkeypatch, tmp_path):
monkeypatch.setenv("HERMES_HOME", str(tmp_path))
skill_dir = tmp_path / "skills" / "tools" / "cached-skill"
skill_dir.mkdir(parents=True)
(skill_dir / "SKILL.md").write_text(
"---\nname: cached-skill\ndescription: Cached skill\n---\n"
)
first = build_skills_system_prompt()
assert "cached-skill" in first
(tmp_path / "config.yaml").write_text(
"skills:\n disabled: [cached-skill]\n"
)
second = build_skills_system_prompt()
assert "cached-skill" not in second
def test_includes_setup_needed_skills(self, monkeypatch, tmp_path):
monkeypatch.setenv("HERMES_HOME", str(tmp_path))
monkeypatch.delenv("MISSING_API_KEY_XYZ", raising=False)