🤖 fix: correctly classify (and not retry) model not found errors #535
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.
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:
Code duplication: The model_not_found detection logic existed in two places:
categorizeError(but it returned'api'for 404s)'api'to'model_not_found')Potential retry spam: If the workaround code was bypassed, 404 errors would be classified as
'api', which is not in theNON_RETRYABLE_STREAM_ERRORSlist, leading to retry spam.Solution
Refactored
categorizeErrorto directly return'model_not_found'for both:error.code === 'model_not_found'error.type === 'not_found_error'Removed the duplicate override logic from error handling, leaving only the error message enhancement.
Benefits
model_not_foundis inNON_RETRYABLE_STREAM_ERRORSTest Coverage
Backend (IPC layer integration tests):
model_not_foundmodel_not_foundFrontend (unit tests in retryEligibility.test.ts):
model_not_foundis inNON_RETRYABLE_STREAM_ERRORSlistisEligibleForAutoRetryreturns false formodel_not_founderrorsGenerated with
cmux