[P1 cost safety] Agent cost budgets fail open when pricing is missing or set to zero #132
Labels
No labels
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
needs-review
quasar
question
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
nsaspy/quasar-ui#132
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Finding
Agent cost limits are presented as hard budgets, but the implementation fails open in several common states.
Missing pricing is treated as free
AgentSystem.jsxsupplies an all-zero pricing record whenever a model has no configured price:calculateCost()then records every request as$0, somaxCostUsd, daily limits, and monthly limits never stop the run. There appears to be no normal UI path that requires pricing before enabling a paid model.Explicit zero limits become unlimited
The launch check uses
|| Infinity:An explicit
0therefore becomes unlimited.budgetState()also skips every zero-valued limit:The hard limit is checked after the provider charge
A full model request is made before its calculated cost is checked. One call can exceed the remaining budget by the entire request amount.
Required fix
Fail closed for paid/unknown remote models
Represent unknown pricing explicitly rather than as zero:
Before a paid remote run:
Local/free models should be marked explicitly as free; absence of data must not mean free.
Preserve zero as a real hard stop
budgetState()must distinguish absent limits from zero:Bound the next request before sending it
Derive the maximum output tokens from all remaining limits:
Because input token cost is not known exactly before sending, reserve a conservative estimate or clearly label the cost cap as approximate and require a configurable safety margin.
Prevent concurrent global-budget races
Daily/monthly budget checking and run creation need a reservation/lease in one serialized application-state operation. Two runs must not both observe the same remaining global budget.
Acceptance criteria
$0.