From 118ca5cf6d5479df2ef66b5dce1e07e3ca3e657b Mon Sep 17 00:00:00 2001 From: ianshaw Date: Sun, 4 Jan 2026 18:26:39 -0800 Subject: [PATCH 1/2] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E7=A9=BAcontent?= =?UTF-8?q?=E5=A4=84=E7=90=86=E5=8F=8A=E6=9B=B4=E6=96=B0Gemini=E4=BD=BF?= =?UTF-8?q?=E7=94=A8=E6=8C=87=E5=8D=97=E9=93=BE=E6=8E=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 修复FilterThinkingBlocksForRetry对空content数组的处理 - docker-compose添加SECURITY_URL_ALLOWLIST_UPSTREAM_HOSTS配置 - 更新Gemini使用指南链接:检查归属地、修改归属地、激活Gemini Web --- backend/internal/service/gateway_request.go | 47 +++++++++++-------- deploy/docker-compose.yml | 5 ++ .../components/account/CreateAccountModal.vue | 18 +++++-- 3 files changed, 47 insertions(+), 23 deletions(-) diff --git a/backend/internal/service/gateway_request.go b/backend/internal/service/gateway_request.go index b385d2dc..aa48d880 100644 --- a/backend/internal/service/gateway_request.go +++ b/backend/internal/service/gateway_request.go @@ -99,13 +99,22 @@ func FilterThinkingBlocks(body []byte) []byte { // - Remove `redacted_thinking` blocks (cannot be converted to text). // - Ensure no message ends up with empty content. func FilterThinkingBlocksForRetry(body []byte) []byte { - // Fast path: check for presence of thinking-related keys in messages or top-level thinking config. - if !bytes.Contains(body, []byte(`"type":"thinking"`)) && - !bytes.Contains(body, []byte(`"type": "thinking"`)) && - !bytes.Contains(body, []byte(`"type":"redacted_thinking"`)) && - !bytes.Contains(body, []byte(`"type": "redacted_thinking"`)) && - !bytes.Contains(body, []byte(`"thinking":`)) && - !bytes.Contains(body, []byte(`"thinking" :`)) { + hasThinkingContent := bytes.Contains(body, []byte(`"type":"thinking"`)) || + bytes.Contains(body, []byte(`"type": "thinking"`)) || + bytes.Contains(body, []byte(`"type":"redacted_thinking"`)) || + bytes.Contains(body, []byte(`"type": "redacted_thinking"`)) || + bytes.Contains(body, []byte(`"thinking":`)) || + bytes.Contains(body, []byte(`"thinking" :`)) + + // Also check for empty content arrays that need fixing. + // Note: This is a heuristic check; the actual empty content handling is done below. + hasEmptyContent := bytes.Contains(body, []byte(`"content":[]`)) || + bytes.Contains(body, []byte(`"content": []`)) || + bytes.Contains(body, []byte(`"content" : []`)) || + bytes.Contains(body, []byte(`"content" :[]`)) + + // Fast path: nothing to process + if !hasThinkingContent && !hasEmptyContent { return body } @@ -195,20 +204,20 @@ func FilterThinkingBlocksForRetry(body []byte) []byte { newContent = append(newContent, block) } - if modifiedThisMsg { + // Handle empty content: either from filtering or originally empty + if len(newContent) == 0 { modified = true - // Handle empty content after filtering - if len(newContent) == 0 { - // Always add a placeholder to avoid upstream "non-empty content" errors. - placeholder := "(content removed)" - if role == "assistant" { - placeholder = "(assistant content removed)" - } - newContent = append(newContent, map[string]any{ - "type": "text", - "text": placeholder, - }) + placeholder := "(content removed)" + if role == "assistant" { + placeholder = "(assistant content removed)" } + newContent = append(newContent, map[string]any{ + "type": "text", + "text": placeholder, + }) + msgMap["content"] = newContent + } else if modifiedThisMsg { + modified = true msgMap["content"] = newContent } newMessages = append(newMessages, msgMap) diff --git a/deploy/docker-compose.yml b/deploy/docker-compose.yml index fbd79710..9c786d6d 100644 --- a/deploy/docker-compose.yml +++ b/deploy/docker-compose.yml @@ -91,6 +91,11 @@ services: - GEMINI_OAUTH_CLIENT_SECRET=${GEMINI_OAUTH_CLIENT_SECRET:-} - GEMINI_OAUTH_SCOPES=${GEMINI_OAUTH_SCOPES:-} - GEMINI_QUOTA_POLICY=${GEMINI_QUOTA_POLICY:-} + + # ======================================================================= + # Security Configuration + # ======================================================================= + - SECURITY_URL_ALLOWLIST_UPSTREAM_HOSTS=${SECURITY_URL_ALLOWLIST_UPSTREAM_HOSTS:-} depends_on: postgres: condition: service_healthy diff --git a/frontend/src/components/account/CreateAccountModal.vue b/frontend/src/components/account/CreateAccountModal.vue index 4c75626e..37ef96f0 100644 --- a/frontend/src/components/account/CreateAccountModal.vue +++ b/frontend/src/components/account/CreateAccountModal.vue @@ -1522,7 +1522,7 @@
· + 修改归属地 + + · + Date: Sun, 4 Jan 2026 18:34:19 -0800 Subject: [PATCH 2/2] =?UTF-8?q?fix(antigravity):=20=E6=89=A9=E5=B1=95=20is?= =?UTF-8?q?SignatureRelatedError=20=E6=A3=80=E6=B5=8B=20thinking=20?= =?UTF-8?q?=E7=BB=93=E6=9E=84=E9=94=99=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 添加对 "Expected thinking/redacted_thinking" 错误的检测 - 修复 antigravity 服务中 thinking 模式启用时的结构约束错误 - 确保此类错误能触发重试逻辑 --- .../internal/service/antigravity_gateway_service.go | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/backend/internal/service/antigravity_gateway_service.go b/backend/internal/service/antigravity_gateway_service.go index 7763bc40..cfbb85d2 100644 --- a/backend/internal/service/antigravity_gateway_service.go +++ b/backend/internal/service/antigravity_gateway_service.go @@ -574,7 +574,17 @@ func isSignatureRelatedError(respBody []byte) bool { } // Keep this intentionally broad: different upstreams may use "signature" or "thought_signature". - return strings.Contains(msg, "thought_signature") || strings.Contains(msg, "signature") + if strings.Contains(msg, "thought_signature") || strings.Contains(msg, "signature") { + return true + } + + // Also detect thinking block structural errors: + // "Expected `thinking` or `redacted_thinking`, but found `text`" + if strings.Contains(msg, "expected") && (strings.Contains(msg, "thinking") || strings.Contains(msg, "redacted_thinking")) { + return true + } + + return false } func extractAntigravityErrorMessage(body []byte) string {