JIA-ss
ad90bb4645
fix(api): 修复 thinking 块被意外修改导致的 400 错误
问题描述:
使用扩展思考功能时,偶现以下错误:
"thinking or redacted_thinking blocks in the latest assistant message cannot be modified"
根因分析:
当代理服务修改请求体中的某些字段时(如 metadata.user_id、model),
使用 map[string]any 解析整个 JSON 后重新序列化,导致:
1. 字段顺序改变(Go map 序列化按字母排序)
2. 数字格式变化(如 1.0 → 1)
3. Unicode 转义变化
Claude API 对 thinking 块进行字节级验证,任何变化都会触发错误。
修复内容:
1. identity_service.go - RewriteUserID/RewriteUserIDWithMasking
使用 json.RawMessage 保留其他字段的原始字节
2. gateway_service.go - replaceModelInBody
使用 json.RawMessage 保留其他字段的原始字节
3. gateway_service.go - normalizeClaudeOAuthRequestBody
保留 messages 的原始字节,跳过包含 thinking 块的消息修改
4. gateway_service.go - isThinkingBlockSignatureError
添加 "cannot be modified" 错误检测,触发自动重试
5. antigravity_gateway_service.go - isSignatureRelatedError
添加 "cannot be modified" 错误检测
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-03 16:15:37 +08:00
..
2026-01-13 11:14:32 +08:00
2026-01-15 15:14:44 +08:00
2026-01-07 16:59:35 +08:00
2025-12-26 16:45:40 +08:00
2026-01-17 18:00:07 +08:00
2026-01-17 18:00:07 +08:00
2026-01-29 01:28:43 +08:00
2026-01-19 17:06:16 +08:00
2026-01-26 10:44:38 +08:00
2026-01-15 15:14:44 +08:00
2026-01-01 18:59:38 +08:00
2026-02-02 22:06:37 +08:00
2026-02-02 22:06:37 +08:00
2026-01-09 19:43:19 +08:00
2026-01-11 10:55:25 +08:00
2026-02-02 21:47:47 +08:00
2026-01-30 16:45:04 +08:00
2026-01-30 17:28:53 +08:00
2026-01-30 16:45:04 +08:00
2026-01-05 00:56:48 +08:00
2026-02-03 16:15:37 +08:00
2026-01-05 17:14:06 +08:00
2026-02-03 14:23:47 +08:00
2026-01-24 23:41:36 +08:00
2026-01-16 11:57:14 +08:00
2026-02-03 14:25:30 +08:00
2026-01-22 21:09:28 +08:00
2026-01-23 10:29:52 +08:00
2026-01-24 23:04:48 +08:00
2026-01-18 22:13:47 +08:00
2026-01-11 10:55:25 +08:00
2026-01-16 17:26:05 +08:00
2026-01-18 22:23:03 +08:00
2026-01-18 22:23:03 +08:00
2026-01-18 22:13:47 +08:00
2026-01-09 21:59:32 +08:00
2026-01-11 10:55:26 +08:00
2026-02-03 13:38:44 +08:00
2026-02-03 13:38:44 +08:00
2025-12-25 17:15:01 +08:00
2025-12-31 08:50:12 +08:00
2026-01-04 22:10:32 +08:00
2026-01-05 17:07:29 +08:00
2026-02-02 21:47:02 +08:00
2026-01-08 23:07:00 +08:00
2026-01-16 17:35:17 +08:00
2026-01-23 10:29:52 +08:00
2026-01-03 06:32:51 -08:00
2026-01-05 14:41:08 +08:00
2026-01-18 10:52:18 +08:00
2026-01-19 19:50:57 +08:00
2026-01-18 10:52:18 +08:00
2026-01-18 10:52:18 +08:00
2025-12-28 09:49:54 +08:00
2026-02-03 13:38:44 +08:00
2026-01-24 22:55:28 +08:00
2026-01-26 09:19:53 +08:00
2026-01-29 02:36:28 +08:00
2026-02-02 22:06:37 +08:00
2026-01-29 01:49:51 +08:00
2026-01-29 02:03:54 +08:00
2026-01-05 00:56:48 +08:00
2026-01-04 18:26:39 -08:00
2026-01-31 02:01:51 +08:00
2025-12-31 08:50:12 +08:00
2026-02-03 16:15:37 +08:00
2026-02-03 06:01:29 +08:00
2026-02-03 06:01:29 +08:00
2026-02-02 22:06:37 +08:00
2026-01-26 04:40:38 +08:00
2026-01-08 23:47:29 +08:00
2026-01-08 23:47:29 +08:00
2025-12-26 00:11:03 -08:00
2026-01-04 15:36:00 +08:00
2026-01-14 15:55:44 +08:00
2026-01-23 10:29:52 +08:00
2025-12-31 16:25:45 +08:00
2025-12-26 00:11:03 -08:00
2026-02-02 21:47:47 +08:00
2026-01-05 17:07:29 +08:00
2026-01-16 17:26:05 +08:00
2026-01-18 20:08:40 +08:00
2026-02-03 16:15:37 +08:00
2026-01-16 13:03:04 +08:00
2026-01-23 15:17:47 +08:00
2026-01-17 11:00:07 +08:00
2026-01-17 11:00:07 +08:00
2026-01-20 22:46:23 +08:00
2026-01-15 23:52:50 +08:00
2026-02-03 15:13:10 +08:00
2026-01-27 19:13:01 +08:00
2026-01-16 17:35:17 +08:00
2026-01-23 10:29:52 +08:00
2026-01-13 16:47:35 +08:00
2026-01-13 16:47:35 +08:00
2026-01-17 11:00:07 +08:00
2026-01-17 11:00:07 +08:00
2026-02-03 14:25:30 +08:00
2026-01-10 01:38:47 +08:00
2026-01-15 21:31:55 +08:00
2026-01-11 20:55:44 +08:00
2026-01-15 21:31:55 +08:00
2026-01-15 15:14:44 +08:00
2026-01-15 15:14:44 +08:00
2026-01-15 21:31:55 +08:00
2026-01-09 20:53:44 +08:00
2026-01-10 01:38:47 +08:00
2026-01-10 01:38:47 +08:00
2026-01-09 20:53:44 +08:00
2026-01-15 15:14:44 +08:00
2026-01-15 23:02:15 +08:00
2026-01-09 20:53:44 +08:00
2026-01-11 23:00:31 +08:00
2026-01-15 15:14:44 +08:00
2026-01-15 21:31:55 +08:00
2026-01-09 20:53:44 +08:00
2026-02-03 14:25:30 +08:00
2026-01-12 14:17:42 +08:00
2026-01-12 14:17:42 +08:00
2026-01-09 20:53:44 +08:00
2026-01-11 23:57:20 +08:00
2026-01-16 23:36:52 +08:00
2026-01-15 21:31:55 +08:00
2026-01-15 15:14:44 +08:00
2026-02-02 20:16:17 +08:00
2026-01-15 15:14:44 +08:00
2026-01-09 20:52:17 +08:00
2026-01-12 00:02:19 +08:00
2026-01-15 15:14:44 +08:00
2026-01-09 20:53:44 +08:00
2026-01-16 23:47:42 +08:00
2026-01-10 13:14:35 +08:00
2026-01-10 13:14:35 +08:00
2026-01-11 10:55:25 +08:00
2026-01-15 15:15:20 +08:00
2026-01-15 15:14:44 +08:00
2026-01-15 15:15:20 +08:00
2026-01-03 06:29:02 -08:00
2026-01-15 15:06:34 +08:00
2026-01-25 13:32:08 +08:00
2026-01-26 09:57:44 +08:00
2025-12-26 16:45:40 +08:00
2026-02-03 13:38:44 +08:00
2026-01-12 14:19:06 +08:00
2026-01-12 14:19:06 +08:00
2026-01-12 14:19:06 +08:00
2026-01-12 14:19:06 +08:00
2026-01-19 11:45:04 +08:00
2026-02-03 13:38:44 +08:00
2025-12-26 16:45:40 +08:00
2026-02-03 13:38:44 +08:00
2026-01-20 11:40:55 +08:00
2026-01-24 20:26:01 +08:00
2026-01-25 18:12:15 +08:00
2026-01-11 21:54:52 -08:00
2026-01-16 15:25:33 +08:00
2026-01-16 15:25:33 +08:00
2026-01-23 10:58:30 +08:00
2026-01-23 10:29:52 +08:00
2026-01-15 19:08:07 +08:00
2026-01-15 18:27:06 +08:00
2026-02-02 20:05:37 +08:00
2026-02-02 20:05:37 +08:00
2026-01-04 19:28:20 +08:00
2025-12-31 16:25:45 +08:00
2026-01-26 09:19:53 +08:00
2025-12-31 23:42:01 +08:00
2026-01-04 19:28:20 +08:00
2026-01-20 11:59:13 +08:00
2026-01-19 19:50:57 +08:00
2026-01-18 10:52:18 +08:00
2026-02-03 14:36:29 +08:00
2026-01-11 10:55:25 +08:00
2026-01-03 06:37:08 -08:00
2026-01-01 18:58:34 +08:00
2026-01-26 09:19:53 +08:00
2026-01-24 20:26:01 +08:00
2025-12-26 16:45:40 +08:00
2026-01-26 09:19:53 +08:00
2026-01-16 15:25:33 +08:00
2026-02-02 20:05:37 +08:00