hermes - 💡(How to fix) Fix build_skills_system_prompt can serve stale disabled-skill index until cache clear [1 comments, 2 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
NousResearch/hermes-agent#14535Fetched 2026-04-24 06:16:41
View on GitHub
Comments
1
Participants
2
Timeline
6
Reactions
0
Timeline (top)
labeled ×5commented ×1

Code Example

source venv/bin/activate
python - <<'PY'
import os, tempfile, textwrap
from pathlib import Path
from agent.prompt_builder import build_skills_system_prompt, clear_skills_system_prompt_cache

with tempfile.TemporaryDirectory() as td:
    home = Path(td)
    os.environ['HERMES_HOME'] = str(home)
    d = home / 'skills' / 'demo'
    d.mkdir(parents=True)
    (d / 'SKILL.md').write_text(textwrap.dedent('''\
---
name: demo
description: demo skill
---
body
'''))

    clear_skills_system_prompt_cache()
    p1 = build_skills_system_prompt()

    (home / 'config.yaml').write_text('skills:\n  disabled:\n    - demo\n')
    p2 = build_skills_system_prompt()

    clear_skills_system_prompt_cache()
    p3 = build_skills_system_prompt()

    print('demo in p1:', 'demo skill' in p1)
    print('demo in p2:', 'demo skill' in p2)
    print('demo in p3:', 'demo skill' in p3)
PY

---

demo in p1: True
demo in p2: True
demo in p3: False
RAW_BUFFERClick to expand / collapse

Bug Description

build_skills_system_prompt() returns a cached skill index before re-reading the disabled-skills config. If config.yaml changes in-process (for example disabling a skill from settings/UI or a long-lived gateway reload path), the prompt can keep advertising the old skill list until the cache is cleared or the process restarts.

Affected files / lines

  • agent/prompt_builder.py:599-619 — cache lookup returns early
  • agent/prompt_builder.py:621get_disabled_skill_names() runs only after the early return path

Why this is a bug

The cache key includes skills dir, external dirs, tool filters, and platform hint, but not the disabled-skill config state. That means a config-only change can leave the in-process system prompt stale.

This is especially visible in long-lived gateway/CLI processes where skill visibility may change without a full restart.

Minimal reproduction

source venv/bin/activate
python - <<'PY'
import os, tempfile, textwrap
from pathlib import Path
from agent.prompt_builder import build_skills_system_prompt, clear_skills_system_prompt_cache

with tempfile.TemporaryDirectory() as td:
    home = Path(td)
    os.environ['HERMES_HOME'] = str(home)
    d = home / 'skills' / 'demo'
    d.mkdir(parents=True)
    (d / 'SKILL.md').write_text(textwrap.dedent('''\
---
name: demo
description: demo skill
---
body
'''))

    clear_skills_system_prompt_cache()
    p1 = build_skills_system_prompt()

    (home / 'config.yaml').write_text('skills:\n  disabled:\n    - demo\n')
    p2 = build_skills_system_prompt()

    clear_skills_system_prompt_cache()
    p3 = build_skills_system_prompt()

    print('demo in p1:', 'demo skill' in p1)
    print('demo in p2:', 'demo skill' in p2)
    print('demo in p3:', 'demo skill' in p3)
PY

Current output:

demo in p1: True
demo in p2: True
demo in p3: False

Expected Behavior

After config.yaml disables a skill, the next build_skills_system_prompt() call in the same process should stop listing that skill.

Actual Behavior

The stale cached prompt is returned until clear_skills_system_prompt_cache() is called or the process restarts.

Suggested investigation direction

  • Either include disabled-skill config state in the cache key, or
  • move the disabled-skill read ahead of the early-return path, or
  • invalidate the prompt cache when skills config changes.

extent analysis

TL;DR

The most likely fix is to update the cache key to include the disabled-skill config state or move the disabled-skill read ahead of the early-return path in build_skills_system_prompt().

Guidance

  • Investigate updating the cache key in agent/prompt_builder.py to include the disabled-skill config state, ensuring the cache is invalidated when the config changes.
  • Consider moving the get_disabled_skill_names() call to before the cache lookup in build_skills_system_prompt() to ensure the latest disabled skill list is used.
  • Review the clear_skills_system_prompt_cache() function to ensure it correctly invalidates the cache when the skills config changes.
  • Test the changes using the provided minimal reproduction script to verify the expected behavior.

Example

# Example of updating the cache key to include disabled-skill config state
def build_skills_system_prompt():
    # ...
    cache_key = (skills_dir, external_dirs, tool_filters, platform_hint, get_disabled_skill_names())
    # ...

Notes

The provided minimal reproduction script can be used to test and verify any changes made to build_skills_system_prompt(). It is essential to ensure that the cache is correctly invalidated when the skills config changes to prevent stale prompts.

Recommendation

Apply a workaround by updating the cache key to include the disabled-skill config state, as this approach ensures the cache is invalidated when the config changes, providing the most straightforward and effective solution.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING

hermes - 💡(How to fix) Fix build_skills_system_prompt can serve stale disabled-skill index until cache clear [1 comments, 2 participants]