fix(translator): handle system role as developer in Claude request conversion

- Updated `ConvertClaudeRequestToGemini` logic to treat `system` role as `developer`.
- Added unit test case to validate the behavior.

Closes: #3510
This commit is contained in:
Luis Pater
2026-05-22 12:04:27 +08:00
parent cecd39317d
commit 33f4904b25
2 changed files with 15 additions and 0 deletions

View File

@@ -87,6 +87,9 @@ func ConvertClaudeRequestToCodex(modelName string, inputRawJSON []byte, _ bool)
for i := 0; i < len(messageResults); i++ {
messageResult := messageResults[i]
messageRole := messageResult.Get("role").String()
if messageRole == "system" {
messageRole = "developer"
}
newMessage := func() []byte {
msg := []byte(`{"type":"message","role":"","content":[]}`)

View File

@@ -42,6 +42,18 @@ func TestConvertClaudeRequestToCodex_SystemMessageScenarios(t *testing.T) {
wantHasDeveloper: true,
wantTexts: []string{"Be helpful"},
},
{
name: "System role in messages",
inputJSON: `{
"model": "claude-3-opus",
"messages": [
{"role": "system", "content": "Follow the project instructions"},
{"role": "user", "content": "hello"}
]
}`,
wantHasDeveloper: true,
wantTexts: []string{"Follow the project instructions"},
},
{
name: "Array system field with filtered billing header",
inputJSON: `{