CodeAgentSource
AgentPrism.Core.dllA source that exposes code-defined agents in the catalog.
public sealed class CodeAgentSource : IAgentSourceInheritance
Section titled “Inheritance”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”Its priority is 0, the highest. If a database definition has the same name, code wins because it is validated at build time while the database definition is run-time data.
Constructors
Section titled “Constructors”CodeAgentSource(IEnumerable<CodeAgentRegistration>, AgentDefinitionCompiler, CompiledAgentCache, IServiceProvider, ITenantContext)
Section titled “ CodeAgentSource(IEnumerable<CodeAgentRegistration>, AgentDefinitionCompiler, CompiledAgentCache, IServiceProvider, ITenantContext)”Initializes a new code source.
public CodeAgentSource(IEnumerable<CodeAgentRegistration> registrations, AgentDefinitionCompiler compiler, CompiledAgentCache cache, IServiceProvider services, ITenantContext tenantContext)Parameters
Section titled “Parameters”registrations IEnumerable<CodeAgentRegistration>
The code agent registrations.
compiler AgentDefinitionCompiler
The compiler for declarative definitions.
cache CompiledAgentCache
The compiled agent cache.
services IServiceProvider
The service provider supplied to factory registrations.
tenantContext ITenantContext
The tenant context. Code agent definitions are shared across tenants, but
AgentDefinitionCompiler can bind tenant-dependent tools, such as
semantic search, to the ambient tenant at compilation time. See AddVectorSearchTool.
Adding the tenant to the cache key prevents that binding from leaking to another tenant.
Exceptions
Section titled “Exceptions”A dependency is null.
The same agent name is registered more than once.
Properties
Section titled “Properties”Gets the name of the source, used for diagnostics and user interface badges.
public string Name { get; }Property Value
Section titled “Property Value”Priority
Section titled “ Priority”Gets the resolution priority. A lower value is tried first. When two agents share a name, the source with priority wins.
public int Priority { get; }Property Value
Section titled “Property Value”Remarks
Section titled “Remarks”The values in use: 0 for the code source, 10 for the MAF hosting source, 100 for the database source.
Methods
Section titled “Methods”ListAsync(CancellationToken)
Section titled “ ListAsync(CancellationToken)”Lists every agent in this source.
public ValueTask<IReadOnlyList<AgentDescriptor>> ListAsync(CancellationToken cancellationToken = default)Parameters
Section titled “Parameters”cancellationToken CancellationToken
The cancellation token.
Returns
Section titled “Returns”ValueTask<IReadOnlyList<AgentDescriptor>>
The agent summaries.
ResolveAsync(string, string?, CancellationToken)
Section titled “ ResolveAsync(string, string?, CancellationToken)”Resolves the agent with the given name and makes it runnable.
public ValueTask<AIAgent?> ResolveAsync(string agentName, string? culture = null, CancellationToken cancellationToken = default)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 this source does not hold it.