The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(skills): skills.disabled also matches a duplicate's exact load path
kshitijk4poora08d0990594a
diff --git a/agent/prompt_builder.py b/agent/prompt_builder.pyindex f8f5ff85e71..228d9d48d01 100644--- a/agent/prompt_builder.py+++ b/agent/prompt_builder.py@@ -1558,8 +1558,8 @@ def _build_skills_system_prompt_inner(# project > local > create_dir > external_dirs; same-tier duplicates listed by exact path). Hidden and# incompatible copies still take part — skill_view sees them too.from agent.skill_utils import (- TIER_CREATE_DIR, TIER_EXTERNAL, TIER_LOCAL, TIER_PROJECT, get_skill_create_dir, iter_project_skill_files,- resolve_skill_catalog)+ TIER_CREATE_DIR, TIER_EXTERNAL, TIER_LOCAL, TIER_PROJECT, get_skill_create_dir, is_disabled_entry,+ iter_project_skill_files, resolve_skill_catalog)rows: list[tuple[dict, bool]] = []for proj_dir in (d for d in project_dirs if d.exists()):rows += _scan_extra_root(proj_dir, iter_project_skill_files(proj_dir), TIER_PROJECT, "Error reading project skill %s: %s")@@ -1574,7 +1574,8 @@ def _build_skills_system_prompt_inner({**entry, "name": _entry_name(entry), "path": entry["root"] / entry["rel"],"visible": ok and not hides(_entry_name(entry), entry.get("skill_name") or "", entry.get("conditions") or {})}for entry, ok in rows])- visible_entries = [e for e in resolved if e["visible"] and e["status"] != "shadowed"]+ visible_entries = [e for e in resolved+ if e["visible"] and e["status"] != "shadowed" and not is_disabled_entry(e, disabled)]_label_visible_entries(visible_entries, skills_by_category)if snapshot is None: # persist for fast cold-start reuse (best-effort)category_descriptions.update(_read_category_descriptions(skills_dir, "Could not read skill description %s: %s"))diff --git a/agent/skill_utils.py b/agent/skill_utils.pyindex e4c4666c831..298c2424e4f 100644--- a/agent/skill_utils.py+++ b/agent/skill_utils.py@@ -469,6 +469,12 @@ def pick_skill_candidate(candidates) -> Tuple[Optional[int], List[int]]:return (contenders[0] if len(contenders) == 1 else None), contenders+def is_disabled_entry(entry: Dict[str, Any], disabled: Set[str]) -> bool:+ """``skills.disabled`` matches a resolved catalog entry by its declared name OR its exact relative+ path — the identifier a same-tier duplicate's list/config/web row shows (``a/one``) and saves."""+ return bool(disabled) and not disabled.isdisjoint({str(entry["name"]), entry["relative_path"]})++def resolve_skill_catalog(entries: List[Dict[str, Any]]) -> List[Dict[str, Any]]:"""Copies of scanned skills (each with ``name``, ``tier``, ``root`` and ``path`` = its SKILL.md)annotated with what skill_view() resolves, using its aliases (declared name, directory name, pathdiff --git a/tests/agent/test_skill_commands.py b/tests/agent/test_skill_commands.pyindex 9ca3ee78494..1203ecdf9a2 100644--- a/tests/agent/test_skill_commands.py+++ b/tests/agent/test_skill_commands.py@@ -587,6 +587,16 @@ class TestDuplicateNamesAgreeAcrossSurfaces:parts = _load_cron_skill_parts({"id": "j"}, ["dup-demo", "xdup"])assert ambiguous in parts[0] and "LOCAL XDUP" in "\n".join(parts)+ # Disabling a duplicate by the exact path its row shows (what `hermes skills` / the web toggle+ # save) hides it from list and index and refuses the load.+ disabled = {"a/one"}+ monkeypatch.setattr(skill_utils, "get_disabled_skill_names", lambda *a, **k: disabled)+ monkeypatch.setattr(pb, "get_disabled_skill_names", lambda *a, **k: disabled)+ monkeypatch.setattr(skills_tool_module, "_is_skill_disabled", lambda n, platform=None: n in disabled)+ assert sorted(s["name"] for s in json.loads(skills_list())["skills"]) == ["b/two", "xdup"]+ assert "a/one" not in pb.build_skills_system_prompt()+ assert "disabled" in json.loads(skill_view("a/one"))["error"]+class TestBuildSkillInvocationMessage:diff --git a/tools/skills_tool.py b/tools/skills_tool.pyindex 16da6810c75..ea963b65ee3 100644--- a/tools/skills_tool.py+++ b/tools/skills_tool.py@@ -183,7 +183,8 @@ def _skill_catalog(*, skip_disabled: bool = False) -> List[Dict[str, Any]]:"""Every scanned skill resolved by ``agent.skill_utils.resolve_skill_catalog`` (status /load_name / tier / path), visible ones only; cached per session. Resolution runs over ALLfiles first — skill_view ignores platform/disabled gates when collecting candidates."""- from agent.skill_utils import TIER_PROJECT, iter_project_skill_files, iter_skill_index_files, resolve_skill_catalog+ from agent.skill_utils import (+ TIER_PROJECT, is_disabled_entry, iter_project_skill_files, iter_skill_index_files, resolve_skill_catalog)cache_key = "with_disabled" if skip_disabled else "filtered"disabled = set() if skip_disabled else _get_disabled_skill_names()roots, _ = _skill_search_dirs()@@ -217,7 +218,7 @@ def _skill_catalog(*, skip_disabled: bool = False) -> List[Dict[str, Any]]:logger.debug("Failed to read skill file %s: %s", skill_md, e)except Exception as e:logger.debug("Skipping skill at %s: failed to parse: %s", skill_md, e, exc_info=True)- skills = [s for s in resolve_skill_catalog(scanned) if s.pop("visible") and s["name"] not in disabled]+ skills = [s for s in resolve_skill_catalog(scanned) if s.pop("visible") and not is_disabled_entry(s, disabled)]# Keyed by the signature computed BEFORE the scan: a write racing the scan changes the# signature, so the next call re-scans instead of serving a torn result._SKILLS_CACHE[cache_key] = (signature, now, skills)@@ -607,7 +608,8 @@ def skill_view(if not skill_matches_platform(frontmatter):return _fail(f"Skill '{name}' is not supported on this platform.", readiness_status=SkillReadinessStatus.UNSUPPORTED.value)resolved_name = frontmatter.get("name", skill_md.parent.name)- if _is_skill_disabled(resolved_name):+ # Disabled by declared name or by the exact path its list row shows (same-tier duplicates).+ if _is_skill_disabled(resolved_name) or _is_skill_disabled(_owned_relative(skill_dir, skill_md, all_dirs)):return _fail(f"Skill '{resolved_name}' is disabled. Enable it with `hermes skills` or inspect the files directly on disk.")if file_path and skill_dir:return _serve_skill_file(