quant.cpp icon indicating copy to clipboard operation
quant.cpp copied to clipboard

System prompt (role: system) is ignored in /v1/chat/completions

Open unamedkr opened this issue 7 months ago • 1 comments

Description

The system role in the messages array is accepted without error but has no effect on the model's behavior.

Steps to Reproduce

curl http://localhost:8080/v1/chat/completions \
  -H "Content-Type: application/json" \
  -d '{
    "messages": [
      {"role": "system", "content": "You are a pirate. Always respond in pirate speak."},
      {"role": "user", "content": "What is gravity?"}
    ],
    "temperature": 0.0,
    "max_tokens": 60
  }'

Expected Behavior

Response should reflect the system prompt (e.g., pirate speak).

Actual Behavior

Response is identical to a request without the system prompt. The system message is silently ignored.

Impact

  • Severity: P1 — System prompts are essential for app developers to control model behavior
  • Breaks OpenAI API compatibility (system role is a core feature)
  • RAG, chatbot personas, and structured output all depend on system prompts

Suggested Fix

Include the system message in the chat template construction. For ChatML-style templates:

<|im_start|>system
{system_content}<|im_end|>
<|im_start|>user
{user_content}<|im_end|>
<|im_start|>assistant

Environment

  • quant.cpp: latest main
  • Model: SmolLM2-1.7B-Instruct-Q8_0.gguf

Reported by ClawTeam Claw-2 (Builder persona)

unamedkr avatar Apr 12 '26 02:04 unamedkr

Investigated: build_prompt() in tq_server.c correctly formats system role messages into ChatML (<|im_start|>system\n{content}<|im_end|>\n). The system prompt IS included in the prompt sent to the model. The observed behavior is a model limitation (SmolLM2-1.7B has weak system prompt adherence), not a code bug. Closing as not-a-bug.

unamedkr avatar Apr 12 '26 03:04 unamedkr