Skip to content

fix(ai-gateway): gate fallback reasoning variants - #5086

Merged
chrarnoldus merged 2 commits into
mainfrom
prevent-unsupported-reasoning-variants
Aug 6, 2026
Merged

fix(ai-gateway): gate fallback reasoning variants#5086
chrarnoldus merged 2 commits into
mainfrom
prevent-unsupported-reasoning-variants

Conversation

@chrarnoldus

Copy link
Copy Markdown
Contributor

Summary

  • only infer OpenRouter fallback variants when reasoning is advertised in supported_parameters
  • preserve variants derived from OpenRouter metadata
  • apply the same fallback guard to direct-BYOK model conversion and models.dev synchronization

Verification

  • pnpm --filter web test -- --runInBand src/lib/ai-gateway/providers/openrouter/index.test.ts src/lib/ai-gateway/providers/direct-byok/index.test.ts src/lib/ai-gateway/providers/direct-byok/sync-direct-byok.test.ts
  • pnpm --filter web typecheck
  • targeted oxlint, oxfmt --check, and git diff --check

@chrarnoldus chrarnoldus self-assigned this Aug 6, 2026
@kilo-code-bot

kilo-code-bot Bot commented Aug 6, 2026

Copy link
Copy Markdown
Contributor

Code Review Summary

Status: No Issues Found | Recommendation: Merge

Executive Summary

Incremental review of the latest commit: making allowFallbackVariants a required parameter is compile-time safe — every caller (openrouter/index.ts, auto-model/resolution.ts, internal pass-through) now passes it explicitly, and the auto-model routing path deliberately preserves the previous fallback-allowed behavior with true; the earlier fallback-variant gating across OpenRouter enhancement, direct-BYOK conversion, and models.dev sync remains sound.

Files Reviewed (8 files)
  • apps/web/src/lib/ai-gateway/auto-model/resolution.ts
  • apps/web/src/lib/ai-gateway/providers/model-settings.ts
  • apps/web/src/lib/ai-gateway/providers/openrouter/index.ts
  • apps/web/src/lib/ai-gateway/providers/openrouter/index.test.ts
  • apps/web/src/lib/ai-gateway/providers/direct-byok/index.ts
  • apps/web/src/lib/ai-gateway/providers/direct-byok/index.test.ts
  • apps/web/src/lib/ai-gateway/providers/direct-byok/sync-direct-byok.ts
  • apps/web/src/lib/ai-gateway/providers/direct-byok/sync-direct-byok.test.ts
Previous Review Summary (commit fe99f5d)

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

Previous review (commit fe99f5d)

Status: No Issues Found | Recommendation: Merge

Executive Summary

The fallback-variant gating is applied consistently across OpenRouter model enhancement, direct-BYOK conversion, and models.dev sync; the new optional allowFallbackVariants parameter is backwards-compatible for existing callers, explicit/derived variants still take precedence, downstream consumers already handle undefined variants, and test updates (including a Claude-named non-reasoning model) correctly pin the new behavior.

Files Reviewed (7 files)
  • apps/web/src/lib/ai-gateway/providers/model-settings.ts
  • apps/web/src/lib/ai-gateway/providers/openrouter/index.ts
  • apps/web/src/lib/ai-gateway/providers/openrouter/index.test.ts
  • apps/web/src/lib/ai-gateway/providers/direct-byok/index.ts
  • apps/web/src/lib/ai-gateway/providers/direct-byok/index.test.ts
  • apps/web/src/lib/ai-gateway/providers/direct-byok/sync-direct-byok.ts
  • apps/web/src/lib/ai-gateway/providers/direct-byok/sync-direct-byok.test.ts

Reviewed by kimi-k3 · Input: 39.4K · Output: 5.6K · Cached: 263.2K

Review guidance: REVIEW.md from base branch main

@chrarnoldus
chrarnoldus enabled auto-merge (squash) August 6, 2026 10:51
@chrarnoldus
chrarnoldus merged commit 82d8e83 into main Aug 6, 2026
16 checks passed
@chrarnoldus
chrarnoldus deleted the prevent-unsupported-reasoning-variants branch August 6, 2026 10:51
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