Skip to content

RunPricingResolver

Namespace AgentPrism · Assembly AgentPrism.Core.dll

Provides the default IRunPricingResolver implementation. It resolves prices from the model catalog, then AgentPrism:Pricing configuration.

public sealed class RunPricingResolver : IRunPricingResolver

objectRunPricingResolver

IRunPricingResolver

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

When no provider is supplied, such as during historical recalculation, the first provider that has the model name is used from either source. The runs table has no provider column and IModelProviderRegistry.List already orders providers alphabetically. Different prices for a same-named model across providers are a known, accepted limitation; it cannot be resolved without adding a provider column to runs.

RunPricingResolver(IModelProviderRegistry, IOptions<AgentPrismOptions>, ILogger<RunPricingResolver>?)

Section titled “ RunPricingResolver(IModelProviderRegistry, IOptions<AgentPrismOptions>, ILogger<RunPricingResolver>?)”

Initializes a price resolver.

public RunPricingResolver(IModelProviderRegistry registry, IOptions<AgentPrismOptions> options, ILogger<RunPricingResolver>? logger = null)

registry IModelProviderRegistry

The model catalog.

options IOptions<AgentPrismOptions>

The AgentPrism options and Pricing section.

logger ILogger<RunPricingResolver>?

The logger used to report a usage record that contradicts itself, such as more cached input tokens than input tokens in total. Optional: the price is still computed without it.

ArgumentNullException

A dependency is null.

Resolves the cost.

public RunCost? Resolve(string? provider, string? model, RunUsage? usage)

provider string?

The provider name. If null (example: recomputing a historical row), the price is resolved by model name alone, using the first match across providers.

model string?

The model name. Cost does not apply if null or empty.

usage RunUsage?

The token usage. Cost does not apply if null.

RunCost?

null only if model or usage is missing (a case where cost can never apply — for example, a code agent with no bound model). When the model is known, a RunCost is always returned even if pricing is undefined; in that case RunCost.Source is PricingSource.Unknown and the cost fields are nullnot zero.