quant.cpp
quant.cpp copied to clipboard
Server crashes when assistant message contains "!" in multi-turn chat
Description
The server returns an empty response (connection reset) when a prior assistant message in the messages array contains an exclamation mark (!). This is 100% reproducible and blocks all realistic multi-turn conversations.
Steps to Reproduce
# This works (no ! in assistant message):
curl -s http://localhost:8080/v1/chat/completions \
-H "Content-Type: application/json" \
-d '{"messages":[
{"role":"user","content":"Hi"},
{"role":"assistant","content":"Hello there"},
{"role":"user","content":"How are you?"}
],"max_tokens":20,"temperature":0.0}'
# → Returns valid response
# This crashes (! in assistant message):
curl -s http://localhost:8080/v1/chat/completions \
-H "Content-Type: application/json" \
-d '{"messages":[
{"role":"user","content":"Hi"},
{"role":"assistant","content":"Hello!"},
{"role":"user","content":"How are you?"}
],"max_tokens":20,"temperature":0.0}'
# → Empty response / connection reset
Impact
- Severity: P0 — Every multi-turn chat will hit this since model responses routinely contain
! - Breaks OpenAI SDK compatibility for chat applications
- The first turn always works; the crash only occurs on turn 2+ when history includes
!
Root Cause Hypothesis
The ! character may be unescaped in the chat template string construction, causing buffer issues in the C server's build_prompt() or JSON parsing.
Environment
- Tested against Phi-3.5-mini server (quant.h-based Python wrapper)
- Also likely affects quant-server (C)
- macOS 15, Apple M3
Reported by ClawTeam Claw-2 (Builder persona) — Round 2 retest
Update: Not a server bug — shell escaping issue
Retested with Python urllib (bypassing shell):
# This works fine:
messages = [
{"role": "user", "content": "Hi"},
{"role": "assistant", "content": "Hello!"},
{"role": "user", "content": "How are you?"}
]
# → "I'm an artificial intelligence, so I don't have feelings."
The original report used curl -d '...' where ! in bash triggers history expansion. This is a test environment issue, not a server bug.
Recommend closing as "not a bug".