Goal
Update the OpenAI Claude translator to use a top-level developer role for GPT-5, Codex, and o-series model names, while keeping system for other compatible models.
Rationale
Some newer GPT-compatible chat models reject top-level system messages and expect developer instructions instead. The Claude-to-OpenAI translator currently always emits system for Anthropic top-level system content, which can break those models. This change preserves generic compatibility by only switching known model families that expect developer.
Intended implementation
- Add
topLevelSystemRoleForOpenAI(modelName string) string.
- Normalize model names by trimming space, lowercasing, and stripping provider prefixes before matching.
- Return
developer for gpt, gpt-5*, codex*, o1*, o3*, and o4*.
- Return
system otherwise.
- Use the helper when constructing the top-level system/developer message.
- Add tests for matching model families and update affected conversion assertions.
func topLevelSystemRoleForOpenAI(modelName string) string {
model := strings.ToLower(strings.TrimSpace(modelName))
if slash := strings.LastIndex(model, /); slash >= 0 {
model = model[slash+1:]
}
if model == gpt ||
strings.HasPrefix(model, gpt-5) ||
strings.HasPrefix(model, codex) ||
strings.HasPrefix(model, o1) ||
strings.HasPrefix(model, o3) ||
strings.HasPrefix(model, o4) {
return developer
}
return system
}
Local verification status
Goal
Update the OpenAI Claude translator to use a top-level
developerrole for GPT-5, Codex, and o-series model names, while keepingsystemfor other compatible models.Rationale
Some newer GPT-compatible chat models reject top-level
systemmessages and expect developer instructions instead. The Claude-to-OpenAI translator currently always emitssystemfor Anthropic top-level system content, which can break those models. This change preserves generic compatibility by only switching known model families that expectdeveloper.Intended implementation
topLevelSystemRoleForOpenAI(modelName string) string.developerforgpt,gpt-5*,codex*,o1*,o3*, ando4*.systemotherwise.Local verification status