Interface IBudgetEnforcer
Enforces token and cost budgets on agent runs. Called before and after each
provider call so the engine can stop early or refuse an iteration when the
budget is exhausted.
public interface IBudgetEnforcer
Methods
PreCheckAsync(string?, AgentBudget, AgentUsage, CancellationToken)
Checks whether the agent run is allowed to continue at the start of an
ValueTask<BudgetDecision> PreCheckAsync(string? conversationId, AgentBudget budget, AgentUsage usageSoFar, CancellationToken ct = default)
PreCheckAsync(string?, AgentBudget, AgentUsage, IExchange?, CancellationToken)
with the run's exchange, which
ValueTask<BudgetDecision> PreCheckAsync(string? conversationId, AgentBudget budget, AgentUsage usageSoFar, IExchange? exchange, CancellationToken ct = default)
RecordAndCheckAsync(string?, AgentBudget, AgentUsage, AgentUsage, CancellationToken)
Records usage produced by the iteration and returns a decision whether the agent may
ValueTask<BudgetDecision> RecordAndCheckAsync(string? conversationId, AgentBudget budget, AgentUsage iterationUsage, AgentUsage totalUsage, CancellationToken ct = default)
RecordAndCheckAsync(string?, AgentBudget, AgentUsage, AgentUsage, IExchange?, CancellationToken)
with the
ValueTask<BudgetDecision> RecordAndCheckAsync(string? conversationId, AgentBudget budget, AgentUsage iterationUsage, AgentUsage totalUsage, IExchange? exchange, CancellationToken ct = default)