Skip to content

fix(models): apply Qwen discounts through OpenRouter#3902

Open
chrarnoldus wants to merge 5 commits into
mainfrom
fix/qwen-custom-pricing
Open

fix(models): apply Qwen discounts through OpenRouter#3902
chrarnoldus wants to merge 5 commits into
mainfrom
fix/qwen-custom-pricing

Conversation

@chrarnoldus

Copy link
Copy Markdown
Contributor

Summary

  • Remove Qwen3.7 Max and Plus from Kilo-exclusive Alibaba routing so their OpenRouter entries remain available.
  • Centralize model-ID pricing multipliers and optional display percentages in custom-pricing.ts.
  • Apply custom prices to the model list and billed usage while preserving upstream cost in market_cost.

Verification

  • Manual verification not run before PR creation, per requested workflow; focused automated validation follows after push.

Visual Changes

N/A

Reviewer Notes

Review the ordering in usage processing: abuse reporting and market_cost retain upstream spend before the custom billed price is applied.

Co-authored-by: kiloconnect[bot] <240665456+kiloconnect[bot]@users.noreply.github.com>
@chrarnoldus chrarnoldus self-assigned this Jun 10, 2026
});
});

test('applies custom usage pricing independently of the display percentage', () => {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

SUGGESTION: Missing applyCustomPricingToModel test for Qwen Plus

The test block covers applyCustomPricingToCost_mUsd for both Qwen Max and Plus, but applyCustomPricingToModel (the display-facing path) is only exercised for Qwen Max. A parallel test for QWEN37_PLUS_MODEL_ID would confirm the display name suffix (20% off) and the discounted pricing fields are produced correctly, and guard against future percentage vs multiplier drift.

@kilo-code-bot

kilo-code-bot Bot commented Jun 10, 2026

Copy link
Copy Markdown
Contributor

Code Review Summary

Status: 1 Issue Found | Recommendation: Merge

Executive Summary

The latest commit refactors calculateCustomCost_mUsd to accept JustTheCostsUsageStats directly and moves the uncachedInputTokens derivation into the function itself; the one outstanding suggestion — a missing applyCustomPricingToModel test for Qwen Plus — remains unaddressed.

Overview

Severity Count
CRITICAL 0
WARNING 0
SUGGESTION 1
Issue Details (click to expand)

SUGGESTION

File Line Issue
apps/web/src/lib/ai-gateway/custom-pricing.test.ts N/A applyCustomPricingToModel is tested for Qwen Max only — no parallel test covering Qwen Plus display name (20% off) and its pricing fields
Files Reviewed (3 files changed in new commit)
  • apps/web/src/lib/ai-gateway/custom-pricing.ts — refactored calculateCustomCost_mUsd signature to accept JustTheCostsUsageStats; no issues
  • apps/web/src/lib/ai-gateway/custom-pricing.test.ts — updated field names to match new type; 1 outstanding suggestion carried forward
  • apps/web/src/lib/ai-gateway/processUsage.ts — moved custom cost computation earlier and simplified assignment; no issues

Fix these issues in Kilo Cloud


Reviewed by claude-4.6-sonnet-20260217 · 538,419 tokens

Review guidance: REVIEW.md from base branch main

@chrarnoldus chrarnoldus marked this pull request as draft June 10, 2026 09:27
Co-authored-by: kiloconnect[bot] <240665456+kiloconnect[bot]@users.noreply.github.com>
@chrarnoldus chrarnoldus marked this pull request as ready for review June 10, 2026 12:45
chrarnoldus and others added 3 commits June 10, 2026 15:16
Refactor `calculateCustomCost_mUsd` to use `JustTheCostsUsageStats` instead of the legacy `Usage` type. The function now internally calculates `uncachedInputTokens` from the provided usage statistics, simplifying the call site in `processUsage.ts`.

Updated tests to reflect the new usage object structure and token property names.

Co-authored-by: kiloconnect[bot] <240665456+kiloconnect[bot]@users.noreply.github.com>
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