You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
POST https://api.commandcode.ai/provider/v1/messages rejects any request whose messages array
contains a {"role":"system"} entry, with HTTP 400 {"type":"error","error":{"type":"invalid_request_error","message":"Invalid input at messages.1.role"}}.
Mid-conversation system messages are a documented, generally-available Anthropic Messages API
capability, and the current Claude Code build emits them routinely — so Claude Code cannot complete
a single turn against this endpoint, on any model.
The same endpoint accepts a top-level system field (both string and content-block array), and
accepts user / assistant roles inside messages. The trigger is specifically the system role
appearing inside messages.
mid-conversation system messages are available on the Claude API, Amazon Bedrock and Google Cloud;
they are supported on Claude Opus 5.5 (among others);
"No beta header is required for mid-conversation system messages";
placement rules: the entry must not be first in messages, must immediately follow a user turn,
and must precede an assistant turn or end the array.
/provider/v1/messages should accept that shape, or — if it is intentionally unsupported — return a
specific documented error rather than the generic Invalid input at messages.N.role, so clients can
detect it and rewrite the request (e.g. by hoisting the content into the top-level system field).
Actual Behavior
400 {"type":"error","error":{"type":"invalid_request_error","message":"Invalid input at messages.1.role"}}
Steps to reproduce the issue
Minimal repro plus two controls, all against the same key / model (2-message body, so the system entry sits at index 1 and is both last-in-array and directly after the user turn —
i.e. fully compliant with the documented placement rules):
KEY="$CMDCODE_KEY"
BASE=https://api.commandcode.ai/provider/v1/messages
H=(-H "Authorization: Bearer $KEY" -H 'content-type: application/json')
# (a) mid-conversation system role -> 400
curl -sS "${H[@]}" -X POST "$BASE" -d '{"model":"claude-opus-5-5","max_tokens":16, "messages":[{"role":"user","content":"hi"},{"role":"system","content":"ctx"}]}'# -> 400 {"type":"error","error":{"type":"invalid_request_error","message":"Invalid input at messages.1.role"}}# (b) the SAME text as a top-level system array -> 200
curl -sS "${H[@]}" -X POST "$BASE" -d '{"model":"claude-opus-5-5","max_tokens":16, "system":[{"type":"text","text":"ctx"}],"messages":[{"role":"user","content":"hi"}]}'# -> 200# (c) top-level system as a plain string -> 200
curl -sS "${H[@]}" -X POST "$BASE" -d '{"model":"claude-opus-5-5","max_tokens":16, "system":"ctx","messages":[{"role":"user","content":"hi"}]}'# -> 200
The rejection is about the role value itself, not about the content shape or any field on the
entry: it reproduces with "content":"ctx" (string), with content-block arrays, and at any index.
For reference, this is the request the current Claude Code build actually sends (captured
verbatim; note messages[1]):
{"model":"claude-opus-5","max_tokens":32000,
"system":[{"type":"text","text":"You are Claude Code, Anthropic's official CLI for Claude."}],
"messages":[{"role":"user","content":[{"type":"text","text":"hi"}]},
{"role":"system","content":[{"type":"text","text":"<context injected mid-session>"}]}]}
(Reproduced identically on 2.1.274 and 2.1.278; the request shape is emitted by the CLI, not
version-specific.)
Isolation — same key, same model (claude-opus-5-5), one variable changed per row. Only the system role inside messages fails; every other shape returns 200. Note that the added anthropic-beta header makes no difference, consistent with the feature requiring no beta header.
messages contents
result
user only
200
user + assistant + user
200
user + system (index 1, last in array)
400
system as top-level string
200
system as top-level content-block array
200
user + assistant, each with content-block arrays
200
user + system, with anthropic-beta: context-1m-2025-08-07 added
400 (identical message)
user + system, with no anthropic-beta header
400 (identical message)
Command Code Version
N/A — reporting against the Provider API directly
Operating System
Linux
Terminal/IDE
server-side / n/a
Shell
bash
Session file (optional)
No response
Fix prompt (optional)
POST /provider/v1/messages rejects any request whose messages array contains a {"role":"system"}
entry, returning 400 {"error":{"type":"invalid_request_error","message":"Invalid input at messages.N.role"}}.
Mid-conversation system messages are a documented Anthropic Messages API feature (no beta header
required, supported on Opus 5.5) and Claude Code sends them on every turn, so the endpoint is
currently unusable for that client.
Reproduce: POST a body with messages:[{"role":"user",...},{"role":"system",...}] -> 400. The same
content as a top-level system field (string or block array) -> 200, and user/assistant roles in messages -> 200, so the trigger is specifically the system role inside messages.
Check: the request above returns a normal completion, and a mid-conversation system entry placed
per Anthropic's rules (not first, immediately after a user turn, last in the array or before an assistant turn) is accepted. If the shape is intentionally unsupported, return a distinct error code
instead of the generic Invalid input, and document the limitation on the Provider API errors page.
All Claude models reproduce identically; the failure is not model-specific. A minimal, model-only
control (POST /provider/v1/messages with the same model and a plain user message) returns 200, so
credentials and routing are fine.
Impact: Claude Code cannot complete any turn. The identical limitation forced a client-side choice
between dropping mid-session context injection or not using this gateway.
Minor, general request: the error names messages.1.role (good) but param:"input" style errors on /responses name no index or item type. Naming the offending index and type consistently would
make this class of bug self-diagnosing.
Summary
POST https://api.commandcode.ai/provider/v1/messagesrejects any request whosemessagesarraycontains a
{"role":"system"}entry, with HTTP 400{"type":"error","error":{"type":"invalid_request_error","message":"Invalid input at messages.1.role"}}.Mid-conversation system messages are a documented, generally-available Anthropic Messages API
capability, and the current Claude Code build emits them routinely — so Claude Code cannot complete
a single turn against this endpoint, on any model.
The same endpoint accepts a top-level
systemfield (both string and content-block array), andaccepts
user/assistantroles insidemessages. The trigger is specifically thesystemroleappearing inside
messages.Expected Behavior
Per Anthropic's specification
(https://platform.claude.com/docs/en/build-with-claude/mid-conversation-system-messages):
messages, must immediately follow auserturn,and must precede an
assistantturn or end the array./provider/v1/messagesshould accept that shape, or — if it is intentionally unsupported — return aspecific documented error rather than the generic
Invalid input at messages.N.role, so clients candetect it and rewrite the request (e.g. by hoisting the content into the top-level
systemfield).Actual Behavior
400 {"type":"error","error":{"type":"invalid_request_error","message":"Invalid input at messages.1.role"}}
Steps to reproduce the issue
systementry sits at index 1 and is both last-in-array and directly after theuserturn —i.e. fully compliant with the documented placement rules):
rolevalue itself, not about thecontentshape or any field on theentry: it reproduces with
"content":"ctx"(string), with content-block arrays, and at any index.verbatim; note
messages[1]):{"model":"claude-opus-5","max_tokens":32000, "system":[{"type":"text","text":"You are Claude Code, Anthropic's official CLI for Claude."}], "messages":[{"role":"user","content":[{"type":"text","text":"hi"}]}, {"role":"system","content":[{"type":"text","text":"<context injected mid-session>"}]}]}(Reproduced identically on 2.1.274 and 2.1.278; the request shape is emitted by the CLI, not
version-specific.)
claude-opus-5-5), one variable changed per row. Only thesystemrole insidemessagesfails; every other shape returns 200. Note that the addedanthropic-betaheader makes no difference, consistent with the feature requiring no beta header.messagescontentsuseronlyuser+assistant+useruser+system(index 1, last in array)systemas top-level stringsystemas top-level content-block arrayuser+assistant, each with content-block arraysuser+system, withanthropic-beta: context-1m-2025-08-07addeduser+system, with noanthropic-betaheaderCommand Code Version
N/A — reporting against the Provider API directly
Operating System
Linux
Terminal/IDE
server-side / n/a
Shell
bash
Session file (optional)
No response
Fix prompt (optional)
POST /provider/v1/messagesrejects any request whosemessagesarray contains a{"role":"system"}entry, returning 400
{"error":{"type":"invalid_request_error","message":"Invalid input at messages.N.role"}}.Mid-conversation system messages are a documented Anthropic Messages API feature (no beta header
required, supported on Opus 5.5) and Claude Code sends them on every turn, so the endpoint is
currently unusable for that client.
Reproduce: POST a body with
messages:[{"role":"user",...},{"role":"system",...}]-> 400. The samecontent as a top-level
systemfield (string or block array) -> 200, anduser/assistantroles inmessages-> 200, so the trigger is specifically thesystemrole insidemessages.Check: the request above returns a normal completion, and a mid-conversation
systementry placedper Anthropic's rules (not first, immediately after a
userturn, last in the array or before anassistantturn) is accepted. If the shape is intentionally unsupported, return a distinct error codeinstead of the generic
Invalid input, and document the limitation on the Provider API errors page.Additional context
Provider:
base_url = https://api.commandcode.ai/provider/v1, API-key auth.control (
POST /provider/v1/messageswith the same model and a plain user message) returns 200, socredentials and routing are fine.
between dropping mid-session context injection or not using this gateway.
/v1/messages) and the/responsesinput-item family in Provider API /v1/responses rejects Codex's tool_search_call / tool_search_output input items with 400 "Invalid input" #893. Both show that aligning the request validation with thedocumented Anthropic / Responses shapes is the accepted direction.
messages.1.role(good) butparam:"input"style errors on/responsesname no index or item type. Naming the offending index and type consistently wouldmake this class of bug self-diagnosing.