@@ -140,31 +140,34 @@ describe("dispatchReplyFromConfig stale visible admission recovery", () => {
140140 expect ( dispatchParams . dispatcher . sendFinalReply ) . toHaveBeenCalledTimes ( 1 ) ;
141141 } ) ;
142142
143- it ( "sends overload feedback when stuck recovery expires the active reply" , async ( ) => {
144- let resolverStarted : ( ) => void = ( ) => { } ;
145- const resolverStartedPromise = new Promise < void > ( ( resolve ) => {
146- resolverStarted = resolve ;
147- } ) ;
148- const dispatchParams = createVisibleDispatchParams ( async ( _ctx , options ) => {
149- resolverStarted ( ) ;
150- await new Promise < void > ( ( resolve ) => {
151- options ?. abortSignal ?. addEventListener ( "abort" , ( ) => resolve ( ) , { once : true } ) ;
143+ it . each ( [ "no_activity" , "stuck_recovery" ] as const ) (
144+ "sends truthful stalled feedback when %s expires the active reply" ,
145+ async ( reason ) => {
146+ let resolverStarted : ( ) => void = ( ) => { } ;
147+ const resolverStartedPromise = new Promise < void > ( ( resolve ) => {
148+ resolverStarted = resolve ;
149+ } ) ;
150+ const dispatchParams = createVisibleDispatchParams ( async ( _ctx , options ) => {
151+ resolverStarted ( ) ;
152+ await new Promise < void > ( ( resolve ) => {
153+ options ?. abortSignal ?. addEventListener ( "abort" , ( ) => resolve ( ) , { once : true } ) ;
154+ } ) ;
155+ const error = new Error ( "reply expired" ) ;
156+ error . name = "AbortError" ;
157+ throw error ;
152158 } ) ;
153- const error = new Error ( "reply expired" ) ;
154- error . name = "AbortError" ;
155- throw error ;
156- } ) ;
157159
158- const dispatchPromise = dispatchReplyFromConfig ( dispatchParams ) ;
159- await resolverStartedPromise ;
160- const operation = replyRunRegistry . get ( sessionKey ) ;
161- expect ( operation ) . toBeDefined ( ) ;
162- expect ( expireStaleReplyOperation ( operation ! , "stuck_recovery" ) ) . toBe ( true ) ;
160+ const dispatchPromise = dispatchReplyFromConfig ( dispatchParams ) ;
161+ await resolverStartedPromise ;
162+ const operation = replyRunRegistry . get ( sessionKey ) ;
163+ expect ( operation ) . toBeDefined ( ) ;
164+ expect ( expireStaleReplyOperation ( operation ! , reason ) ) . toBe ( true ) ;
163165
164- await expect ( dispatchPromise ) . resolves . toMatchObject ( { queuedFinal : true } ) ;
165- expect ( dispatchParams . dispatcher . sendFinalReply ) . toHaveBeenCalledWith ( {
166- text : "⚠️ Your reply was dropped because the gateway was overloaded. Please retry." ,
167- isError : true ,
168- } ) ;
169- } ) ;
166+ await expect ( dispatchPromise ) . resolves . toMatchObject ( { queuedFinal : true } ) ;
167+ expect ( dispatchParams . dispatcher . sendFinalReply ) . toHaveBeenCalledWith ( {
168+ text : "⚠️ This turn was interrupted because it stopped making progress. Please try again." ,
169+ isError : true ,
170+ } ) ;
171+ } ,
172+ ) ;
170173} ) ;
0 commit comments