Skip to content

[Bug] Claude Desktop Cowork (claude-desktop-3p, adaptive thinking) 多轮稳定 400 "Invalid signature in thinking block" #3052

@kongkong7777

Description

@kongkong7777

环境

  • CLIProxyAPI 版本:v6.9.38(当前最新)
  • 客户端:Claude Desktop Cowork v2.1.119,按官方"third-party inference"模式配置成走 CLIProxyAPI
  • 认证:Claude Max OAuth 账号
  • 复现的模型claude-opus-4-7claude-opus-4-6claude-opus-4-5-20251101claude-sonnet-4-6 都中招

现象

Cowork 多轮对话第二轮及以后稳定 400:

messages.1.content.0: Invalid `signature` in `thinking` block

第一轮没问题,只要带上历史就报错。

这个场景特有的指纹

请求 body 的 system[0].text 里能看到:

x-anthropic-billing-header: cc_version=2.1.119.<fingerprint>; cc_entrypoint=claude-desktop-3p; cch=...;

请求 body 里同时有:

{
  "thinking": {"type": "adaptive"},
  "messages": [
    ...,
    { "role": "assistant", "content": [
      { "type": "thinking",
        "thinking": "...",
        "signature": "gAAAAABp7JIk-p-NNsh6kcHis7Jecs..." }
    ]},
    ...
  ]
}

注意 "thinking": {"type": "adaptive"} 是 Cowork 新引入的"自适应思考"模式(在 Cowork UI 里以 "Adaptive thinking — Thinks for more complex tasks" 开关呈现)。

跟之前已关闭的几个 issue 的区别

我们这边的 signature 本身就是被 Anthropic 拒收的,可能的原因:

  1. Cowork v2.1.119 客户端在 adaptive 模式下生成的 signature 跟 Anthropic 后端校验逻辑对不上(Cowork 侧 bug,CLIProxyAPI 没法直接修);或
  2. Anthropic 后端最近收紧了 adaptive 模式的签名校验。

触发频率

我们的部署日均 30k 请求左右,只要 Cowork 用户开了 adaptive thinking + 多轮对话,必中。等于不修就没法用 Cowork 走 CLIProxy。

我们目前在网关侧的 workaround(已稳定生产运行)

考虑到 Cowork UI 本来就不向用户暴露 thinking 块,对模型侧上下文连续性才是关键。我们在网关层加了预处理:

  1. 检测 Cowork 请求(body 里出现 claude-desktop-3p,或 thinking.type === "adaptive"
  2. 遍历 messages[].content[],把每一个 thinking 块转成普通 text 块 —— 保留推理文本内容,只丢掉签名
// 改之前
{ type: "thinking", thinking: "...", signature: "gAAAAA..." }
// 改之后
{ type: "text", text: "<previous_reasoning>\n...\n</previous_reasoning>" }
  1. redacted_thinking(已加密,没有明文)替换成占位:{ type: "text", text: "<previous_reasoning_redacted/>" }

效果:

  • 100% 修复,Cowork 全模型都能正常多轮
  • 模型仍然能看到自己上一轮的完整 reasoning(XML 标签是 Anthropic 模型原生约定,不会被错误理解为新 prompt 输入)
  • 用户体验完全不变(Cowork UI 本来就不显示 thinking)
  • 端到端验证:拿一个 25 个 thinking block / 77 messages 的真实失败请求重放,HTTP 200

建议的上游修法

希望 CLIProxyAPI 能加一个针对已知存在 bug 的客户端的 opt-in 兼容开关,例如:

client-workarounds:
  cowork-adaptive-thinking-fix: true

只在检测到 claude-desktop-3p + adaptive 同时出现时才生效,避免影响 Claude Code CLI 等正常工作的客户端流量。

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions