CompositeAgentCatalog
AgentPrism.Core.dllCombines all IAgentSource sources in one catalog and wraps resolved agents with registered IAgentDecorator decorators.
public sealed class CompositeAgentCatalog : IAgentCatalogInheritance
Section titled “Inheritance”object ← CompositeAgentCatalog
Implements
Section titled “Implements”Inherited Members
Section titled “Inherited Members”object.GetType(), object.ToString(), object.Equals(object?), object.Equals(object?, object?), object.ReferenceEquals(object?, object?), object.GetHashCode()
Remarks
Section titled “Remarks”Sources are tried in IAgentSource.Priority order. When names collide, the higher-priority source with the lower number wins. The losing source is omitted from the list and the catalog logs a warning.
Constructors
Section titled “Constructors”CompositeAgentCatalog(IEnumerable<IAgentSource>, IEnumerable<IAgentDecorator>, ILogger<CompositeAgentCatalog>)
Section titled “ CompositeAgentCatalog(IEnumerable<IAgentSource>, IEnumerable<IAgentDecorator>, ILogger<CompositeAgentCatalog>)”Initializes a new composite catalog.
public CompositeAgentCatalog(IEnumerable<IAgentSource> sources, IEnumerable<IAgentDecorator> decorators, ILogger<CompositeAgentCatalog> logger)Parameters
Section titled “Parameters”sources IEnumerable<IAgentSource>
The agent sources.
decorators IEnumerable<IAgentDecorator>
The decorators applied to resolved agents.
logger ILogger<CompositeAgentCatalog>
The logger.
Exceptions
Section titled “Exceptions”A dependency is null.
Methods
Section titled “Methods”ListAsync(CancellationToken)
Section titled “ ListAsync(CancellationToken)”Lists the agents from every source. On a name clash the source with the higher priority wins, and the lower-priority one is not added to the list.
public ValueTask<IReadOnlyList<AgentDescriptor>> ListAsync(CancellationToken cancellationToken = default)Parameters
Section titled “Parameters”cancellationToken CancellationToken
The cancellation token.
Returns
Section titled “Returns”ValueTask<IReadOnlyList<AgentDescriptor>>
Agent summaries ordered by name.
ResolveAsync(string, string?, CancellationToken)
Section titled “ ResolveAsync(string, string?, CancellationToken)”Resolves the agent with the given name. The returned agent is wrapped by the run recording decorator; every run is written into IRunStore.
public ValueTask<AIAgent?> ResolveAsync(string agentName, string? culture, CancellationToken cancellationToken)Parameters
Section titled “Parameters”agentName string
The agent name.
culture string?
The requested culture, resolved against the definition’s culture-keyed instructions
(see AgentDefinition.InstructionsByCulture). null uses the
definition’s default instructions.
cancellationToken CancellationToken
The cancellation token.
Returns
Section titled “Returns”ValueTask<AIAgent?>
The agent, or null when no source holds it.
ResolveAsync(string, int?, string?, CancellationToken)
Section titled “ ResolveAsync(string, int?, string?, CancellationToken)”Resolves an agent by name and by a specific definition version.
Code agents (AgentDefinitionOrigin.Code) have no version history;
AgentPrismException is thrown when version is
given for a code agent.
public ValueTask<AIAgent?> ResolveAsync(string agentName, int? version, string? culture = null, CancellationToken cancellationToken = default)Parameters
Section titled “Parameters”agentName string
The agent name.
version int?
The requested definition version. When null it behaves like IAgentCatalog.ResolveAsync (the current version).
culture string?
See IAgentCatalog.ResolveAsync.
cancellationToken CancellationToken
The cancellation token.
Returns
Section titled “Returns”ValueTask<AIAgent?>
The agent, or null when it is not found.
Exceptions
Section titled “Exceptions”version is given and the agent comes from code, or that version
does not exist.