Skip to content

fix(ai-gateway): alias balanced to efficient routing - #5031

Merged
iscekic merged 2 commits into
mainfrom
feat/auto-balanced-alias
Aug 5, 2026
Merged

fix(ai-gateway): alias balanced to efficient routing#5031
iscekic merged 2 commits into
mainfrom
feat/auto-balanced-alias

Conversation

@iscekic

@iscekic iscekic commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

Summary

  • route kilo-auto/balanced through the benchmark-driven efficient decision engine
  • expose the same routing candidates for both auto model IDs
  • preserve the requested auto model ID in classifier billing
  • add regression tests and update ADR 0002

Tests

  • JEST_MAX_WORKERS=1 pnpm exec jest --runInBand --runTestsByPath src/lib/ai-gateway/auto-model/resolution.test.ts src/lib/ai-gateway/auto-routing-models.test.ts
  • JEST_MAX_WORKERS=1 pnpm exec jest --runInBand --runTestsByPath 'src/app/api/openrouter/[...path]/route.test.ts'\n- JEST_MAX_WORKERS=1 pnpm exec jest --runInBand --runTestsByPath src/app/api/openrouter/models/route.test.ts 'src/app/api/organizations/[id]/models/route.test.ts' src/lib/ai-gateway/providers/openrouter/index.test.ts\n- pnpm --filter web typecheck\n- pnpm --filter web lint\n- pnpm exec oxfmt --check ...\n\nCloses: N/A

@iscekic iscekic self-assigned this Aug 5, 2026
@iscekic
iscekic requested a review from chrarnoldus August 5, 2026 11:42
Comment thread apps/web/src/lib/ai-gateway/auto-model/resolution.ts Outdated
@kilo-code-bot

kilo-code-bot Bot commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

Code Review Summary

Status: 1 Issue Found | Recommendation: Address before merge

Executive Summary

The follow-up commits cleanly retire the legacy kilo/auto branch and the KiloClaw setup promo (resolving all previous findings), but the retired kilo/auto ID is not registered in unavailableModelIds, so stale clients still hardcoding it get a degraded model-not-found path instead of the standard unavailable-model response.

Overview

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

WARNING

File Line Issue
apps/web/src/lib/ai-gateway/unavailable-models.ts 56 Retired legacy kilo/auto ID not added to unavailableModelIds — stale clients hardcoding it (older OpenClaw) fall through auto-model handling into regular routing instead of the explicit unavailable-model error, breaking the repo convention (kilo/auto-free precedent and ai-gateway AGENTS.md)
Files Reviewed (12 files)
  • apps/web/src/app/api/public/leaderboard-model-provider-usage/route.ts
  • apps/web/src/lib/ai-gateway/auto-model/index.ts
  • apps/web/src/lib/ai-gateway/auto-model/resolution.test.ts
  • apps/web/src/lib/ai-gateway/auto-model/resolution.ts
  • apps/web/src/lib/ai-gateway/models.ts
  • apps/web/src/lib/ai-gateway/providers/anthropic.constants.ts
  • apps/web/src/lib/ai-gateway/providers/vercel/mapModelIdToVercel.test.ts
  • apps/web/src/lib/ai-gateway/unavailable-models.ts - 1 issue
  • apps/web/src/lib/kiloclaw/setup-promo.test.ts (deleted)
  • apps/web/src/lib/kiloclaw/setup-promo.ts (deleted)
  • docs/adr/0002-auto-routing-efficient.md
  • packages/db/src/schema.ts

Fix these issues in Kilo Cloud

Previous Review Summary (commit 3fbed54)

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

Previous review (commit 3fbed54)

Status: 1 Issue Found | Recommendation: Address before merge

Executive Summary

Aliasing kilo-auto/balanced to the efficient engine silently bypasses the KiloClaw first-instance free setup promo (BALANCED_CLAW_SETUP_MODEL) for new KiloClaw users on the default model.

Overview

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

WARNING

File Line Issue
apps/web/src/lib/ai-gateway/auto-model/resolution.ts 325 KiloClaw first-instance setup promo bypassed for kilo-auto/balanced — promo-eligible users (KiloClaw defaults to this model) are now classifier-routed and billed classifier overhead instead of receiving the free :clawsetup setup model
Files Reviewed (9 files)
  • apps/web/src/app/api/openrouter/[...path]/route.ts
  • apps/web/src/app/api/openrouter/[...path]/route.test.ts
  • apps/web/src/app/api/openrouter/models/route.test.ts
  • apps/web/src/lib/ai-gateway/auto-model/resolution.ts - 1 issue
  • apps/web/src/lib/ai-gateway/auto-model/resolution.test.ts
  • apps/web/src/lib/ai-gateway/auto-routing-models.ts
  • apps/web/src/lib/ai-gateway/auto-routing-models.test.ts
  • apps/web/src/lib/ai-gateway/auto-routing-table-cache.ts
  • docs/adr/0002-auto-routing-efficient.md

Fix these issues in Kilo Cloud


Reviewed by kimi-k3 · Input: 71.1K · Output: 16K · Cached: 872.4K

Review guidance: REVIEW.md from base branch main

Comment thread apps/web/src/lib/ai-gateway/auto-model/resolution.ts Outdated
Remove the KILO_AUTO_LEGACY_MODEL resolution branch entirely: upstream
OpenClaw no longer hardcodes kilo/auto, so the ID is no longer treated
as an auto model.

Retire the KiloClaw first-instance setup promo with it: delete the
BALANCED_CLAW_SETUP_MODEL branch, the setup-promo module, and the
hidden :clawsetup Sonnet exclusive. Balanced requests resolve through
the benchmark classifier like efficient ones.
Comment thread apps/web/src/lib/ai-gateway/unavailable-models.ts
@iscekic
iscekic enabled auto-merge (squash) August 5, 2026 12:14
@iscekic
iscekic merged commit 6fa02a6 into main Aug 5, 2026
46 checks passed
@iscekic
iscekic deleted the feat/auto-balanced-alias branch August 5, 2026 12:15
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