Files
magpie/internal
yetone 1ddcc3e8cc gateway: a provider that refuses a system message inside messages gets its text on the top-level system, and an empty one left out (#1407, liuyejinghong: Command Code "Invalid input at messages.1.role")
Claude Code puts system messages inside messages[] (its environment, and a
turn's effort as output_config on an empty one). Command Code's Provider
API (the "commandcode" API-key preset, Anthropic at
api.commandcode.ai/provider) turns away any of them with 400 "Invalid input
at messages.N.role", so every such turn failed.

It is handled as the other shapes Claude Code sends and a relay may refuse
(anthropic_shapes.go): on a 400 naming messages.N.role, where message N of
the body as sent is a system one, the provider is marked unfit for
shape:messages[].role=system, asked again at once, and from then on sent
each system message's text at the end of the top-level system (a string
system becomes one text block first), an empty one left out. A role
refusal over a user or assistant message marks nothing, and a provider that
takes system messages gets them where the agent put them. This runs in
forward/forwardOnce, so it also covers a moved commandcode-plan, whose
plugin fetch passes the gateway's Messages body to the same API.

Verified:
- TestSystemMessageRefusedGoesOnTop (the issue's request and the
  effort-only system message) fails without the change with
  "status 400: ... Command Code: Invalid input at messages.1.role";
  TestSystemMessageKeptWhereTaken checks the neighbours stay as sent.
- Real Command Code (the owner's GOAT key): curl user,system,user gives
  400 "Invalid input at messages.1.role"; user,user and a top-level system
  array give 200. Through this gateway (New().Handler(), temp HOME, real
  key) both the issue's request and the effort-only variant answer 200.
- gofmt -l, go vet, GOOS=linux and GOOS=windows go vet -tags nogui
  ./internal/gateway, go test -tags nogui -count=1 ./internal/gateway
  under a temp HOME: all pass.
2026-10-09 22:14:45 +08:00
..
…
…