Skip to content

fix: translate "developer" role to "system" for chat template compatibility#20079

Closed
marksverdhei wants to merge 1 commit intoggml-org:masterfrom
marksverdhei:fix/developer-role-to-system
Closed

fix: translate "developer" role to "system" for chat template compatibility#20079
marksverdhei wants to merge 1 commit intoggml-org:masterfrom
marksverdhei:fix/developer-role-to-system

Conversation

@marksverdhei
Copy link
Copy Markdown

Summary

  • OpenAI's Responses API uses "developer" as an alias for "system", but llama.cpp passed this role through verbatim to Jinja chat templates
  • Templates that validate roles strictly (e.g. Qwen3.5 MoE) crashed with raise_exception('Unexpected message role.'), while permissive templates silently lost the system prompt
  • Adds developersystem remapping in three places: common_chat_msgs_parse_oaicompat(), the chat completions message loop, and the Responses API conversion layer
  • The Responses API fix also merges developer/system messages with the instructions-derived system message to prevent duplicate system messages that trigger "System message must be at the beginning" template errors

Test plan

  • Verified with Qwen3.5-35B-A3B-UD GGUF — POST /v1/chat/completions with role: "developer" + tools returns 200 (was 500)
  • Verified POST /v1/responses with instructions + developer role input + tools returns 200 (was 500)
  • Verified Codex CLI v0.107.0 (wire_api = "responses") works end-to-end with Qwen3.5
  • Run existing server tests to confirm no regressions

🤖 Generated with Claude Code

…bility

OpenAI's Responses API uses "developer" as an alias for "system", but
llama.cpp passed this role through verbatim to Jinja chat templates.
Templates that validate roles strictly (e.g. Qwen3.5 MoE) crashed with
"Unexpected message role", while permissive templates silently lost the
system prompt.

Changes:
- common/chat.cpp: remap developer→system in common_chat_msgs_parse_oaicompat()
- server-common.cpp (chat completions): remap on raw JSON messages before
  template parsing
- server-common.cpp (responses API): remap developer→system and merge with
  any existing system message from the "instructions" field to avoid
  duplicate system messages that trigger "System message must be at the
  beginning" errors

Fixes Codex CLI + Qwen3.5-35B-A3B and any other model with strict
template role validation.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant