Skip to content

.NET: [Bug]: FileAgentSkillsProvider accepts SkillsInstructionPrompt without {0} and drops the generated skills list #4638

Description

@moonbox3

Summary

FileAgentSkillsProvider documents that SkillsInstructionPrompt must include a {0} placeholder for the generated skills list, but the current validation only checks whether string.Format(template, string.Empty) succeeds. As a result, templates with no placeholder are accepted and silently omit the generated skills list from the final instructions.

Affected code

  • dotnet/src/Microsoft.Agents.AI/Skills/FileAgentSkillsProvider.cs
  • dotnet/src/Microsoft.Agents.AI/Skills/FileAgentSkillsProviderOptions.cs
  • dotnet/tests/Microsoft.Agents.AI.UnitTests/AgentSkills/FileAgentSkillsProviderTests.cs

Current behavior

A template like:

new FileAgentSkillsProviderOptions
{
    SkillsInstructionPrompt = "Custom template"
}

is accepted, and the final instructions become just Custom template rather than including the discovered skills.

Expected behavior

If a custom SkillsInstructionPrompt does not contain a usable {0} placeholder, construction should fail with ArgumentException, matching the documented contract.

Why this is a bug

The public option docs say to use {0} as the placeholder for the generated skills list. The implementation currently enforces only valid format-string syntax, not presence of the placeholder itself, so valid-but-placeholder-free templates are accepted and produce incorrect output.

Likely fix

Tighten validation in BuildSkillsInstructionPrompt(...) so it rejects templates that do not actually reference argument 0, and add a unit test for a placeholder-free template.

Notes

I checked the current open .NET issues in this repo on 2026-03-12 and did not find a clear duplicate for this specific bug.

Metadata

Metadata

Assignees

Labels

.NETUsage: [Issues, PRs], Target: .NetbugUsage: [Issues], Target: all issues (Legacy, prefer issue type: bug)

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions