8000 .NET: [Bug]: `FileAgentSkillsProvider` custom `SkillsInstructionPrompt` silently drops all skills · Issue #4344 · microsoft/agent-framework · GitHub
[go: up one dir, main page]

Skip to content

.NET: [Bug]: FileAgentSkillsProvider custom SkillsInstructionPrompt silently drops all skills #4344

@piotresky

Description

@piotresky

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

  1. Create a FileAgentSkillsProvider with a custom instruction prompt:
    var options = new FileAgentSkillsProviderOptions
    {
        SkillsInstructionPrompt = "Available skills:\n{0}\nUse them wisely."
    };
    var provider = new FileAgentSkillsProvider("path/to/skills", options);
  2. Call InvokeCoreAsync with a valid skills directory containing at least one skill.
  3. 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} intact

Code 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

Labels

.NETbugSomething isn't workingv1.0Features being tracked for the version 1.0 GA

Type

Projects

Status

Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions

    0