fix: expand model key regex and fallbackOn categories#27
Open
tmogeid wants to merge 1 commit into
Open
Conversation
…ackOn to 29 categories - Fix MODEL_KEY_RE regex to accept nested provider paths with slashes and colons (e.g. nvidia/z-ai/glm-5.2, openrouter/tencent/hy3:free) - Expand ErrorCategory type from 5 to 29 categories for broader error coverage - Update classifier to recognize new error patterns (auth, billing, premium, etc.) - Fix README: opencode.jsonc -> opencode.json, add extended fallbackOn docs
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.
Problem
The
MODEL_KEY_REregex insrc/config/schema.tsandsrc/config/agent-loader.tsuses charset[a-zA-Z0-9._-]for the modelID portion, which rejects model keys containing forward slashes or colons.This blocks users from configuring fallback models with nested provider paths (e.g.
nvidia/z-ai/glm-5.2,openrouter/tencent/hy3:free).Additionally, the
ErrorCategorytype only supports 5 categories (rate_limit,quota_exceeded,5xx,timeout,overloaded), which doesn't cover common failure modes like auth errors, billing issues, or premium subscription requirements.Changes
1. Fix MODEL_KEY_RE regex
Add
\/:to the modelID charset in both regex definitions:This allows nested provider paths with slashes and colons (for model IDs like
openrouter/tencent/hy3:free).2. Expand ErrorCategory to 29 categories
The original 5 categories only covered rate limits, quotas, server errors, timeouts, and overload. The expanded set adds:
unauthorized,401,403insufficient_credits,insufficient_balance,no_credits,out_of_credits,insufficient_fundsbilling,credit_balance,payment_requiredpremium,premium_subscription,subscription_required429,500,502,503,504limit,insufficient_quota,quota_exceeded_message3. Update classifier with new patterns
The classifier now recognizes messages like "unauthorized", "insufficient balance", "premium subscription", etc. and maps them to the appropriate categories.
4. Fix README
opencode.jsonc->opencode.json(the correct filename)fallbackOncategories documentationTesting
tsc --noEmit— 0 errors)