From 4fdcae6c91cd85cc7361d76bb44bf7bc5a9f92c0 Mon Sep 17 00:00:00 2001 From: Teknium <127238744+teknium1@users.noreply.github.com> Date: Wed, 15 Apr 2026 17:22:55 -0700 Subject: [PATCH] fix: use absolute skill_dir for external skills (#10313) (#10587) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit _load_skill_payload() reconstructed skill_dir as SKILLS_DIR / relative_path, which is wrong for external skills from skills.external_dirs — they live outside SKILLS_DIR entirely. Scripts and linked files failed to load. Fix: skill_view() now includes the absolute skill_dir in its result dict. _load_skill_payload() uses that directly when available, falling back to the SKILLS_DIR-relative reconstruction only for legacy responses. Closes #10313 --- agent/skill_commands.py | 9 ++++++++- tools/skills_tool.py | 1 + 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/agent/skill_commands.py b/agent/skill_commands.py index 149b4aae..280105da 100644 --- a/agent/skill_commands.py +++ b/agent/skill_commands.py @@ -72,7 +72,14 @@ def _load_skill_payload(skill_identifier: str, task_id: str | None = None) -> tu skill_name = str(loaded_skill.get("name") or normalized) skill_path = str(loaded_skill.get("path") or "") skill_dir = None - if skill_path: + # Prefer the absolute skill_dir returned by skill_view() — this is + # correct for both local and external skills. Fall back to the old + # SKILLS_DIR-relative reconstruction only when skill_dir is absent + # (e.g. legacy skill_view responses). + abs_skill_dir = loaded_skill.get("skill_dir") + if abs_skill_dir: + skill_dir = Path(abs_skill_dir) + elif skill_path: try: skill_dir = SKILLS_DIR / Path(skill_path).parent except Exception: diff --git a/tools/skills_tool.py b/tools/skills_tool.py index 340e4ed5..ed8c8cfb 100644 --- a/tools/skills_tool.py +++ b/tools/skills_tool.py @@ -1263,6 +1263,7 @@ def skill_view(name: str, file_path: str = None, task_id: str = None) -> str: "related_skills": related_skills, "content": content, "path": rel_path, + "skill_dir": str(skill_dir) if skill_dir else None, "linked_files": linked_files if linked_files else None, "usage_hint": "To view linked files, call skill_view(name, file_path) where file_path is e.g. 'references/api.md' or 'assets/config.yaml'" if linked_files