Skip to content

fix(auto-routing-benchmark): bill BYOK sweep completions at upstream cost - #9000

Open
iscekic wants to merge 1 commit into
mainfrom
fix/sweep-byok-cost
Open

iscekic wants to merge 1 commit into
mainfrom
fix/sweep-byok-cost

Conversation

@iscekic

@iscekic iscekic commented Oct 28, 2026

Copy link
Copy Markdown
Collaborator

The offline sweep reads the billed cost of each completion. For a BYOK response, OpenRouter's usage.cost is only its routing fee, and the provider bills usage.cost_details.upstream_inference_cost. The sweep now reads that upstream cost when is_byok is true, which matches the gateway's billing rule in processUsage.shared.ts. A BYOK response without an upstream cost reports an unknown cost.

Verification: vitest run src/scoreboard/sweep.test.ts (27 passed; the two new BYOK cases fail without the change), tsgo --noEmit, oxlint and oxfmt on the changed files.

Production prerequisites: none. The change affects only the local offline sweep command and its scoreboard input.

…cost

Offline sweep completions report usage.cost_details.upstream_inference_cost when the response is BYOK, matching the gateway billing rule. A BYOK response without an upstream cost reports an unknown cost.
@kilo-code-bot

kilo-code-bot Bot commented Oct 28, 2026 •

Copy link
Copy Markdown
Contributor

Code Review Summary

Status: No Issues Found | Recommendation: Merge

Executive Summary

The BYOK sweep cost change is small and sound: it reads usage.cost_details.upstream_inference_cost when is_byok is true, falls back to usage.cost otherwise, and reports an unknown cost when a BYOK response omits the upstream cost, with tests covering all three paths.

Assumptions: The comparison against the gateway billing rule was verified in packages/web-shared/src/lib/ai-gateway/processUsage.shared.ts; the sweep does not send server-tool or plugin requests, so the gateway's additional non-inference charges do not apply. No memory-leak surface exists in the changed lines (schema fields plus a value assignment; no new listeners, timers, or streams).

Files Reviewed (2 files)
  • services/auto-routing-benchmark/src/scoreboard/sweep.ts
  • services/auto-routing-benchmark/src/scoreboard/sweep.test.ts

Reviewed by deepseek-flash-latest · Input: 51K · Output: 7K · Cached: 567.2K

Review guidance: REVIEW.md from base branch main

This branch has not been deployed

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant