You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Aggregate cost renders $0.00 for positive sub-micro spend #1046
costevent.Event.Micros() = math.Round(CostUSD * 1e6) in costevent.go rounds sub-half-micro costs to 0. The event is still marked priced. After aggregation, CostMicros can be 0 while PricedRequests > 0. renderCostSummary then printsCOST $0.00 — the same output as a genuinely-free priced call.
This can occur for models like Anthropic Haiku's ~$0.25/M input rate, where a 1-token priced call is $2.5e-7 and rounds to 0 micros.
Behavior impact
Small-but-real spend reads as free in the usage-graph total. The per-event cell is unaffected (it renders through formatUSDCell's <$0.0001 floor against the raw CostUSD, not against the rounded micros).
Proposed fix
Add a PositiveCostRequests counter that sources from the pre-rounding CostUSD > 0 predicate:
costevent.eventCost — new predicate exposed
usage.Counts + Counts.Add — new field, folded at every accumulation site
Closing as substantially addressed — but by a different route than proposed here, and with one narrow case left open. Recording both so this is not lost.
What fixed itself
The user-visible symptom — a positive cost rendering as $0.00, indistinguishable from genuinely free — no longer reproduces for any figure that survives rounding. formatUSDTotalMicros (cmd/agentop/tui/prune_saving.go:164) now carries exactly the floor this issue asked for:
ifmicros>0&µs<5_000 {
// Positive but under half a cent.return"<$0.01"
}
And the contract above it states the rule as settled policy rather than a local fix: "NEITHER FORM EVER RENDERS A POSITIVE FIGURE AS ZERO. Cents falls back to <$0.01 and four decimals to <$0.0001." That arrived with the cent-arithmetic extraction out of renderCostSummary, not as a fix for this issue.
The PositiveCostRequests counter proposed here was never implemented — it appears nowhere in the tree. The symptom was closed more cheaply, at the formatter rather than threaded through usage.Counts and every accumulation site.
What is still true
The floor is gated on micros > 0, so the case in this issue's body survives in the aggregate total:
A single 1-token Haiku call at ~$2.5e-7 therefore still reaches the renderer as exactly 0 micros and prints COST $0.00. What changed is that any window whose aggregate clears half a micro now reads <$0.01 instead of $0.00 — which is every realistic window, and why this stopped being observable.
Why close rather than finish it
Distinguishing "rounded to zero" from "actually free" still requires the original fix: a counter sourced from the pre-rounding CostUSD > 0 predicate, threaded through usage.Counts and folded at every accumulation site. That is real work across the cost core for a case that needs a window containing exactly one sub-half-micro priced call and nothing else. The cheap alternative is still correctly ruled out by this issue — clamping Micros() to 1 lies about the figure, and event.go:364 now independently states the same rule for the bound case: "a clamped figure is a wrong number wearing a right label."
Reopen if a real window ever reads $0.00 with priced traffic in it — that would mean the aggregate is rounding to zero in practice, which is the version worth paying for.
Note for anyone following the links above: this issue's file reference is stale. authbridge/authlib/costevent/costevent.go moved to core/cost/event/event.go.
Activity
[-]Aggregate cost renders $0.00 for genuinely positive sub-micro spend[/-][+]Aggregate cost renders $0.00 for positive sub-micro spend[/+]mrsabath commentedon Oct 2, 2026
Closing as substantially addressed — but by a different route than proposed here, and with one narrow case left open. Recording both so this is not lost.
What fixed itself
The user-visible symptom — a positive cost rendering as
$0.00, indistinguishable from genuinely free — no longer reproduces for any figure that survives rounding.formatUSDTotalMicros(cmd/agentop/tui/prune_saving.go:164) now carries exactly the floor this issue asked for:And the contract above it states the rule as settled policy rather than a local fix: "NEITHER FORM EVER RENDERS A POSITIVE FIGURE AS ZERO. Cents falls back to
<$0.01and four decimals to<$0.0001." That arrived with the cent-arithmetic extraction out ofrenderCostSummary, not as a fix for this issue.The
PositiveCostRequestscounter proposed here was never implemented — it appears nowhere in the tree. The symptom was closed more cheaply, at the formatter rather than threaded throughusage.Countsand every accumulation site.What is still true
The floor is gated on
micros > 0, so the case in this issue's body survives in the aggregate total:pricing.MicrosFromUSDstill rounds —math.Round(usd * 1e6)atcore/cost/pricing/cost.go:141Event.Micros()returns0for a sub-half-micro cost whilePriced()staystrue(core/cost/event/event.go:372)core/cost/ledger/writer.go:552then writesCostMicros = 0withPricedRequests = 1A single 1-token Haiku call at ~$2.5e-7 therefore still reaches the renderer as exactly
0micros and printsCOST $0.00. What changed is that any window whose aggregate clears half a micro now reads<$0.01instead of$0.00— which is every realistic window, and why this stopped being observable.Why close rather than finish it
Distinguishing "rounded to zero" from "actually free" still requires the original fix: a counter sourced from the pre-rounding
CostUSD > 0predicate, threaded throughusage.Countsand folded at every accumulation site. That is real work across the cost core for a case that needs a window containing exactly one sub-half-micro priced call and nothing else. The cheap alternative is still correctly ruled out by this issue — clampingMicros()to1lies about the figure, andevent.go:364now independently states the same rule for the bound case: "a clamped figure is a wrong number wearing a right label."Reopen if a real window ever reads
$0.00with priced traffic in it — that would mean the aggregate is rounding to zero in practice, which is the version worth paying for.Note for anyone following the links above: this issue's file reference is stale.
authbridge/authlib/costevent/costevent.gomoved tocore/cost/event/event.go.Tracked on the cost surface under #1113.