[BUG] Claude Code for VS Code API Error: 400 messages[1].role must be either 'user' or 'assistant', but got 'system'
Resolved 💬 25 comments Opened May 29, 2026 by hswyxj Closed Jul 1, 2026
Preflight Checklist
- [x] I have searched existing issues and this hasn't been reported yet
- [x] This is a single bug report (please file separate reports for different bugs)
- [x] I am using the latest version of Claude Code
What's Wrong?
- Claude Code for VS Code 报错信息 messages[1].role must be either 'user' or
'assistant', but got 'system'
- CLI 正常但 VS Code 扩展Claude Code for VS Code报错
What Should Happen?
Claude 应该正常回复信息
Error Messages/Logs
Steps to Reproduce
1.Claude Code for VS Code发送任何信息
2.出现错误:"API Error: 400 messages[1].role must be either 'user' or 'assistant', but got 'system'"
- CLI 正常但 VS Code 扩展Claude Code for VS Code报错
Claude Model
None
Is this a regression?
Yes, this worked in a previous version
Last Working Version
_No response_
Claude Code Version
2.1.156
Platform
Anthropic API
Operating System
Windows
Terminal/Shell
Other
Additional Information
<img width="558" height="343" alt="Image" src="https://github.com/user-attachments/assets/5fd09be8-d580-4a31-97b0-867882dee713" />
25 Comments
我也遇到这个问题,怀疑是vscode 插件版本问题,更新前没遇到
重启后 CLI 也报这个错了==
已解决:安装和自己终端相同版本的Claude code for vscode
回退下版本就好了
应该就是刚才release才产生的bug,无语了这种恶性Bug都能在release版本有
我回退了两天前的版本,然后重启一下vscode就好了
回退到 版本:2.1.153 就好了,这是新版本的问题 这么大的问题 都没测试吗?重大bug
你用的哪个API?我这边156版本cli也有问题
https://github.com/anthropics/claude-code/issues/63469
我也遇到这个问题了,我用的mimo,回退旧版插件解决了
minimax , 你回退到 版本:2.1.153 就好了
暴露了API兼容的脆弱性
因为Claude Code 更新到 V2.1.154 版本。新版本在构造 API 请求时改变了 messages 的格式,把 system 消息放到了 messages 数组内部,而 Anthropic 官方 API 能处理这种格式,但第三方模型不认这种格式,直接返回 400 错误。要先回退版本,再把更新关闭了可以先用
零时解决方案
powershell
$env:CLAUDE_CODE_SIMPLE="1"
$env:ANTHROPIC_DISABLE_SYSTEM_PROMPT="true"
claude --bare
改格式纯恶心人
<img width="1503" height="511" alt="Image" src="https://github.com/user-attachments/assets/7eedae33-eb19-4bfe-a4e0-d04a757f32a0" /> 2.1.156已经修复了,升级下就好了
2.1.156 还是一样报错啊
cli好了
vscode 插件还是崩的
没有吧,我的还不行
<img width="1984" height="213" alt="Image" src="https://github.com/user-attachments/assets/650e2979-92b2-4d96-b537-c0c9a0e7e664" />
那可能只是mimo好了吧,快速兼容过来了
确实。mimo好了 deepseek还是报错。这种传输协议、入参格式的问题。只能靠模型方去适配了,Anthropic是不可能主动改回去的。等一手deepseek的官方Agent 吧
事了拂衣去 深藏身与名
哈基mi 你这家伙 蕾姆
<img width="1381" height="1269" alt="Image" src="https://github.com/user-attachments/assets/691410b4-82d9-41aa-9d93-8b91ed2dfd2d" />
now the problem has been solved (deepseek)
删除.claude重新安装也许会好,这个也是cc自己推出的能力,不过codex也好用,对于编程来说备胎很多
Closing for now — inactive for too long. Please open a new issue if this is still relevant.