Skip to content

fix(proxy): handle 404 with model-not-found guidance#1748

Merged
chrarnoldus merged 7 commits intomainfrom
fix/byok-404-model-not-found
Mar 31, 2026
Merged

fix(proxy): handle 404 with model-not-found guidance#1748
chrarnoldus merged 7 commits intomainfrom
fix/byok-404-model-not-found

Conversation

@kilo-code-bot
Copy link
Copy Markdown
Contributor

@kilo-code-bot kilo-code-bot bot commented Mar 30, 2026

Summary

When an upstream provider returns a 404 for a BYOK request, users previously received an opaque error. This change adds a dedicated handler in makeErrorReadable that tells the user the model does not exist or is no longer available, and recommends switching to kilo-auto/balanced. For KiloClaw/OpenClaw users, the message includes explicit /model switch instructions.

Changes:

  • Added feature parameter to makeErrorReadable to detect kiloclaw/openclaw clients
  • Added 404 handling inside the BYOK block in makeErrorReadable (src/lib/llm-proxy-helpers.ts)
  • Updated the call site in src/app/api/openrouter/[...path]/route.ts to pass feature

Verification

  • Reviewed existing BYOK error handling patterns and followed the same style
  • Confirmed FeatureValue and KILO_AUTO_BALANCED_MODEL are already imported
  • Typecheck could not run in CI-less environment (missing node_modules), but types are consistent with existing patterns

Visual Changes

N/A

Reviewer Notes

  • The 404 handler is placed after the existing byokErrorMessages lookup (401/402/403/429), so it only fires when no other BYOK-specific message matches first.
  • The kiloclaw/openclaw branch mirrors the pattern used in forbiddenFreeModelResponse for consistency.

After user BYOK error handling, return a helpful message when the
upstream provider responds with 404, indicating the model does not
exist or is no longer available. Recommends switching to
kilo-auto/balanced, with explicit /model instructions for
kiloclaw/openclaw users.
The 404 handler should apply to all users, not just BYOK users.
@kilo-code-bot
Copy link
Copy Markdown
Contributor Author

kilo-code-bot bot commented Mar 30, 2026

Code Review Summary

Status: 1 Issue Found | Recommendation: Address before merge

Overview

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

WARNING

File Line Issue
src/lib/llm-proxy-helpers.ts 171 The 404 fallback still chooses kilo-auto/free when balance <= 0, but BYOK requests do not depend on Kilo credits and should not change guidance based on local balance.

Fix these issues in Kilo Cloud

Other Observations (not in diff)

N/A

Files Reviewed (1 files)
  • src/lib/llm-proxy-helpers.ts - 1 issue

Reviewed by gpt-5.4-20260305 · 116,430 tokens

@chrarnoldus chrarnoldus changed the title fix(proxy): handle BYOK 404 with model-not-found guidance fix(proxy): handle 404 with model-not-found guidance Mar 30, 2026
When the user has no credits, recommend kilo-auto/free instead of
kilo-auto/balanced in the 404 model-not-found message.
kilo-code-bot bot added 2 commits March 30, 2026 21:01
BYOK users get a plain message pointing them to check the model name
and their API provider, while non-BYOK users still get the auto model
recommendation.
@chrarnoldus chrarnoldus merged commit ebd74b8 into main Mar 31, 2026
15 checks passed
@chrarnoldus chrarnoldus deleted the fix/byok-404-model-not-found branch March 31, 2026 08:07
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