Skip to content

Commit c64ed46

Browse files
daveking-wqclaude
andcommitted
fix: correct log levels for thinking block signature retry flow
LegacyPrintf uses inferStdLogLevel() to infer log level from message text. Any message containing the word "error" is classified as ERROR level, causing the entire signature-retry recovery flow (which succeeds) to produce spurious ERROR log entries. Changes: - Remove noisy [SignatureCheck] debug logs inside isThinkingBlockSignatureError that were logging every detected signature check as ERROR - Change retry-start log to WARN level via [warn] prefix - Change retry-success log to INFO level by removing "error" from message Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent a225a24 commit c64ed46

1 file changed

Lines changed: 2 additions & 6 deletions

File tree

backend/internal/service/gateway_service.go

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4197,7 +4197,7 @@ func (s *GatewayService) Forward(ctx context.Context, c *gin.Context, account *A
41974197
resp.Body = io.NopCloser(bytes.NewReader(respBody))
41984198
break
41994199
}
4200-
logger.LegacyPrintf("service.gateway", "Account %d: detected thinking block signature error, retrying with filtered thinking blocks", account.ID)
4200+
logger.LegacyPrintf("service.gateway", "[warn] Account %d: thinking blocks have invalid signature, retrying with filtered blocks", account.ID)
42014201

42024202
// Conservative two-stage fallback:
42034203
// 1) Disable thinking + thinking->text (preserve content)
@@ -4212,7 +4212,7 @@ func (s *GatewayService) Forward(ctx context.Context, c *gin.Context, account *A
42124212
retryResp, retryErr := s.httpUpstream.DoWithTLS(retryReq, proxyURL, account.ID, account.Concurrency, account.IsTLSFingerprintEnabled())
42134213
if retryErr == nil {
42144214
if retryResp.StatusCode < 400 {
4215-
logger.LegacyPrintf("service.gateway", "Account %d: signature error retry succeeded (thinking downgraded)", account.ID)
4215+
logger.LegacyPrintf("service.gateway", "Account %d: thinking block retry succeeded (blocks downgraded)", account.ID)
42164216
resp = retryResp
42174217
break
42184218
}
@@ -6102,13 +6102,9 @@ func (s *GatewayService) isThinkingBlockSignatureError(respBody []byte) bool {
61026102
return false
61036103
}
61046104

6105-
// Log for debugging
6106-
logger.LegacyPrintf("service.gateway", "[SignatureCheck] Checking error message: %s", msg)
6107-
61086105
// 检测signature相关的错误(更宽松的匹配)
61096106
// 例如: "Invalid `signature` in `thinking` block", "***.signature" 等
61106107
if strings.Contains(msg, "signature") {
6111-
logger.LegacyPrintf("service.gateway", "[SignatureCheck] Detected signature error")
61126108
return true
61136109
}
61146110

0 commit comments

Comments
 (0)