FoolDev Claude Opus 4.7 commited on
Commit
c61756c
·
1 Parent(s): 6672746

smoke_test: assert no chat-template tokens leak into response

Browse files

Before this, the round-trip check passed on any non-empty response.
The EOS-bleed bug fixed in 6672746 produced output like:
OK<|endoftext|><|im_start|>user
reply with the single word: OK
and the smoke test happily reported success. Now we grep the response
for <|im_start|>, <|im_end|>, <|endoftext|> and fail hard if any leak.

Verified: the fixed Modelfile still passes; the bad response shape
still fails (synthetic test against the same logic).

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>

Files changed (2) hide show
  1. CHANGELOG.md +7 -0
  2. scripts/smoke_test.sh +20 -0
CHANGELOG.md CHANGED
@@ -14,6 +14,13 @@ and documentation**, not the underlying base model.
14
  `<|endoftext|>` it kept generating past it and synthesised a fake new
15
  user turn. Reproducible via `make smoke` before/after.
16
 
 
 
 
 
 
 
 
17
  ### Removed
18
  - `Modelfile.z13` and the `z13` build profile. The Z13-specific tuning
19
  (Q3_K_S + 8K ctx + FA + q8_0 KV cache) wasn't meaningfully different
 
14
  `<|endoftext|>` it kept generating past it and synthesised a fake new
15
  user turn. Reproducible via `make smoke` before/after.
16
 
17
+ ### Added
18
+ - `scripts/smoke_test.sh`: token-leakage guard. The previous round-trip
19
+ check passed on any non-empty response — including the broken EOS-bleed
20
+ output that motivated the stop-token fix above. The smoke test now
21
+ fails hard if `<|im_start|>`, `<|im_end|>`, or `<|endoftext|>` appear
22
+ verbatim in the response.
23
+
24
  ### Removed
25
  - `Modelfile.z13` and the `z13` build profile. The Z13-specific tuning
26
  (Q3_K_S + 8K ctx + FA + q8_0 KV cache) wasn't meaningfully different
scripts/smoke_test.sh CHANGED
@@ -61,6 +61,26 @@ if [[ -z "${RESP}" ]]; then
61
  exit 1
62
  fi
63
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
64
  green "[+] round-trip OK"
65
  echo "----- model said -----"
66
  echo "${RESP}"
 
61
  exit 1
62
  fi
63
 
64
+ # Token-leakage guard: if any of the chat-template control tokens show up
65
+ # verbatim in the response, the Modelfile stop-token list is broken and
66
+ # the model is bleeding past EOS. We caught this in a real regression
67
+ # (commit 6672746) — the model said OK then emitted "<|endoftext|>
68
+ # <|im_start|>user ..." and Ollama kept generating.
69
+ LEAKED=()
70
+ for tok in '<|im_start|>' '<|im_end|>' '<|endoftext|>'; do
71
+ if grep -qF -- "${tok}" <<<"${RESP}"; then
72
+ LEAKED+=("${tok}")
73
+ fi
74
+ done
75
+ if (( ${#LEAKED[@]} )); then
76
+ red "[!] response contains raw control tokens: ${LEAKED[*]}"
77
+ red " Modelfile likely missing PARAMETER stop directives."
78
+ echo "----- model said -----"
79
+ echo "${RESP}"
80
+ echo "----------------------"
81
+ exit 1
82
+ fi
83
+
84
  green "[+] round-trip OK"
85
  echo "----- model said -----"
86
  echo "${RESP}"