@@ -347,6 +347,7 @@ func TestIsMidStreamTransportAbort(t *testing.T) {
347347 "provider stream error: read: connection closed" ,
348348 "write: broken pipe" ,
349349 "provider stream error: server closed the connection" ,
350+ "provider stream error: software caused connection abort" ,
350351 }
351352 for _ , m := range aborts {
352353 if ! isMidStreamTransportAbort (m ) {
@@ -361,9 +362,16 @@ func TestIsMidStreamTransportAbort(t *testing.T) {
361362 "net/http: timeout awaiting response headers" ,
362363 "dial tcp 10.0.0.1:443: connect: connection refused" ,
363364 "i/o timeout" ,
365+ "500 Internal Server Error" ,
366+ "502 Bad Gateway" ,
367+ "503 Service Unavailable" ,
364368 "504 Gateway Timeout" ,
365369 "provider request error: request does not satisfy oneOf schema" ,
366370 "provider request error: connection closed is not a supported finish reason" ,
371+ "provider error: connection closed is not a supported finish reason" ,
372+ "provider error: upstream connection reset by peer" ,
373+ "provider error: unexpected EOF while reading upstream response" ,
374+ "provider error: 502 Bad Gateway" ,
367375 "auth error: connection reset by peer" ,
368376 "rate limit error: server closed" ,
369377 "schema error: property oneOf is invalid" ,
@@ -400,6 +408,31 @@ func TestRunDoesNotRetryClassifiedProviderErrorWithSocketPhrase(t *testing.T) {
400408 }
401409}
402410
411+ func TestRunDoesNotRetryProviderErrorWithSocketPhrase (t * testing.T ) {
412+ p := & midStreamAbortProvider {
413+ abortBefore : 1 ,
414+ abortError : "provider error: unexpected EOF while reading upstream response" ,
415+ }
416+ var notices string
417+ opts := Options {
418+ Registry : tools .NewRegistry (),
419+ OnReasoning : func (s string ) { notices += s },
420+ }
421+ _ , err := Run (context .Background (), "go" , p , opts )
422+ if err == nil {
423+ t .Fatal ("expected application error, got nil" )
424+ }
425+ if got := atomic .LoadInt32 (& p .calls ); got != 1 {
426+ t .Fatalf ("provider error with 'unexpected EOF' must not retry (got %d calls, want 1)" , got )
427+ }
428+ if notices != "" {
429+ t .Fatalf ("expected no reconnect notices, got %q" , notices )
430+ }
431+ if ! strings .Contains (err .Error (), "unexpected EOF" ) {
432+ t .Fatalf ("expected original error preserved, got %v" , err )
433+ }
434+ }
435+
403436func TestRunDoesNotRetryApplicationErrorContainingEOFSubstring (t * testing.T ) {
404437 p := & midStreamAbortProvider {
405438 abortBefore : 1 ,
0 commit comments