fix: translate "developer" role to "system" for chat template compatibility#20079
Closed
marksverdhei wants to merge 1 commit intoggml-org:masterfrom
Closed
fix: translate "developer" role to "system" for chat template compatibility#20079marksverdhei wants to merge 1 commit intoggml-org:masterfrom
marksverdhei wants to merge 1 commit intoggml-org:masterfrom
Conversation
…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>
This was referenced Mar 24, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
"developer"as an alias for"system", but llama.cpp passed this role through verbatim to Jinja chat templatesraise_exception('Unexpected message role.'), while permissive templates silently lost the system promptdeveloper→systemremapping in three places:common_chat_msgs_parse_oaicompat(), the chat completions message loop, and the Responses API conversion layerinstructions-derived system message to prevent duplicate system messages that trigger "System message must be at the beginning" template errorsTest plan
POST /v1/chat/completionswithrole: "developer"+ tools returns 200 (was 500)POST /v1/responseswithinstructions+developerrole input + tools returns 200 (was 500)wire_api = "responses") works end-to-end with Qwen3.5🤖 Generated with Claude Code