@@ -789,7 +789,6 @@ func (h *Handler) Responses(c *gin.Context) {
789789 maxRateLimitRetries := h .getMaxRateLimitRetries ()
790790 generalRetries := 0
791791 rateLimitRetries := 0
792- var lastErr error
793792 var lastStatusCode int
794793 var lastBody []byte
795794 excludeAccounts := make (map [int64 ]bool ) // 重试时排除已失败的账号
@@ -850,7 +849,6 @@ func (h *Handler) Responses(c *gin.Context) {
850849 }
851850
852851 log .Printf ("上游请求失败 (attempt %d): %v" , attempt + 1 , reqErr )
853- lastErr = reqErr
854852 if shouldRetryRequestError (reqErr , & generalRetries , maxRetries ) {
855853 continue
856854 }
@@ -1035,10 +1033,6 @@ func (h *Handler) Responses(c *gin.Context) {
10351033 resp .Body .Close ()
10361034 h .store .Release (account )
10371035 h .store .UnbindSessionAffinity (affinityKey , account .ID ())
1038- lastErr = readErr
1039- if lastErr == nil {
1040- lastErr = errors .New (outcome .failureMessage )
1041- }
10421036 continue
10431037 }
10441038
@@ -1109,15 +1103,6 @@ func (h *Handler) Responses(c *gin.Context) {
11091103 h .store .Release (account )
11101104 return
11111105 }
1112-
1113- // 所有重试都失败
1114- if lastErr != nil {
1115- c .JSON (http .StatusBadGateway , gin.H {
1116- "error" : gin.H {"message" : "上游请求失败: " + lastErr .Error (), "type" : "upstream_error" },
1117- })
1118- } else if lastStatusCode != 0 {
1119- h .sendFinalUpstreamError (c , lastStatusCode , lastBody )
1120- }
11211106}
11221107
11231108// ResponsesCompact 处理 /v1/responses/compact 请求(非流式压缩接口,透传到上游 /responses/compact)
@@ -1192,7 +1177,6 @@ func (h *Handler) ResponsesCompact(c *gin.Context) {
11921177 maxRateLimitRetries := h .getMaxRateLimitRetries ()
11931178 generalRetries := 0
11941179 rateLimitRetries := 0
1195- var lastErr error
11961180 var lastStatusCode int
11971181 var lastBody []byte
11981182 excludeAccounts := make (map [int64 ]bool )
@@ -1243,7 +1227,6 @@ func (h *Handler) ResponsesCompact(c *gin.Context) {
12431227 }
12441228
12451229 log .Printf ("compact 上游请求失败 (attempt %d): %v" , attempt + 1 , reqErr )
1246- lastErr = reqErr
12471230 if shouldRetryRequestError (reqErr , & generalRetries , maxRetries ) {
12481231 continue
12491232 }
@@ -1332,15 +1315,6 @@ func (h *Handler) ResponsesCompact(c *gin.Context) {
13321315 c .Data (http .StatusOK , "application/json" , respBody )
13331316 return
13341317 }
1335-
1336- // 所有重试都失败
1337- if lastErr != nil {
1338- c .JSON (http .StatusBadGateway , gin.H {
1339- "error" : gin.H {"message" : "上游请求失败: " + lastErr .Error (), "type" : "upstream_error" },
1340- })
1341- } else if lastStatusCode != 0 {
1342- h .sendFinalUpstreamError (c , lastStatusCode , lastBody )
1343- }
13441318}
13451319
13461320func (h * Handler ) ChatCompletions (c * gin.Context ) {
@@ -1414,7 +1388,6 @@ func (h *Handler) ChatCompletions(c *gin.Context) {
14141388 maxRateLimitRetries := h .getMaxRateLimitRetries ()
14151389 generalRetries := 0
14161390 rateLimitRetries := 0
1417- var lastErr error
14181391 var lastStatusCode int
14191392 var lastBody []byte
14201393 excludeAccounts := make (map [int64 ]bool ) // 重试时排除已失败的账号
@@ -1475,7 +1448,6 @@ func (h *Handler) ChatCompletions(c *gin.Context) {
14751448 }
14761449
14771450 log .Printf ("上游请求失败 (attempt %d): %v" , attempt + 1 , reqErr )
1478- lastErr = reqErr
14791451 if shouldRetryRequestError (reqErr , & generalRetries , maxRetries ) {
14801452 continue
14811453 }
@@ -1654,10 +1626,6 @@ func (h *Handler) ChatCompletions(c *gin.Context) {
16541626 resp .Body .Close ()
16551627 h .store .Release (account )
16561628 h .store .UnbindSessionAffinity (affinityKey , account .ID ())
1657- lastErr = readErr
1658- if lastErr == nil {
1659- lastErr = errors .New (outcome .failureMessage )
1660- }
16611629 continue
16621630 }
16631631
@@ -1727,15 +1695,6 @@ func (h *Handler) ChatCompletions(c *gin.Context) {
17271695 h .store .Release (account )
17281696 return
17291697 }
1730-
1731- // 所有重试都失败
1732- if lastErr != nil {
1733- c .JSON (http .StatusBadGateway , gin.H {
1734- "error" : gin.H {"message" : "上游请求失败: " + lastErr .Error (), "type" : "upstream_error" },
1735- })
1736- } else if lastStatusCode != 0 {
1737- h .sendFinalUpstreamError (c , lastStatusCode , lastBody )
1738- }
17391698}
17401699
17411700// handleStreamResponse 处理流式响应(翻译 Codex → OpenAI)
0 commit comments