Share via


FileAgentSkillsProvider Class

Definition

An AIContextProvider that discovers and exposes Agent Skills from filesystem directories.

public sealed class FileAgentSkillsProvider : Microsoft.Agents.AI.AIContextProvider
type FileAgentSkillsProvider = class
    inherit AIContextProvider
Public NotInheritable Class FileAgentSkillsProvider
Inherits AIContextProvider
Inheritance
FileAgentSkillsProvider

Remarks

This provider implements the progressive disclosure pattern from the Agent Skills specification:

  1. Advertise β€” skill names and descriptions are injected into the system prompt (~100 tokens per skill).
  2. Load β€” the full SKILL.md body is returned via the load_skill tool.
  3. Read resources β€” supplementary files are read from disk on demand via the read_skill_resource tool.

Skills are discovered by searching the configured directories for SKILL.md files. Referenced resources are validated at initialization; invalid skills are excluded and logged.

Security: this provider only reads static content. Skill metadata is XML-escaped before prompt embedding, and resource reads are guarded against path traversal and symlink escape. Only use skills from trusted sources.

Constructors

Name Description
FileAgentSkillsProvider(IEnumerable<String>, FileAgentSkillsProviderOptions, ILoggerFactory)

Initializes a new instance of the FileAgentSkillsProvider class that searches multiple directories for skills.

FileAgentSkillsProvider(String, FileAgentSkillsProviderOptions, ILoggerFactory)

Initializes a new instance of the FileAgentSkillsProvider class that searches a single directory for skills.

Properties

Name Description
ProvideInputMessageFilter

Gets the filter function to apply to input messages before providing context via ProvideAIContextAsync(AIContextProvider+InvokingContext, CancellationToken).

(Inherited from AIContextProvider)
StateKey

Gets the key used to store the provider state in the StateBag.

(Inherited from AIContextProvider)
StoreInputMessageFilter

Gets the filter function to apply to request messages before storing context via StoreAIContextAsync(AIContextProvider+InvokedContext, CancellationToken).

(Inherited from AIContextProvider)

Methods

Name Description
GetService(Type, Object)

Asks the AIContextProvider for an object of the specified type serviceType.

(Inherited from AIContextProvider)
GetService<TService>(Object)

Asks the AIContextProvider for an object of type TService.

(Inherited from AIContextProvider)
InvokedAsync(AIContextProvider+InvokedContext, CancellationToken)

Called at the end of the agent invocation to process the invocation results.

(Inherited from AIContextProvider)
InvokedCoreAsync(AIContextProvider+InvokedContext, CancellationToken)

Called at the end of the agent invocation to process the invocation results.

(Inherited from AIContextProvider)
InvokingAsync(AIContextProvider+InvokingContext, CancellationToken)

Called at the start of agent invocation to provide additional context.

(Inherited from AIContextProvider)
InvokingCoreAsync(AIContextProvider+InvokingContext, CancellationToken)

Called at the start of agent invocation to provide additional context.

(Inherited from AIContextProvider)
ProvideAIContextAsync(AIContextProvider+InvokingContext, CancellationToken)

When overridden in a derived class, provides additional AI context to be merged with the input context for the current invocation.

(Inherited from AIContextProvider)
StoreAIContextAsync(AIContextProvider+InvokedContext, CancellationToken)

When overridden in a derived class, processes invocation results at the end of the agent invocation.

(Inherited from AIContextProvider)

Applies to