fix(agents): enforce exact skill path from <available_skills>

The agent could fabricate or guess SKILL.md paths instead of using the
exact <location> value provided in <available_skills>. Add an explicit
prompt-level constraint to prevent path hallucination.

Refs: #50590, #43735, #43383
This commit is contained in:
tianguicheng
2026-04-29 14:27:58 +08:00
committed by sallyom
parent 978bc53e80
commit 09d4896344

View File

@@ -202,7 +202,7 @@ function buildSkillsSection(params: { skillsPrompt?: string; readToolName: strin
return [
"## Skills (mandatory)",
"Before replying: scan <available_skills> <description> entries.",
`- If exactly one skill clearly applies: read its SKILL.md at <location> with \`${params.readToolName}\`, then follow it.`,
`- If exactly one skill clearly applies: read its SKILL.md at <location> with \`${params.readToolName}\`, then follow it. You MUST use the exact <location> value from <available_skills>; never guess, fabricate, or hard-code a skill file path.`,
"- If multiple could apply: choose the most specific one, then read/follow it.",
"- If none clearly apply: do not read any SKILL.md.",
"Constraints: never read more than one skill up front; only read after selecting.",