Skip to content

fix(ai-gateway): respect policy in Auto Free routing - #5041

Merged
chrarnoldus merged 6 commits into
mainfrom
exclude-enterprise-policy-models-from-autofree
Aug 5, 2026
Merged

fix(ai-gateway): respect policy in Auto Free routing#5041
chrarnoldus merged 6 commits into
mainfrom
exclude-enterprise-policy-models-from-autofree

Conversation

@chrarnoldus

Copy link
Copy Markdown
Contributor

Summary

  • filter Auto Free candidates through the member's effective enterprise model policy before weighted selection
  • reuse the prefetched policy for the existing post-resolution enforcement
  • hide Auto Free from model catalogs when no policy-allowed concrete candidates remain

Validation

  • pnpm --filter web typecheck
  • focused Jest suites: 5 passed, 66 tests
  • changed-file oxlint: 0 warnings, 0 errors
  • pnpm format
  • git diff --check

@chrarnoldus chrarnoldus self-assigned this Aug 5, 2026
Comment thread apps/web/src/lib/ai-gateway/auto-routing-models.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 the latest commit (bb17387..dd0eed5): a behavior-preserving refactor in auto-routing-models.ts that extracts the hide-Auto-Free condition into hideAutoFreeModel; the previously raised empty-candidate hiding suggestion is confirmed fixed via the null sentinel for failed candidate lookups.

Files Reviewed (1 file, incremental)
  • apps/web/src/lib/ai-gateway/auto-routing-models.ts
Previous Review Summaries (3 snapshots, latest commit bb17387)

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

Previous review (commit bb17387)

Status: No Issues Found | Recommendation: Merge

Files Reviewed (4 files)
  • apps/web/src/lib/ai-gateway/auto-model/resolution.ts
  • apps/web/src/lib/ai-gateway/auto-model/resolution.test.ts
  • apps/web/src/lib/ai-gateway/monitored-models.ts
  • apps/web/src/lib/organizations/effective-model-access.server.test.ts

Previous review (commit 2d60dde)

Status: No Issues Found | Recommendation: Merge

Files Reviewed (2 files)
  • apps/web/src/lib/ai-gateway/auto-routing-models.ts
  • apps/web/src/lib/ai-gateway/auto-routing-models.test.ts

Previous review (commit 5e649e8)

Status: 1 Issue Found | Recommendation: Address before merge

Executive Summary

Auto Free routing now correctly filters candidates through the effective enterprise model policy and reuses the prefetched policy post-resolution; the only finding is a minor error-path conflation that hides kilo-auto/free from catalogs on transient candidate-lookup failure.

Overview

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

SUGGESTION

File Line Issue
apps/web/src/lib/ai-gateway/auto-routing-models.ts 49 Hiding kilo-auto/free on empty candidates now also triggers on transient lookup failure (.catch(() => [])), conflating fetch errors with genuinely no policy-allowed candidates
Files Reviewed (6 files)
  • apps/web/src/app/api/openrouter/[...path]/route.ts - 0 issues
  • apps/web/src/app/api/openrouter/[...path]/route.test.ts - 0 issues
  • apps/web/src/lib/ai-gateway/auto-model/resolution.ts - 0 issues
  • apps/web/src/lib/ai-gateway/auto-model/resolution.test.ts - 0 issues
  • apps/web/src/lib/ai-gateway/auto-routing-models.ts - 1 issue
  • apps/web/src/lib/ai-gateway/auto-routing-models.test.ts - 0 issues

Fix these issues in Kilo Cloud


Reviewed by kimi-k3 · Input: 32.5K · Output: 6K · Cached: 166.9K

Review guidance: REVIEW.md from base branch main

@chrarnoldus
chrarnoldus merged commit 20bb006 into main Aug 5, 2026
15 checks passed
@chrarnoldus
chrarnoldus deleted the exclude-enterprise-policy-models-from-autofree branch August 5, 2026 17:34
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