symfonic.services.budget.errors¶
errors ¶
The failure taxonomy of budgeting.
Three questions an operator asks, so three types. "Is my configuration
impossible?" (BudgetPolicyError — a share that sums past one, a minimum that
cannot fit, a ratio of zero). "Did the content not fit?" (BudgetOverflowError
— the only one that depends on the input rather than the config). "Did the
exact counter I asked for exist?" (ExactCounterUnavailableError — the seam
between an adopter's provider tokenizer and this package's refusal to fetch
one).
All three are configuration failures in the FERR sense: they are raised before
any provider call, so nothing has been sent and nothing has been billed, and an
adopter's existing except ConfigurationError already catches them.
BudgetError ¶
Bases: ConfigurationError
Root of the budgeting taxonomy. Never raised directly.
Parented on :class:ConfigurationError rather than on a fresh root for the
same reason the prompt compiler's taxonomy is: budgeting runs inside plan
compilation, and an adopter who already catches configuration failures
around Agent(...) must not have to learn a second base class.
BudgetOverflowError ¶
Bases: BudgetError
Content exceeded its budget and the policy said to refuse.
Also raised, under every overflow action, when pinned content alone exceeds the budget: dropping or truncating a pinned block produces a context whose missing half is invisible at run time.
BudgetPolicyError ¶
Bases: BudgetError
The declared budget cannot be satisfied by arithmetic, whatever the input.
Raised at construction or at allocation — never mid-request — because a policy whose shares sum past the window is wrong on an empty prompt too.
ExactCounterUnavailableError ¶
Bases: BudgetError
An exact token counter was required and none was registered — or the one offered admits it is not offline.
Refusing here is the point of the class. The alternative, silently estimating for an operator who asked for exact arithmetic, produces billing and truncation numbers that are wrong in a direction nobody can see.