rossoctl / rossoctl/cortex

Aggregate cost renders $0.00 for positive sub-micro spend

Open
#1,046 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Go
Stars
13
Forks
40
Avg merge
12h 17m
Merged PRs (30d)
156

Description

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

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with authbridge/authlib/costevent/costevent.go and trace usage.Counts, Counts.Add, and renderCostSummary through every accumulation site. Confirm the pre-rounding positive-cost count reaches the summary, then run the existing Go tests covering cost events, usage aggregation, and rendering; done means positive sub-micro spend renders < $0.01 while genuinely free priced calls still render $0.00.

Written by the indexing model from the issue text.

Assessment

Tech stack
go
Domain
backend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Active
Clarity
Clearly specified
Newbie friendliness
75/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.