Fix issue #2393: auto-enable model_fallback and expand retry patterns#2479
Closed
code-yeongyu wants to merge 1 commit intodevfrom
Closed
Fix issue #2393: auto-enable model_fallback and expand retry patterns#2479code-yeongyu wants to merge 1 commit intodevfrom
code-yeongyu wants to merge 1 commit intodevfrom
Conversation
There was a problem hiding this comment.
1 issue found across 6 files
Confidence score: 3/5
- Potential mismatch with actual SDK behavior:
src/shared/model-error-classifier.test.tsassumeserror.name === "FreeUsageLimitError", but the SDK wraps limit errors asMessageV2.APIError, so the classifier/tests may be validating the wrong condition and could mis-handle real limit errors. - Severity is high (8/10) and confidence is high, suggesting a concrete behavioral mismatch rather than a minor test tweak; this introduces some user-impacting risk if error classification is relied on.
- Pay close attention to
src/shared/model-error-classifier.test.ts- ensure error name/type checks align with how the SDK surfaces limit errors.
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="src/shared/model-error-classifier.test.ts">
<violation number="1" location="src/shared/model-error-classifier.test.ts:43">
P1: Custom agent: **Opencode Compatibility**
Opencode SDK never throws an error with `name: "FreeUsageLimitError"`. Backend limit errors are wrapped by the SDK into `MessageV2.APIError` instances (meaning `error.name` is always `"APIError"`), and the `FreeUsageLimitError` identifier is only present in the `responseBody` or `message`. Testing for `name: "FreeUsageLimitError"` indicates an invalid approach to catching Opencode limit errors, as it won't match the actual errors emitted by the SDK.</violation>
</file>
Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.
| expect(result).toBe(true) | ||
| }) | ||
|
|
||
| test("treats FreeUsageLimitError names as retryable", () => { |
There was a problem hiding this comment.
P1: Custom agent: Opencode Compatibility
Opencode SDK never throws an error with name: "FreeUsageLimitError". Backend limit errors are wrapped by the SDK into MessageV2.APIError instances (meaning error.name is always "APIError"), and the FreeUsageLimitError identifier is only present in the responseBody or message. Testing for name: "FreeUsageLimitError" indicates an invalid approach to catching Opencode limit errors, as it won't match the actual errors emitted by the SDK.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At src/shared/model-error-classifier.test.ts, line 43:
<comment>Opencode SDK never throws an error with `name: "FreeUsageLimitError"`. Backend limit errors are wrapped by the SDK into `MessageV2.APIError` instances (meaning `error.name` is always `"APIError"`), and the `FreeUsageLimitError` identifier is only present in the `responseBody` or `message`. Testing for `name: "FreeUsageLimitError"` indicates an invalid approach to catching Opencode limit errors, as it won't match the actual errors emitted by the SDK.</comment>
<file context>
@@ -40,6 +40,28 @@ describe("model-error-classifier", () => {
expect(result).toBe(true)
})
+ test("treats FreeUsageLimitError names as retryable", () => {
+ //#given
+ const error = { name: "FreeUsageLimitError" }
</file context>
Owner
Author
|
Duplicate of #2422 which already passes CI |
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
FreeUsageLimitErrorand broader free-tier or daily-limit messagesmodel_fallbackwhenfallback_modelsare configured, while keeping explicitmodel_fallback: falseas an overrideTesting
bun run typecheckbun run buildbun test src/shared/model-error-classifier.test.ts src/plugin/hooks/model-fallback-config.test.ts src/plugin/event.model-fallback.test.tsbun test(currently fails on pre-existing expectations insrc/plugin-config.test.tsaboutdisabled_hooks; unrelated to this change)Summary by cubic
Auto-enables
model_fallbackwhenfallback_modelsare configured and expands retryable error detection (including free-tier limits) to make provider fallback more reliable.Bug Fixes
FreeUsageLimitErrorand free-tier/daily-limit messages as retryable; error name matching is now case-insensitive.model_fallbackwhen any agent/category definesfallback_models; explicitmodel_fallback: falsestill disables it.Refactors
model-fallback-configandcreate-model-fallback-session-hook, added focused tests, and simplifiedcreate-session-hooks.Written for commit fd7faff. Summary will update on new commits.