Skip to content

CompositeAgentCatalog

Namespace AgentPrism · Assembly AgentPrism.Core.dll

Combines all IAgentSource sources in one catalog and wraps resolved agents with registered IAgentDecorator decorators.

public sealed class CompositeAgentCatalog : IAgentCatalog

objectCompositeAgentCatalog

IAgentCatalog

object.GetType(), object.ToString(), object.Equals(object?), object.Equals(object?, object?), object.ReferenceEquals(object?, object?), object.GetHashCode()

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.

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)

sources IEnumerable<IAgentSource>

The agent sources.

decorators IEnumerable<IAgentDecorator>

The decorators applied to resolved agents.

logger ILogger<CompositeAgentCatalog>

The logger.

ArgumentNullException

A dependency is null.

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)

cancellationToken CancellationToken

The cancellation token.

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)

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.

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)

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.

ValueTask<AIAgent?>

The agent, or null when it is not found.

AgentPrismException

version is given and the agent comes from code, or that version does not exist.