fix(proxy): handle 404 with model-not-found guidance#1748
Open
kilo-code-bot[bot] wants to merge 6 commits intomainfrom
Open
fix(proxy): handle 404 with model-not-found guidance#1748kilo-code-bot[bot] wants to merge 6 commits intomainfrom
kilo-code-bot[bot] wants to merge 6 commits intomainfrom
Conversation
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.
Contributor
Author
Code Review SummaryStatus: 1 Issue Found | Recommendation: Address before merge Overview
Issue Details (click to expand)WARNING
Fix these issues in Kilo Cloud Other Observations (not in diff)N/A Files Reviewed (1 file)
Reviewed by gpt-5.4-20260305 · 380,617 tokens |
When the user has no credits, recommend kilo-auto/free instead of kilo-auto/balanced in the 404 model-not-found message.
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.
| } | ||
|
|
||
| if (response.status === 404) { | ||
| const recommendedModel = balance <= 0 ? KILO_AUTO_FREE_MODEL : KILO_AUTO_BALANCED_MODEL; |
Contributor
Author
There was a problem hiding this comment.
WARNING: BYOK fallback depends on the user's Kilo balance
BYOK requests can still reach this branch, but balance is the user's Kilo credit balance, not the upstream provider balance behind their API key. Accounts with zero Kilo credits will now be told to switch to kilo-auto/free, which contradicts the new BYOK guidance and makes the recommendation depend on unrelated state.
Suggested change
| const recommendedModel = balance <= 0 ? KILO_AUTO_FREE_MODEL : KILO_AUTO_BALANCED_MODEL; | |
| const recommendedModel = isUserByok || balance > 0 ? KILO_AUTO_BALANCED_MODEL : KILO_AUTO_FREE_MODEL; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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
makeErrorReadablethat tells the user the model does not exist or is no longer available, and recommends switching tokilo-auto/balanced. For KiloClaw/OpenClaw users, the message includes explicit/modelswitch instructions.Changes:
featureparameter tomakeErrorReadableto detect kiloclaw/openclaw clientsmakeErrorReadable(src/lib/llm-proxy-helpers.ts)src/app/api/openrouter/[...path]/route.tsto passfeatureVerification
FeatureValueandKILO_AUTO_BALANCED_MODELare already importednode_modules), but types are consistent with existing patternsVisual Changes
N/A
Reviewer Notes
byokErrorMessageslookup (401/402/403/429), so it only fires when no other BYOK-specific message matches first.forbiddenFreeModelResponsefor consistency.