Skip to content

Support developer role for GPT-compatible Claude translations #4025

Description

@hudson-s

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions