AgentSkillsProvider Class

Definition

An AIContextProvider that exposes agent skills from one or more AgentSkillsSource instances.

public sealed class AgentSkillsProvider : Microsoft.Agents.AI.AIContextProvider, IDisposable
type AgentSkillsProvider = class
    inherit AIContextProvider
    interface IDisposable
Public NotInheritable Class AgentSkillsProvider
Inherits AIContextProvider
Implements IDisposable
Inheritance
AgentSkillsProvider
Implements

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.
  2. Load — the full skill body is returned via the load_skill tool.
  3. Read resources — supplementary content is read on demand via the read_skill_resource tool.
  4. Run scripts — scripts are executed via the run_skill_script tool (when scripts exist).

The provider can optionally own the lifetime of its underlying AgentSkillsSource. When constructed via one of the convenience constructors (skill paths or in-memory skills) or via AgentSkillsProviderBuilder, the source pipeline is created internally and owned by the provider, so disposing the provider disposes the pipeline. When constructed from a caller-supplied AgentSkillsSource, ownership is controlled by the ownsSource constructor parameter and defaults to the caller retaining ownership.

Constructors

Name Description
AgentSkillsProvider(AgentSkill[])

Initializes a new instance of the AgentSkillsProvider class. Duplicate skill names are automatically deduplicated (first occurrence wins).

AgentSkillsProvider(AgentSkillsSource, AgentSkillsProviderOptions, ILoggerFactory, Boolean)

Initializes a new instance of the AgentSkillsProvider class from a custom AgentSkillsSource. Unlike other constructors, this one does not apply automatic deduplication, allowing callers to customize deduplication behavior via the source pipeline.

AgentSkillsProvider(IEnumerable<AgentSkill>, AgentSkillsProviderOptions, ILoggerFactory)

Initializes a new instance of the AgentSkillsProvider class. Duplicate skill names are automatically deduplicated (first occurrence wins).

AgentSkillsProvider(IEnumerable<String>, AgentFileSkillScriptRunner, AgentFileSkillsSourceOptions, AgentSkillsProviderOptions, ILoggerFactory)

Initializes a new instance of the AgentSkillsProvider class that discovers file-based skills from multiple directories. Duplicate skill names are automatically deduplicated (first occurrence wins).

AgentSkillsProvider(String, AgentFileSkillScriptRunner, AgentFileSkillsSourceOptions, AgentSkillsProviderOptions, ILoggerFactory)

Initializes a new instance of the AgentSkillsProvider class that discovers file-based skills from a single directory. Duplicate skill names are automatically deduplicated (first occurrence wins).

Fields

Name Description
LoadSkillToolName

The name of the tool that loads a skill.

ReadSkillResourceToolName

The name of the tool that reads a skill resource.

RunSkillScriptToolName

The name of the tool that runs a skill script.

Properties

Name Description
AllToolsAutoApprovalRule

Gets an auto-approval rule that approves all skill tools, including the script execution tool (RunSkillScriptToolName).

ProvideInputMessageFilter

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

(Inherited from AIContextProvider)
ReadOnlyToolsAutoApprovalRule

Gets an auto-approval rule that approves the read-only skill tools (LoadSkillToolName and ReadSkillResourceToolName).

StateKeys

Gets the set of keys used to store the provider state in the StateBag.

(Inherited from AIContextProvider)
StoreInputRequestMessageFilter

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

(Inherited from AIContextProvider)
StoreInputResponseMessageFilter

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

(Inherited from AIContextProvider)

Methods

Name Description
Dispose()

Releases the resources used by this provider. When the provider owns its underlying AgentSkillsSource (see the ownsSource constructor parameter), the source is disposed as well.

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