Provider /v1/messages rejects role:"system" inside messages[] — Claude Code ≥ 2.1.154 incompatible
Maintainer thường phản hồi trong vòng 2 ngày
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 2/5
- Thời gian dự kiến
- 1-3 giờ
- Mức phù hợp với người mới
- 75/100
Hướng nghiên cứu
Tìm bộ xác thực yêu cầu của /v1/messages và mô hình của nó cho messages[].role; issue xác định giới hạn vai trò là điểm gây lỗi. Trước tiên, hãy đọc bộ xác thực và các kiểm thử yêu cầu của nó, sau đó kiểm tra cách các thông điệp đã được xác thực được chuyển tiếp upstream. Công việc hoàn tất khi một thông điệp có vai trò system sau lượt của user vượt qua bước xác thực và các trường hợp user và assistant hiện có vẫn hoạt động.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Provider /v1/messages rejects role:"system" inside messages[] — Claude Code ≥ 2.1.154 incompatible
Summary
The Provider Anthropic Messages endpoint validates messages[].role against only user/assistant and returns:
{"type":"error","error":{"type":"invalid_request_error","message":"Invalid input at messages.1.role"}}
This breaks vanilla Claude Code ≥ 2.1.154, which sends a system-role message inside messages[] (a still-open regression: anthropics/claude-code#63469). Your own command-code CLI sends the legacy shape and works — vanilla Claude Code against api.commandcode.ai/provider does not.
Repro (curl, max_tokens 2 — both uncharged/zero-cost)
Works (control, legacy shape):
curl https://api.commandcode.ai/provider/v1/messages \
-H "Authorization: Bearer $CMD_PROVIDER_API_KEY" \
-H "anthropic-version: 2023-06-01" -H "content-type: application/json" \
-d '{"model":"claude-haiku-5-5","max_tokens":2,"messages":[{"role":"user","content":"hi"}]}'
# → HTTP 200, normal completion
Fails with 400 Invalid input at messages.0.role (system-role message):
curl https://api.commandcode.ai/provider/v1/messages \
-H "Authorization: Bearer $CMD_PROVIDER_API_KEY" \
-H "anthropic-version: 2023-06-01" -H "content-type: application/json" \
-d '{"model":"claude-haiku-5-5","max_tokens":2,"messages":[{"role":"system","content":"You reply tersely."},{"role":"user","content":"hi"}]}'
Verified 2026-10-29: identical 400 on every Claude model in the catalog — claude-opus-5-5, claude-opus-5, claude-sonnet-5-5, claude-sonnet-4-6, claude-fable-5-1, claude-haiku-5-5 (so it's central validation, not per-upstream). The failure fires before upstream routing model-level plan checks fire earlier; the schema gate is the blocker.
Why this is valid per Anthropic's own API
Working with Messages API → System role in messages documents mid-conversation system messages on Opus 5/5.5, Sonnet 5/5.5, Haiku 5.5, Fable/Mythos 5.x, Opus 4.8 — legal after a user turn (only messages[0] is excluded, and Claude Code ≥ 2.1.154 places it after the first user message). First-party api.anthropic.com accepts this since Claude Code 2.1.154 onward.
References
- anthropics/claude-code#63469 — regression thread: Claude Code started sending
messages[].role="system"in 2.1.154; still unfixed upstream (closed stale 2026-08); broke DeepSeek/GLM/Kimi-compatible gateways for 5 months - free-claude-code#611 — a third-party Anthropic-compatible server fixed exactly this by widening its
rolevalidator to include"system"(then merging/forwarding) - Your docs example requests only ever use
usermessages, so the docs and validator are consistent today — but Claude Code (the highest-volume /v1/messages client) is not
Suggested fix
In the /v1/messages request validator, allow "system" alongside user|assistant for messages[].role (≈10 lines in the pydantic model: role: Literal["user","assistant","system"]), then either forward as-is to system-role-aware upstreams (Anthropic's newer API accepts it on the 5.x families) or pre-merge system-role messages into the top-level system param for legacy upstreams. The free-claude-code fix is the minimal version and has been in production for 5 months.
Environment: macOS, Claude Code 2.1.308 (Homebrew cask), Provider plan key. happy to provide more traces (request captured verbatim via local listener: anthropic-beta headers list included).
- Ngôn ngữ chính
- Không có dữ liệu ngôn ngữ
- Star
- 4.2k
- Fork
- 372
- Merge trung bình
- 4 ngày 15 giờ
- Pull request đã merge (30 ngày)
- 9
Chuẩn bị môi trường
Dự án này không cung cấp dev container, Dockerfile hay hướng dẫn đóng góp, nên bạn cần tự thiết lập môi trường: hãy bắt đầu từ README và xem hướng dẫn đóng góp lần đầu của chúng tôi để biết các bước chung.
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của CommandCodeAI/command-code
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 65/100
CommandCodeAI/command-code#1088 ·
Maintainer thường phản hồi trong vòng 2 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
CommandCodeAI/command-code#1082 · 1 bình luận · 2 reaction ·
Maintainer thường phản hồi trong vòng 2 ngày
-
Feature request: auto-reconnect remote control (/rc) after restartCó thể đã có người làm @aliarain đã nhận 9 ngày trước. Đang mởp2
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 85/100
CommandCodeAI/command-code#992 · 1 bình luận · 1 người được giao ·
Maintainer thường phản hồi trong vòng 2 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
CommandCodeAI/command-code#933 ·
Maintainer thường phản hồi trong vòng 2 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
CommandCodeAI/command-code#855 ·
Maintainer thường phản hồi trong vòng 2 ngày
Tất cả issue của CommandCodeAI/command-code
Issue tương tự
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 74/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Let TypeScript accept an initial object in ReactiveDictCó thể đã có người làm @yograj-vijay-yadav đã nhận hôm nay. Đang mởbug good first issue help wanted workshop
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 92/100
meteor/meteor#14919 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 86/100
marmelab/atomic-crm#400 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
-
good first issue help wanted
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
servo/rust-smallvec#827 ·
Maintainer thường phản hồi trong vòng 1 ngày