vllm - 💡(How to fix) Fix [Bug]: Claude Code CLI >= 2.1.154 sends ctx/msg/system roles and breaks vLLM Anthropic Messages API validation

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…

Error Message

API Error: 400 { "error": { "message": "1 validation error:\n {'type': 'literal_error', 'loc': ('body', 'messages', 1, 'role'), 'msg': "Input should be 'user' or 'assistant'", 'input': 'system', 'ctx': {'expected': "'user' or 'assistant'"}}", "type": "Bad Request", "param": null, "code": 400 } }

Root Cause

Because of this strict validation, requests from recent Claude Code versions fail before model inference starts.

Fix Action

Fix / Workaround

A temporary workaround reported by users is to expand the allowed roles in vllm/entrypoints/anthropic/protocol.py, but a proper upstream fix should probably normalize these roles instead of only expanding the enum.

Possible temporary patch:

Code Example

vLLM version: 0.20.1
Docker image: vllm/vllm-openai:v0.20.1-cu129
Python: 3.12 inside container
Endpoint: Anthropic-compatible /v1/messages
Client: Claude Code CLI >= 2.1.154
Deployment: Docker
Model: openai/gpt-oss-20b or compatible local model

---

API Error: 400 {
  "error": {
    "message": "1 validation error:\n  {'type': 'literal_error', 'loc': ('body', 'messages', 1, 'role'), 'msg': \"Input should be 'user' or 'assistant'\", 'input': 'system', 'ctx': {'expected': \"'user' or 'assistant'\"}}",
    "type": "Bad Request",
    "param": null,
    "code": 400
  }
}
RAW_BUFFERClick to expand / collapse

Your current environment

<details> <summary>Environment</summary>
vLLM version: 0.20.1
Docker image: vllm/vllm-openai:v0.20.1-cu129
Python: 3.12 inside container
Endpoint: Anthropic-compatible /v1/messages
Client: Claude Code CLI >= 2.1.154
Deployment: Docker
Model: openai/gpt-oss-20b or compatible local model
</details>

🐛 Describe the bug

After upgrading Claude Code CLI to version 2.1.154 or later, Claude Code appears to send additional message roles such as ctx, msg, and system inside the Anthropic Messages API messages array.

vLLM's Anthropic protocol currently validates incoming message roles as only user or assistant.

Because of this strict validation, requests from recent Claude Code versions fail before model inference starts.

Example error:

API Error: 400 {
  "error": {
    "message": "1 validation error:\n  {'type': 'literal_error', 'loc': ('body', 'messages', 1, 'role'), 'msg': \"Input should be 'user' or 'assistant'\", 'input': 'system', 'ctx': {'expected': \"'user' or 'assistant'\"}}",
    "type": "Bad Request",
    "param": null,
    "code": 400
  }
}

This seems to have started after Claude Code CLI 2.1.154.

A temporary workaround reported by users is to expand the allowed roles in vllm/entrypoints/anthropic/protocol.py, but a proper upstream fix should probably normalize these roles instead of only expanding the enum.

Possible temporary patch:

- role: Literal["user", "assistant"]
+ role: Literal["user", "assistant", "ctx", "msg", "system"]

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…

Still need to ship something?

×6

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

Back to top recommendations

TRENDING

vllm - 💡(How to fix) Fix [Bug]: Claude Code CLI >= 2.1.154 sends ctx/msg/system roles and breaks vLLM Anthropic Messages API validation