Skip to content

feat(ai-gateway): derive BYOK variants from models.dev - #4867

Merged
chrarnoldus merged 8 commits into
mainfrom
ludicrous-prawn
Jul 29, 2026
Merged

feat(ai-gateway): derive BYOK variants from models.dev#4867
chrarnoldus merged 8 commits into
mainfrom
ludicrous-prawn

Conversation

@chrarnoldus

@chrarnoldus chrarnoldus commented Jul 29, 2026

Copy link
Copy Markdown
Contributor

Summary

  • derive OpenCode reasoning variants for models.dev-backed direct BYOK models from provider-specific reasoning_options
  • translate supported toggle and effort controls, reusing the shared binary instant/thinking variants for toggle-only models
  • resolve the AI SDK provider during models.dev sync and set Anthropic variant verbosity to the corresponding supported reasoning effort
  • apply model-family fallback during sync when models.dev controls are absent or unsupported, including Anthropic verbosity on fallback variants
  • persist variants on DirectByokModel and carry synced variants onto overlapping recommended model entries
  • tolerate unsupported or future reasoning option types without failing sync
  • keep OpenAI-compatible fetched models and OpenRouter models on the existing conversion-time model-family fallback path
  • remove the now-unused REASONING_VARIANTS_NONE_LOW_MEDIUM_HIGH constant

Examples

zai-coding/glm-5.2 exposes the catalog-provided high and max efforts:

{
  "high": { "reasoning": { "enabled": true, "effort": "high" } },
  "max": { "reasoning": { "enabled": true, "effort": "max" } }
}

opencode-go/minimax-m3 uses the Anthropic SDK and a catalog toggle, so its enabled variant also gets matching verbosity:

{
  "instant": { "reasoning": { "enabled": false, "effort": "none" } },
  "thinking": {
    "reasoning": { "enabled": true, "effort": "high" },
    "verbosity": "high"
  }
}

opencode-go/qwen3.7-plus includes unsupported budget_tokens, so it falls back to the Qwen binary variants and still receives Anthropic verbosity:

{
  "instant": { "reasoning": { "enabled": false, "effort": "none" } },
  "thinking": {
    "reasoning": { "enabled": true, "effort": "high" },
    "verbosity": "high"
  }
}

The disabled variants omit verbosity because none is not a valid VerbositySchema value.

Verification

  • pnpm --filter web test -- --runInBand src/lib/ai-gateway/providers/direct-byok/sync-direct-byok.test.ts src/lib/ai-gateway/providers/direct-byok/index.test.ts (11 tests passed)
  • pnpm --filter web typecheck
  • targeted oxlint on all changed files
  • formatting and git diff --check

@chrarnoldus chrarnoldus self-assigned this Jul 29, 2026
@kilo-code-bot

kilo-code-bot Bot commented Jul 29, 2026

Copy link
Copy Markdown
Contributor

Code Review Summary

Status: No Issues Found | Recommendation: Merge

Executive Summary

Incremental review of the follow-up change that adds AI SDK provider resolution and Anthropic verbosity mapping to parseModelsDevProviderModels, plus a fallback to getModelVariants when models.dev reasoning options are absent; the new addAnthropicVariantVerbosity logic and updated tests are consistent and no issues were found on changed lines.

Files Reviewed (2 files)
  • 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 Summaries (2 snapshots, latest commit 3f7d12a)

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

Previous review (commit 3f7d12a)

Status: No Issues Found | Recommendation: Merge

Executive Summary

Incremental review of the two-file follow-up fix (returning undefined instead of {} from modelsDevReasoningOptionsToVariants so the existing ?? fallback to getModelVariants/synced variants actually triggers) found no issues; the change is correct and the updated tests match the new behavior.

Files Reviewed (2 files)
  • 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 (commit 6690698)

Status: No Issues Found | Recommendation: Merge

Executive Summary

Reviewed the direct BYOK variant-derivation changes (models.dev reasoning-option parsing, synced-variant retention, and heuristic-fallback preservation) across 7 files and found no high-confidence bugs, security issues, or breaking changes in the modified lines; the new/updated tests accurately reflect the implemented logic.

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

Reviewed by claude-sonnet-5 · Input: 22 · Output: 6.8K · Cached: 474.1K

Review guidance: REVIEW.md from base branch main

@chrarnoldus chrarnoldus changed the title feat(ai-gateway): derive direct BYOK variants feat(ai-gateway): derive BYOK variants from models.dev Jul 29, 2026
@chrarnoldus
chrarnoldus merged commit 8387786 into main Jul 29, 2026
16 checks passed
@chrarnoldus
chrarnoldus deleted the ludicrous-prawn branch July 29, 2026 19:09
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