API Error: 400 Failed to deserialize the JSON body into the target type: messages[1].role: unknown variant `system`, expected `user` or `assistant` at line 1 column 17119

解决方案

方案一:设置环境变量(推荐)

在您的系统中添加环境变量,禁用 Claude Code 的"自适应思考"功能

# 临时设置(当前终端会话)
export CLAUDE_CODE_SIMPLE=1

# 永久设置(添加到 ~/.bashrc 或 ~/.zshrc)
echo 'export CLAUDE_CODE_SIMPLE=1' >> ~/.zshrc
source ~/.zshrc
方案2 : 回退到2.1.152 ,并禁用自动升级
1 安装老版本
npm install -g @anthropic-ai/claude-code@2.1.152
2 配置禁用自动升级
方法一: 
编辑:

~/.claude/settings.json
加入:
{
  "env": {
    "DISABLE_AUTOUPDATER": "1"
  }
}

 
方法二: 

编辑:
~/.zshrc
添加:
export DISABLE_AUTOUPDATER=1
然后:
source ~/.zshrc
这样所有终端都会生效。



另: 如果只想升级稳定版本
 
autoUpdatesChannel: "stable"

Logo

汇聚全球AI编程工具,助力开发者即刻编程。

更多推荐