Skip to content

build_skills_system_prompt can serve stale disabled-skill index until cache clear #14535

@NewTurn2017

Description

@NewTurn2017

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    P3Low — cosmetic, nice to havecomp/agentCore agent loop, run_agent.py, prompt builderduplicateThis issue or pull request already existssweeper:implemented-on-mainSweeper: behavior already present on current maintool/skillsSkills system (list, view, manage)type/bugSomething isn't working

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions