Skip to content

feat(ai-gateway): add weighted routing for Auto Free models - #5023

Merged
chrarnoldus merged 2 commits into
mainfrom
summer-linen
Aug 5, 2026
Merged

feat(ai-gateway): add weighted routing for Auto Free models#5023
chrarnoldus merged 2 commits into
mainfrom
summer-linen

Conversation

@chrarnoldus

Copy link
Copy Markdown
Contributor

Summary

  • store hardcoded weights alongside Auto Free model IDs
  • route sticky Auto Free selections through weighted buckets after availability filtering
  • preserve the current distribution with weight 1 defaults while allowing one-value routing bias changes

Verification

  • pnpm --filter web exec jest --runInBand src/lib/ai-gateway/models.test.ts src/lib/ai-gateway/auto-model/resolution.test.ts src/lib/ai-gateway/auto-routing-models.test.ts
  • pnpm --filter web typecheck
  • pnpm --filter web lint
  • changed-file oxfmt --list-different
  • git diff --check

@chrarnoldus chrarnoldus self-assigned this Aug 5, 2026
Comment thread apps/web/src/lib/ai-gateway/models.test.ts Outdated
@kilo-code-bot

kilo-code-bot Bot commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

Code Review Summary

Status: No Issues Found | Recommendation: Merge

Executive Summary

Incremental review of commit a215c269f: the weighted-selection test assertion in models.test.ts now uses the total routing weight (4) as modulus, resolving the previous review's only finding; no new issues introduced.

Files Reviewed (1 file)
  • apps/web/src/lib/ai-gateway/models.test.ts - verified: assertion modulus now matches the seed search (getRandomNumber(seed, 4)) and the bucket space consumed by selectAutoFreeModel (weights 3 + 1)
Previous Review Summary (commit 2e00a6e)

Current summary above is authoritative. Previous snapshots are kept for context only.

Previous review (commit 2e00a6e)

Status: 1 Issue Found | Recommendation: Address before merge

Executive Summary

The weighted Auto Free routing logic is correct (bucket math, availability filtering, null fallback all sound), with a single low-risk test-quality nit: a misleading modulus in the new weighted-selection test assertion in models.test.ts.

Overview

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

SUGGESTION

File Line Issue
apps/web/src/lib/ai-gateway/models.test.ts 174 Assertion uses candidates.length (2) as modulus instead of the total weight (4) that selectAutoFreeModel actually hashes against
Files Reviewed (3 files)
  • apps/web/src/lib/ai-gateway/auto-model/resolution.ts - verified: deterministic filter+sort, safe null fallback, unchanged seed semantics
  • apps/web/src/lib/ai-gateway/models.ts - verified: correct weighted-bucket selection, zero-weight guard, no broken consumers
  • apps/web/src/lib/ai-gateway/models.test.ts - 1 issue

Fix these issues in Kilo Cloud


Reviewed by kimi-k3 · Input: 25.7K · Output: 3K · Cached: 170.9K

Review guidance: REVIEW.md from base branch main

@chrarnoldus chrarnoldus changed the title feat(ai-gateway): support weighted auto free routing feat(ai-gateway): add weighted routing for Auto Free models Aug 5, 2026
@chrarnoldus
chrarnoldus merged commit bad72cf into main Aug 5, 2026
16 checks passed
@chrarnoldus
chrarnoldus deleted the summer-linen branch August 5, 2026 09:01
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.

2 participants