Skip to content

fix: prevent skill files from being registered as subagents#258

Open
chyax98 wants to merge 1 commit into
nicobailon:mainfrom
chyax98:fix/skill-files-registered-as-agents
Open

fix: prevent skill files from being registered as subagents#258
chyax98 wants to merge 1 commit into
nicobailon:mainfrom
chyax98:fix/skill-files-registered-as-agents

Conversation

@chyax98

@chyax98 chyax98 commented Jun 6, 2026

Copy link
Copy Markdown

Problem

The agent discovery scanner recursively walks the user agent directory tree looking for agent definition files. Because skill packages install their sub-skills under the same tree, the scanner treats SKILL.md files as agent definitions and registers them as executable subagents.

This causes two problems:

  1. Concept conflation: Skills (prompt fragments meant to be injected into an agent's system prompt) are registered as agents (independent sub-processes with their own model/tools/context).
  2. Registry bloat: subagent list output inflates from ~10 real agents to 100+ entries, making it unreadable and polluting the agent namespace.

Root cause

loadAgentsFromDir validates that a .md file has name and description frontmatter, then registers it as an agent. Skill files also contain name and description, so they pass validation and get registered.

Fix

After validating name and description, check whether the frontmatter also contains a metadata or version key. These keys are standard in skill files but not used in agent definitions. If either is present, skip the file instead of registering it as an agent.

This is robust regardless of where skill files live in the directory tree — no hard-coded directory names needed.

Changes

  • src/agents/agents.ts:
    • loadAgentsFromDir: added frontmatter check for metadata or version keys to filter out skill files

Verification

  • All 463 existing unit tests pass.
  • The fix is surgical: only the agent discovery path is affected; skill resolution (skills.ts) remains unchanged.

Fixes #257

@chyax98 chyax98 force-pushed the fix/skill-files-registered-as-agents branch from 694abc6 to 4ac21b4 Compare June 6, 2026 19:57
Agent discovery recursively walks the ~/.agents/ directory looking for
agent definition files. Because skill packages install their sub-skills
under the same tree, the scanner treats SKILL.md files as agent
definitions and registers them as executable subagents.

This causes two problems:
1. Concept conflation: Skills (prompt fragments) are registered as
   agents (independent sub-processes with model/tools/context).
2. Registry bloat: subagent list inflates from ~10 real agents to
   100+ entries, making it unreadable.

Fix: In loadAgentsFromDir, after validating that a .md file has name
and description frontmatter, check whether it also contains a
metadata or version key. These keys are standard in skill files
but not used in agent definitions. If either is present, skip the
file instead of registering it as an agent.

This is robust regardless of where skill files live in the tree.

Closes nicobailon#257
@chyax98 chyax98 force-pushed the fix/skill-files-registered-as-agents branch from 4ac21b4 to e0c517a Compare June 6, 2026 19:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Skill files incorrectly registered as subagents, causing duplicate entries and namespace pollution

2 participants