You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
🤖 fix: correctly classify (and not retry) model not found errors (#535)
Moved model_not_found detection logic from error handling into the
categorizeError method to eliminate code duplication.
## Problem
There were two bugs related to model_not_found error handling:
1. **Code duplication**: The model_not_found detection logic existed in
two places:
- In `categorizeError` (but it returned `'api'` for 404s)
- In error handling (as a workaround to override `'api'` to
`'model_not_found'`)
2. **Potential retry spam**: If the workaround code was bypassed, 404
errors would be classified as `'api'`, which is not in the
`NON_RETRYABLE_STREAM_ERRORS` list, leading to retry spam.
## Solution
Refactored `categorizeError` to directly return `'model_not_found'` for
both:
- **OpenAI**: 400 with `error.code === 'model_not_found'`
- **Anthropic**: 404 with `error.type === 'not_found_error'`
Removed the duplicate override logic from error handling, leaving only
the error message enhancement.
## Benefits
- **Single source of truth** for error classification
- **Prevents retry spam** because `model_not_found` is in
`NON_RETRYABLE_STREAM_ERRORS`
- **Cleaner code** with no duplication
- **Maintainable** - future changes only need to happen in one place
## Test Coverage
**Backend (IPC layer integration tests)**:
- ✅ Anthropic 404 errors are classified as `model_not_found`
- ✅ OpenAI 400 errors are classified as `model_not_found`
**Frontend (unit tests in retryEligibility.test.ts)**:
- ✅ `model_not_found` is in `NON_RETRYABLE_STREAM_ERRORS` list
- ✅ `isEligibleForAutoRetry` returns false for `model_not_found` errors
_Generated with `cmux`_
0 commit comments