CachingAgentSkillsSource Class

Definition

A skill source decorator that caches the result of the inner source's GetSkillsAsync(AgentSkillsSourceContext, CancellationToken) call, returning the cached list on subsequent invocations.

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

Remarks

Concurrent callers are serialized per cache key so that only one underlying fetch runs at a time. Once a fetch succeeds, the result is cached and shared by all subsequent callers.

When RefreshInterval is set, a cached result is returned only while it is younger than the interval; once it expires, the next caller re-invokes the inner source and replaces the cached result. When the interval is null, the cached result never expires.

The fetch observes the initiating caller's cancellation token. If that caller cancels, the fetch is cancelled and the result is not cached; the next waiting caller starts a fresh fetch. Likewise, a fetch that fails is not cached and subsequent calls will retry.

Constructors

Name Description
CachingAgentSkillsSource(AgentSkillsSource, CachingAgentSkillsSourceOptions)

Initializes a new instance of the CachingAgentSkillsSource class.

Properties

Name Description
InnerSource

Gets the inner skill source that receives delegated operations.

(Inherited from DelegatingAgentSkillsSource)

Methods

Name Description
Dispose()

Releases all resources used by this source.

(Inherited from AgentSkillsSource)
Dispose(Boolean)

Releases the unmanaged resources used by this source and optionally releases the managed resources.

(Inherited from DelegatingAgentSkillsSource)
GetSkillsAsync(AgentSkillsSourceContext, CancellationToken)

Gets the skills provided by this source.

Applies to