-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Description
Description
When providing a custom SkillsInstructionPrompt via FileAgentSkillsProviderOptions, the template is prematurely rendered with an empty string during validation, causing all skill entries to be silently discarded from the final instruction prompt.
The LLM never sees any skills in its system instructions, so load_skill / read_skill_resource are never called.
Root Cause
In FileAgentSkillsProvider.cs, method BuildSkillsInstructionPrompt (line ~177):
promptTemplate = string.Format(optionsInstructions, string.Empty);The validation step assigns the rendered result (with {0} replaced by "") back to promptTemplate. When the actual skills XML is later passed to string.Format(promptTemplate, sb.ToString()) at line ~205, the {0} pla
9787
ceholder no longer exists — the skills XML argument is silently discarded.
The default prompt is not affected because it bypasses the validation block entirely.
Steps to Reproduce
- Create a
FileAgentSkillsProviderwith a custom instruction prompt:var options = new FileAgentSkillsProviderOptions { SkillsInstructionPrompt = "Available skills:\n{0}\nUse them wisely." }; var provider = new FileAgentSkillsProvider("path/to/skills", options);
- Call
InvokeCoreAsyncwith a valid skills directory containing at least one skill. - Inspect
result.Instructions.
Expected Behavior
The instructions contain the skills XML inserted at the {0} placeholder:
Available skills:
<skill>
<name>my-skill</name>
<description>Does something useful</description>
</skill>
Use them wisely.
Actual Behavior
The instructions contain an empty skills section — the XML is silently dropped:
Available skills:
Use them wisely.
Why Existing Tests Don't Catch This
The test InvokingCoreAsync_CustomPromptTemplate_UsesCustomTemplateAsync only asserts:
Assert.StartsWith("Custom template:", result.Instructions);It does not verify that the skill name or description actually appears in the rendered output. Adding Assert.Contains("custom-prompt-skill", result.Instructions) would immediately fail.
Proposed Fix
The validation should discard the rendered result and assign the original template separately:
// BEFORE (buggy)
promptTemplate = string.Format(optionsInstructions, string.Empty);
// AFTER (fixed)
_ = string.Format(optionsInstructions, string.Empty); // validate only, discard result
promptTemplate = optionsInstructions; // keep the raw template with {0} intactCode Sample
Error Messages / Stack Traces
Package Versions
Microsoft.Agents.AI 1.0.0-rc2
.NET Version
.NET 8.0
Additional Context
No response
Metadata
Metadata
Assignees
Labels
Type
Projects
Status