Path: redb-route/redb.Route.Llm/Engine/AgentBudgetFactory.cs
Snapshot: redb-route, development snapshot 2026-12-06. This is the development state of the public mirrors; it may differ from the published packages.
License: Apache-2.0. Repository: https://github.com/redbase-app/redb-route
Page: https://redbase.app/src/dev-2026-12-06/redb-route/redb.Route.Llm/Engine/AgentBudgetFactory.cs
----
using redb.Route.Llm.Engine.Governance;
namespace redb.Route.Llm.Engine;
///
/// Translates the nullable budget options of an endpoint / builder into an .
///
/// The nulls matter: null means "this dimension is not limited", while
/// spells that as <= 0. Collapsing an unset option to zero would be harmless here (zero is
/// the same as unset for the enforcer) — but doing it in the URI would not, so the options are
/// appended only when set.
///
///
internal static class AgentBudgetFactory
{
/// Builds the per-run budget; all-null maps to .
public static AgentBudget From(int? inputTokens, int? outputTokens, decimal? costUsd)
=> inputTokens is null && outputTokens is null && costUsd is null
? AgentBudget.Unbounded
: new AgentBudget(inputTokens ?? 0, outputTokens ?? 0, costUsd ?? 0m);
}