ModelProviderRegistry
AgentPrism.Core.dllRegistry that holds the registered IModelProvider implementations by name, and the single place that assembles the model-call pipeline.
public sealed class ModelProviderRegistry : IModelProviderRegistryInheritance
Section titled “Inheritance”object ← ModelProviderRegistry
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”By default no provider is registered; the AgentPrism.OpenAI package
adds the first provider with UseOpenAI. Trying to compile
while no provider is registered produces a clear error.
The entire pipeline is assembled here.
Previously the four provider packages each assembled the
UseFunctionInvocation + UseOpenTelemetry chain
inside themselves; every ring the registry wrapped stayed OUTSIDE
that chain, making it impossible to write a ring that sees the tool-call
turns. Now IModelProvider returns the raw
client and the pipeline is assembled in a single place; a third-party
provider inherits every ring for free too.
Constructors
Section titled “Constructors”ModelProviderRegistry(IEnumerable<IModelProvider>, ModelProviderCircuitBreaker?, IAttachmentStore?, ITenantContext?, ContentGuardPipeline?, ILoggerFactory?, ProviderConcurrencyLimiter?, ITenantProviderBindingStore?, ITenantEgressPolicyStore?, TenantProviderCredentialResolver?)
Section titled “ ModelProviderRegistry(IEnumerable<IModelProvider>, ModelProviderCircuitBreaker?, IAttachmentStore?, ITenantContext?, ContentGuardPipeline?, ILoggerFactory?, ProviderConcurrencyLimiter?, ITenantProviderBindingStore?, ITenantEgressPolicyStore?, TenantProviderCredentialResolver?)”Creates a new registry from the registered providers.
public ModelProviderRegistry(IEnumerable<IModelProvider> providers, ModelProviderCircuitBreaker? circuitBreaker = null, IAttachmentStore? attachmentStore = null, ITenantContext? tenantContext = null, ContentGuardPipeline? contentGuards = null, ILoggerFactory? loggerFactory = null, ProviderConcurrencyLimiter? concurrencyLimiter = null, ITenantProviderBindingStore? tenantProviderBindings = null, ITenantEgressPolicyStore? tenantEgressPolicies = null, TenantProviderCredentialResolver? credentialResolver = null)Parameters
Section titled “Parameters”providers IEnumerable<IModelProvider>
The model providers.
circuitBreaker ModelProviderCircuitBreaker?
The circuit breaker that wraps the produced clients. If null, no wrapping is done (for example, in directly constructed tests).
attachmentStore IAttachmentStore?
The store used to resolve attachment references. If not given together
with tenantContext, no attachment-resolving wrapper is added.
tenantContext ITenantContext?
The tenant context used for attachment resolution.
contentGuards ContentGuardPipeline?
The content inspection pipeline. If null or no IContentGuard is registered, the inspection wrapper is never added.
loggerFactory ILoggerFactory?
The logger factory for UseFunctionInvocation and
UseOpenTelemetry. If null, MAF uses its own default.
concurrencyLimiter ProviderConcurrencyLimiter?
The per-provider outgoing concurrency limiter. If null, no limiting wrapper is added.
tenantProviderBindings ITenantProviderBindingStore?
The per-tenant provider binding store (BYOK). If
null, or if tenantContext is
null, ModelProviderRegistry.CreateChatClientAsync behaves
exactly like ModelProviderRegistry.CreateChatClient.
tenantEgressPolicies ITenantEgressPolicyStore?
The per-tenant egress policy store. If null, no tenant is restricted.
credentialResolver TenantProviderCredentialResolver?
Resolves a TenantProviderBinding into a
ModelProviderCredential. Required together with
tenantProviderBindings for BYOK to take effect.
Exceptions
Section titled “Exceptions”providers is null.
The same provider name has been registered more than once.
Methods
Section titled “Methods”CreateChatClient(ModelBinding)
Section titled “ CreateChatClient(ModelBinding)”Produces a chat client for the given binding, using the provider’s setup-time credential.
public IChatClient CreateChatClient(ModelBinding binding)Parameters
Section titled “Parameters”binding ModelBinding
The model binding.
Returns
Section titled “Returns”IChatClient
The chat client.
Remarks
Section titled “Remarks”This overload does not resolve a tenant provider binding (BYOK) or check an egress policy: both need an async store lookup, which this synchronous method cannot perform. Callers that must honor a tenant’s own credential and egress policy — this includes the real agent-run compile path — use IModelProviderRegistry.CreateChatClientAsync instead.
Exceptions
Section titled “Exceptions”No provider is registered with the name in ModelBinding.Provider.
CreateChatClientAsync(ModelBinding, CancellationToken)
Section titled “ CreateChatClientAsync(ModelBinding, CancellationToken)”Produces a chat client for the given binding, first resolving the current tenant’s own provider credential and egress policy.
public ValueTask<IChatClient> CreateChatClientAsync(ModelBinding binding, CancellationToken cancellationToken = default)Parameters
Section titled “Parameters”binding ModelBinding
The model binding.
cancellationToken CancellationToken
The cancellation token.
Returns
Section titled “Returns”ValueTask<IChatClient>
The chat client.
Remarks
Section titled “Remarks”When no tenant context is registered, or the tenant has no binding for the provider, behavior is identical to IModelProviderRegistry.CreateChatClient (the no-surprises rule: zero surprise when BYOK is not configured).
Exceptions
Section titled “Exceptions”No provider is registered with the name in ModelBinding.Provider, the tenant’s egress policy does not allow the provider, or the tenant’s provider binding cannot be resolved to a credential value.
HasTenantProviderOverrideAsync(ModelBinding, CancellationToken)
Section titled “ HasTenantProviderOverrideAsync(ModelBinding, CancellationToken)”Reports whether the current tenant has its own provider binding for
binding’s primary provider or any of its
ModelBinding.Fallbacks (BYOK).
public ValueTask<bool> HasTenantProviderOverrideAsync(ModelBinding binding, CancellationToken cancellationToken = default)Parameters
Section titled “Parameters”binding ModelBinding
The model binding to check.
cancellationToken CancellationToken
The cancellation token.
Returns
Section titled “Returns”true if a tenant-specific credential would be baked into the chat client IModelProviderRegistry.CreateChatClientAsync produces for this binding.
Remarks
Section titled “Remarks”A compiled agent’s chat client is a fixed pipeline object — once a
tenant’s credential is resolved into it, changing or deleting the
underlying binding has no further effect on that object. A cache
keyed only by definition identity (CompiledAgentCache) must
therefore never hold an agent built with a tenant-specific credential;
callers use this method to decide whether to bypass that cache.
List()
Section titled “ List()”Returns the definitions of the registered providers.
public IReadOnlyList<ModelProviderDescriptor> List()Returns
Section titled “Returns”IReadOnlyList<ModelProviderDescriptor>
The provider definitions.