fix: prevent skill files from being registered as subagents#258
Open
chyax98 wants to merge 1 commit into
Open
Conversation
694abc6 to
4ac21b4
Compare
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
4ac21b4 to
e0c517a
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.mdfiles as agent definitions and registers them as executable subagents.This causes two problems:
subagent listoutput inflates from ~10 real agents to 100+ entries, making it unreadable and polluting the agent namespace.Root cause
loadAgentsFromDirvalidates that a.mdfile hasnameanddescriptionfrontmatter, then registers it as an agent. Skill files also containnameanddescription, so they pass validation and get registered.Fix
After validating
nameanddescription, check whether the frontmatter also contains ametadataorversionkey. 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 formetadataorversionkeys to filter out skill filesVerification
skills.ts) remains unchanged.Fixes #257