fix: prevent reading SKILL.md files when listing available skills

When users ask to list/show/display available skills, the model should
use the information already provided in <available_skills> instead of
reading each SKILL.md file unnecessarily.

Adds <if_user_asks_to_list_skills> section to the skills system prompt
to explicitly instruct the model to use the existing name, description,
and location fields for informational queries.

Closes #10393
This commit is contained in:
Roo Code 2025-12-31 13:14:56 +00:00
parent 2068531801
commit 333b301260
2 changed files with 28 additions and 0 deletions

View file

@ -29,4 +29,25 @@ describe("getSkillsSection", () => {
await expect(getSkillsSection(undefined, "code")).resolves.toBe("")
await expect(getSkillsSection({ getSkillsForMode: vi.fn() }, undefined)).resolves.toBe("")
})
it("should include instructions to not read SKILL.md files when listing skills", async () => {
const mockSkillsManager = {
getSkillsForMode: vi.fn().mockReturnValue([
{
name: "test-skill",
description: "Test skill description",
path: "/path/to/test-skill/SKILL.md",
source: "global" as const,
},
]),
}
const result = await getSkillsSection(mockSkillsManager, "code")
// Verify the new section for listing skills is present
expect(result).toContain("<if_user_asks_to_list_skills>")
expect(result).toContain("</if_user_asks_to_list_skills>")
expect(result).toContain("use ONLY the information already provided in <available_skills>")
expect(result).toContain("Do NOT read any SKILL.md files for informational queries")
})
})

View file

@ -68,6 +68,13 @@ Step 2: Branching Decision
- Do NOT respond outside the skill-defined flow.
</if_skill_applies>
<if_user_asks_to_list_skills>
- When the user asks to list, show, display, or enumerate available skills, use ONLY the information already provided in <available_skills> above.
- The <name>, <description>, and <location> fields provide all necessary information to describe available skills.
- Do NOT read any SKILL.md files for informational queries about what skills exist.
- This applies to requests like "list all skills", "what skills are available", "show me the skills", etc.
</if_user_asks_to_list_skills>
<if_no_skill_applies>
- Proceed with a normal response.
- Do NOT load any SKILL.md files.