Skip to content

fix(skill-tools): follow symlinks in skill discovery via rglob_follow - #23484

Closed
redpiggy-cyber wants to merge 4 commits into
NousResearch:mainfrom
redpiggy-cyber:fix/rglob-symlink-follow
Closed

fix(skill-tools): follow symlinks in skill discovery via rglob_follow#23484
redpiggy-cyber wants to merge 4 commits into
NousResearch:mainfrom
redpiggy-cyber:fix/rglob-symlink-follow

Conversation

@redpiggy-cyber

Copy link
Copy Markdown
Contributor

What does this PR do?

Fixes skill discovery when the skills directory contains symlinked subdirectories. Python's Path.rglob() intentionally does not descend into symlinked directories (CPython issue #40358), so when users symlink their skills directory (e.g. ~/.hermes/skills/redpiggy -> workspace/skills), skill_manage, skill_view, and skill listing all fail to discover any skills inside the symlinked tree.

Adds rglob_follow() — a lightweight helper in agent/skill_utils.py that uses os.walk(followlinks=True) — and replaces the critical rglob calls in the skill discovery paths.

Related Issue

Fixes #8293

Type of Change

  • 🐛 Bug fix (non-breaking change that fixes an issue)

Changes Made

  • agent/skill_utils.py — Added rglob_follow(root, pattern) generator that uses os.walk(followlinks=True) with EXCLUDED_SKILL_DIRS pruning. Same semantics as Path.rglob() but follows symlinks.
  • tools/skill_manager_tool.py:290_find_skill() now uses rglob_follow(skills_dir, "SKILL.md") instead of skills_dir.rglob("SKILL.md").
  • tools/skill_usage.py:235,577list_agent_created_skill_names() and _find_skill_dir() use rglob_follow for the same reason.
  • tests/agent/test_skill_utils.py — Added 5 tests covering: symlink traversal, nested symlink traversal, excluded-dir pruning, directory name matching, and regular (non-symlink) behavior.

How to Test

  1. Create a skills directory with a symlinked subdirectory:
    mkdir -p /tmp/real-skills/alpha && echo "name: alpha" > /tmp/real-skills/alpha/SKILL.md
    ln -s /tmp/real-skills /tmp/test-skills/redpiggy
  2. Verify the fix:
    from agent.skill_utils import rglob_follow
    from pathlib import Path
    results = list(rglob_follow(Path("/tmp/test-skills"), "SKILL.md"))
    assert len(results) == 1  # Found through symlink
  3. Run the test suite:
    pytest tests/agent/test_skill_utils.py -v

Checklist

Code

  • I've read the Contributing Guide
  • My commit messages follow Conventional Commits
  • I searched for existing PRs to make sure this isn't a duplicate
  • My PR contains only changes related to this fix
  • I've run pytest tests/agent/test_skill_utils.py -v and all 9 tests pass
  • I've tested on my platform: macOS 15.7.5

Documentation & Housekeeping

  • I've updated tool descriptions/schemas if I changed tool behavior — or N/A

PATCH-002 (WhatsApp debounce): fix event.type → event.message_type typo
  that silently broke all WhatsApp DM receiving since 2026-05-09.
PATCH-003 (Weixin debounce): re-apply text batching.
PATCH-004 (pre_gateway_text_send hook): re-apply plugin outbound hook.
PATCH-005 (MoA Requesty router): re-apply with updated models.
Python's Path.rglob() does not descend into symlinked directories
(https://bugs.python.org/issue40358). When users symlink their skills
directory (e.g. ~/.hermes/skills/redpiggy -> workspace/skills),
skill_manage, skill_view, and skill_usage fail to discover any skills
inside the symlinked tree.

Add rglob_follow() helper to agent/skill_utils.py that uses
os.walk(followlinks=True) and replace the critical rglob calls in:
- tools/skill_manager_tool.py (_find_skill)
- tools/skill_usage.py (list_agent_created_skill_names, _find_skill_dir)

Fixes NousResearch#8293
@alt-glitch alt-glitch added type/bug Something isn't working P2 Medium — degraded but workaround exists tool/skills Skills system (list, view, manage) duplicate This issue or pull request already exists labels May 11, 2026
@alt-glitch

Copy link
Copy Markdown
Collaborator

Duplicate of #12624 (same symlink traversal fix for skill discovery). Note: this PR also includes unrelated changes to gateway/platforms, hermes_cli/plugins.py, sessions.db, and tools/mixture_of_agents_tool.py that are not part of the skill symlink fix.

@redpiggy-cyber

Copy link
Copy Markdown
Contributor Author

Closing as duplicate of #12624 — same fix, more comprehensive (8 call sites vs 3, plus cycle guard note). We've been running our local version successfully but defer to the earlier PR. Hope #12624 gets merged soon!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

duplicate This issue or pull request already exists P2 Medium — degraded but workaround exists tool/skills Skills system (list, view, manage) type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bug: symlinked skills under ~/.hermes/skills are omitted from skills_list and bare-name skill_view lookup

2 participants