Studio: accept system-role messages in Claude Code requests#6006
Conversation
for more information, see https://pre-commit.ci
There was a problem hiding this comment.
Code Review
This pull request introduces normalization for Anthropic system messages by extracting system-role messages from the messages list and merging them into the top-level system field. The feedback identifies a potential bug where an explicit null content value in a system message could result in a literal "None" string being used as the system prompt, and provides a code suggestion to handle None values defensively.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
…slothai#6006 Treat a system-role message with null content as empty instead of the literal string "None", and skip None blocks inside list content. Adds a regression test.
|
Pushed a small follow-up (921e314) to harden Before this, a The fix returns if content is None: # null content must not become the literal "None"
return ""
...
if block is not None:
parts.append(str(block))Added Thanks for the fix, this is a clean approach. Hoisting in-array system messages into the top level |
Summary
Fixes #6001
Newer Claude Code versions can send system instructions as
role: "system"entries inside themessagesarray when calling/v1/messages. The Anthropic Messages schema only allowsuserandassistantroles inmessages, so Studio rejected those requests with a 422 before the route could translate them.This PR normalizes misplaced system-role messages during request validation by moving their content into the top-level Anthropic
systemfield.Before:

After:

Testing