Skip to content

Aggregate cost renders $0.00 for positive sub-micro spend #1046

Description

@evaline-ju

What happens

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
  • renderCostSummary — render <$0.01 when CostMicros == 0 && PositiveCostRequests > 0

Do not clamp Micros() to 1 — it changes the documented rounding semantics and lies about the underlying figure.

Ref #1000 (addressed by #1042)

Assisted-By: Claude (Anthropic AI) noreply@anthropic.com

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions