File tree Expand file tree Collapse file tree 2 files changed +17
-7
lines changed
Expand file tree Collapse file tree 2 files changed +17
-7
lines changed Original file line number Diff line number Diff line change @@ -40,10 +40,13 @@ describe('shouldRetryWithFreshOpenCodeSession', () => {
4040 it ( 'returns true for stale-session errors' , ( ) => {
4141 expect ( shouldRetryWithFreshOpenCodeSession ( new Error ( '404 session not found' ) ) ) . toBe ( true )
4242 expect ( shouldRetryWithFreshOpenCodeSession ( 'session does not exist' ) ) . toBe ( true )
43+ expect ( shouldRetryWithFreshOpenCodeSession ( 'unknown session' ) ) . toBe ( true )
4344 } )
4445
4546 it ( 'returns false for unrelated session errors' , ( ) => {
4647 expect ( shouldRetryWithFreshOpenCodeSession ( new Error ( 'session limit exceeded' ) ) ) . toBe ( false )
4748 expect ( shouldRetryWithFreshOpenCodeSession ( 'invalid session format' ) ) . toBe ( false )
49+ expect ( shouldRetryWithFreshOpenCodeSession ( 'model not found' ) ) . toBe ( false )
50+ expect ( shouldRetryWithFreshOpenCodeSession ( 'provider does not exist' ) ) . toBe ( false )
4851 } )
4952} )
Original file line number Diff line number Diff line change @@ -504,13 +504,20 @@ export function shouldRetryWithFreshOpenCodeSession(error: unknown): boolean {
504504 : JSON . stringify ( error )
505505
506506 const normalized = message . toLowerCase ( )
507- return (
508- normalized . includes ( '404' ) ||
509- normalized . includes ( 'not found' ) ||
510- normalized . includes ( 'session not found' ) ||
511- normalized . includes ( 'session does not exist' ) ||
512- normalized . includes ( 'does not exist' )
513- )
507+ const staleSessionPatterns = [
508+ 'session not found' ,
509+ 'session does not exist' ,
510+ 'session was not found' ,
511+ 'session no longer exists' ,
512+ 'unknown session' ,
513+ 'invalid session id' ,
514+ ]
515+
516+ if ( staleSessionPatterns . some ( ( pattern ) => normalized . includes ( pattern ) ) ) {
517+ return true
518+ }
519+
520+ return normalized . includes ( '404' ) && normalized . includes ( 'session' )
514521}
515522
516523export async function logOpenCodeFailure ( message : string , error : unknown ) : Promise < void > {
You can’t perform that action at this time.
0 commit comments