AgentSkillsProvider Class
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
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
- Implements
Remarks
This provider implements the progressive disclosure pattern from the Agent Skills specification:
- Advertise — skill names and descriptions are injected into the system prompt.
- Load — the full skill body is returned via the
load_skilltool. - Read resources — supplementary content is read on demand via the
read_skill_resourcetool. - Run scripts — scripts are executed via the
run_skill_scripttool (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 |
| GetService(Type, Object) |
Asks the AIContextProvider for an object of the specified type |
| GetService<TService>(Object) |
Asks the AIContextProvider for an object of type |
| 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) |