ollama - 💡(How to fix) Fix Claude Code v2.1.154+ 发送的消息格式中,将 `system` 角色放入了 `messages` 数组,导致 Ollama 的 Anthropic 兼容层返回 400 错误。

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
RAW_BUFFERClick to expand / collapse

Describe the bug

Claude Code v2.1.154+ 发送的消息格式中,将 system 角色放入了 messages 数组,导致 Ollama 的 Anthropic 兼容层返回 400 错误。

错误信息:unknown variant 'system', expected 'user' or 'assistant'

To Reproduce

  1. 启动 Ollama(任意版本,包括最新 v0.23.0)
  2. 安装 Claude Code v2.1.154 或更高版本
  3. 设置环境变量 ANTHROPIC_BASE_URL=http://localhost:11434
  4. 运行 claude,发送任意消息
  5. 终端报错如上

Expected behavior

Ollama 应能正确处理 Claude Code 发送的新格式消息,或者提供一个兼容模式开关。

Environment

  • Ollama version: v0.23.0
  • Claude Code version: 2.1.156
  • OS: Windows 11
  • Model: qwen3.6:27b

Additional context

社区分析:https://zhuanlan.zhihu.com/p/2043723916825326284 同类问题(vLLM):https://github.com/vllm-project/vllm/issues/44000

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

FAQ

Expected behavior

Ollama 应能正确处理 Claude Code 发送的新格式消息,或者提供一个兼容模式开关。

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING

ollama - 💡(How to fix) Fix Claude Code v2.1.154+ 发送的消息格式中,将 `system` 角色放入了 `messages` 数组,导致 Ollama 的 Anthropic 兼容层返回 400 错误。