[GH-ISSUE #1168] Client-supplied stop sequences are ignored (OpenAI stop and Anthropic stop_sequences) — blocks agent/harness use #487

Closed
opened 2026-11-04 01:43:27 +07:00 by bsakaguchi · 2 comments
Owner

Originally created by @saadharis on GitHub (Oct 6, 2026).
Original GitHub issue: https://github.com/Niko1221/Strata/issues/1168

Summary

Strata ignores client-supplied stop sequences — both the OpenAI stop parameter on /v1/chat/completions and Anthropic stop_sequences on /v1/messages. Generation only ends on the model's EOS token ids, so any client relying on a stop string receives untruncated output.

Environment

  • Engine: Strata v0.1.39, source build on Linux (CUDA 12.6, sm_86)
  • Model: alesha-pro/Qwen3.8-Flash-Next-abliterated-GSQ-RCO-Strata-GGUF → IQ3_XXS (75.8 GB)
  • Hardware: 2× RTX 3090 (48 GB VRAM), 62 GB RAM — layer split CUDA0 layers 0-22 / CUDA1 layers 23-47
  • Context: 262144; endpoints exercised: /v1/chat/completions, /v1/messages

Reproduction

1. OpenAI stop is ignored

curl -s http://127.0.0.1:8080/v1/chat/completions -H 'Content-Type: application/json' -d '{
  "model": "strata",
  "messages": [{"role":"user","content":"List three colors, one per line."}],
  "max_tokens": 60, "temperature": 0, "reasoning_effort": "none",
  "stop": ["\n"]
}'

Expected: generation halts at the first newline → a single line.
Actual: Red\nBlue\nGreen — a full three-line answer, byte-identical to the same request with stop omitted entirely.

2. The stop word is generated rather than honoured

Same request with "stop": ["STOP"] → the literal text STOP appears in content, i.e. it was emitted as ordinary output.

3. Anthropic stop_sequences is ignored too

curl -s http://127.0.0.1:8080/v1/messages -H 'Content-Type: application/json' -d '{
  "model": "strata", "max_tokens": 60,
  "messages": [{"role":"user","content":"List three colors, one per line."}],
  "stop_sequences": ["\n"]
}'

Actual: the same three-line answer, and the response reports "stop_sequence": null.

4. There is no hidden switch for it

  • No request-level stop read of any spelling in serve/ (checked stop, stop_sequences, .get("stop"), ["stop"])
  • stop_tokens in the source is repeat_stop_tokens — a repetition loop-breaker, not a user-facing stop
  • No engine --stop* flag in --help, and no config key for it

Impact

Clients that depend on stop sequences receive text they did not ask for:

  • lm-evaluation-harness humaneval scores 0.000 on this engine. The task sends stop: ["\ndef", "\nclass", "\nif", "\nprint", ...]. With the stop ignored, the model emits correct code and then repeats the prompt inside a markdown fence, which the completion extractor cannot parse. The same engine, same endpoint, same effort scores 0.874 on MMLU stem, so this is not a capability limit.
  • Code-completion clients, agent frameworks doing tool-call post-processing, and any harness that trims on a sentinel misbehave in the same way.

Suggested fix

Truncate the generation stream on the first match of any supplied stop string (check the full detokenized buffer, not only token boundaries), end generation, and report finish_reason: "stop". Wire stop on /v1/chat/completions and map Anthropic stop_sequences onto the same path, surfacing the matched string in the Anthropic response's stop_sequence field.

Everything else has been excellent

For context, since this is the only blocker I've hit: ~99% of routed expert mass resident in VRAM on 2×3090, 105 tok/s decode and 2,383 tok/s prefill at 228K prompt tokens, needle retrieval 3/3 at 10/50/90% depth out to 512K context, and the mmproj vision tower verified end-to-end (3/3 on a synthetic ground-truth image). The Anthropic + Responses API surface on top is a real differentiator. Happy to test a build with this fix.

Originally created by @saadharis on GitHub (Oct 6, 2026). Original GitHub issue: https://github.com/Niko1221/Strata/issues/1168 ## Summary Strata ignores client-supplied **stop sequences** — both the OpenAI `stop` parameter on `/v1/chat/completions` and Anthropic `stop_sequences` on `/v1/messages`. Generation only ends on the model's EOS token ids, so any client relying on a stop string receives untruncated output. ## Environment - Engine: **Strata v0.1.39**, source build on Linux (CUDA 12.6, sm_86) - Model: `alesha-pro/Qwen3.8-Flash-Next-abliterated-GSQ-RCO-Strata-GGUF` → **IQ3_XXS** (75.8 GB) - Hardware: 2× RTX 3090 (48 GB VRAM), 62 GB RAM — layer split CUDA0 layers 0-22 / CUDA1 layers 23-47 - Context: `262144`; endpoints exercised: `/v1/chat/completions`, `/v1/messages` ## Reproduction **1. OpenAI `stop` is ignored** ```bash curl -s http://127.0.0.1:8080/v1/chat/completions -H 'Content-Type: application/json' -d '{ "model": "strata", "messages": [{"role":"user","content":"List three colors, one per line."}], "max_tokens": 60, "temperature": 0, "reasoning_effort": "none", "stop": ["\n"] }' ``` Expected: generation halts at the first newline → a single line. Actual: `Red\nBlue\nGreen` — a full three-line answer, **byte-identical to the same request with `stop` omitted entirely**. **2. The stop word is generated rather than honoured** Same request with `"stop": ["STOP"]` → the literal text `STOP` appears in `content`, i.e. it was emitted as ordinary output. **3. Anthropic `stop_sequences` is ignored too** ```bash curl -s http://127.0.0.1:8080/v1/messages -H 'Content-Type: application/json' -d '{ "model": "strata", "max_tokens": 60, "messages": [{"role":"user","content":"List three colors, one per line."}], "stop_sequences": ["\n"] }' ``` Actual: the same three-line answer, and the response reports `"stop_sequence": null`. **4. There is no hidden switch for it** - No request-level stop read of any spelling in `serve/` (checked `stop`, `stop_sequences`, `.get("stop")`, `["stop"]`) - `stop_tokens` in the source is `repeat_stop_tokens` — a repetition **loop-breaker**, not a user-facing stop - No engine `--stop*` flag in `--help`, and no config key for it ## Impact Clients that depend on stop sequences receive text they did not ask for: - **lm-evaluation-harness `humaneval` scores 0.000** on this engine. The task sends `stop: ["\ndef", "\nclass", "\nif", "\nprint", ...]`. With the stop ignored, the model emits correct code and then **repeats the prompt inside a markdown fence**, which the completion extractor cannot parse. The same engine, same endpoint, same effort scores **0.874 on MMLU stem**, so this is not a capability limit. - Code-completion clients, agent frameworks doing tool-call post-processing, and any harness that trims on a sentinel misbehave in the same way. ## Suggested fix Truncate the generation stream on the first match of any supplied stop string (check the full detokenized buffer, not only token boundaries), end generation, and report `finish_reason: "stop"`. Wire `stop` on `/v1/chat/completions` and map Anthropic `stop_sequences` onto the same path, surfacing the matched string in the Anthropic response's `stop_sequence` field. ## Everything else has been excellent For context, since this is the only blocker I've hit: ~99% of routed expert mass resident in VRAM on 2×3090, **105 tok/s decode and 2,383 tok/s prefill at 228K prompt tokens**, needle retrieval **3/3 at 10/50/90% depth out to 512K context**, and the mmproj vision tower verified end-to-end (3/3 on a synthetic ground-truth image). The Anthropic + Responses API surface on top is a real differentiator. Happy to test a build with this fix.
Author
Owner

@BGonnermann commented on GitHub (Oct 6, 2026):

This looks fixed since v0.1.40 (the report is against v0.1.39).

Commit e7c2edb ("serve: honor stop and stop_sequences, cut the answer before the stop string and stop the engine there") is in the v0.1.40 and v0.1.40.1 tags. On current main, stop_strings() in serve/server.py reads OpenAI's stop (a string or a list) and Anthropic's stop_sequences, the answer is cut before the first match, and the Anthropic response reports stop_reason: "stop_sequence" with the matched string in stop_sequence. serve/test_server.py has tests for both APIs, streamed and not.

I checked this by reading the source and its tests, not by running a model. @saadharis, could you rerun your three curl requests and the humaneval task on 0.1.40 and say whether it holds?

<!-- gh-comment-id:6022547510 --> @BGonnermann commented on GitHub (Oct 6, 2026): This looks fixed since v0.1.40 (the report is against v0.1.39). Commit e7c2edb ("serve: honor stop and stop_sequences, cut the answer before the stop string and stop the engine there") is in the `v0.1.40` and `v0.1.40.1` tags. On current `main`, `stop_strings()` in `serve/server.py` reads OpenAI's `stop` (a string or a list) and Anthropic's `stop_sequences`, the answer is cut before the first match, and the Anthropic response reports `stop_reason: "stop_sequence"` with the matched string in `stop_sequence`. `serve/test_server.py` has tests for both APIs, streamed and not. I checked this by reading the source and its tests, not by running a model. @saadharis, could you rerun your three curl requests and the `humaneval` task on 0.1.40 and say whether it holds?
Author
Owner

@saadharis commented on GitHub (Oct 6, 2026):

Thanks @BGonnermann — confirmed on v0.1.40.1, built from source on Linux (CUDA 12.6, sm_86; IQ3_XXS GSQ-RCO on 2×RTX 3090, max_context 262144). Your read of the source holds on a live model run.

The three repros, re-run on 0.1.40.1 (vs 0.1.39 in the original report):

Request 0.1.39 0.1.40.1
OpenAI stop: ["\n"] 'Red\nBlue\nGreen' (byte-identical to no stop) 'Red' — 0 newlines, finish_reason: "stop"
OpenAI stop: ["5"] on "count 1..10" '1 2 3 4 5 6 7 8 9 10' '1 2 3 4 ' — 5 absent, finish_reason: "stop"
Anthropic /v1/messages stop_sequences: ["\n"] ignored, stop_sequence: null stop_reason: "stop_sequence", stop_sequence: "\n"

So including the Anthropic stop_reason/stop_sequence reporting you described. Tool calls (finish_reason: "tool_calls" with correct arguments) and the mmproj vision path both still pass after the upgrade — no regression.

Now the part where I have to correct my own report. You asked specifically about humaneval, and I have to say it does not improve — but the cause is not the stop gap, and my original attribution was wrong. I re-ran it (164 items) and pulled the raw samples:

raw response : "```python\nfrom typing import List\n\n"     <-- generation ends here
task's until : ['\nclass', '\ndef', '\n#', '\nif', '\nprint']

humaneval in lm-evaluation-harness is a code-completion task: the prompt already ends with the def ... line and docstring, and the model is expected to emit only the function body. Driven through a chat endpoint with --apply_chat_template, the model re-emits the whole definition from from typing import List — and the now-correct \ndef stop cuts generation at that exact moment, so no body is ever produced and every test fails. The stop you fixed is working exactly as specified; it is simply firing on a prompt shape this harness wasn't built for.

Previously (0.1.39) it also scored 0.000, but for a completely different reason — the ignored stop let the output run on and the extractor got the re-emitted prompt inside a fence. Both are the chat-vs-completion mismatch; the missing stop was a symptom I mis-attributed as the cause. Please treat the "humaneval 0.0" line in my original report as withdrawn — it is not evidence about stop and not an engine defect.

Two smaller notes from the run, in case they're useful:

  • 7 of 164 humaneval items came back with null content (API returned null content in the harness) — with max_gen_toks=1024 the whole budget went to reasoning. A harness budget matter, not an engine one.
  • No MMLU regression observed: MMLU-stem scored 0.684 on 0.1.40.1 at 5 samples/subject (a smaller sample than the 0.874 figure I had at 15/subject, so not a like-for-like comparison, just a sanity check that nothing collapsed).

Thanks for the fast turnaround on this and for reading it out of the source + tests — that pointed at exactly the right place, and stop_strings() / StopMatcher behaved as you described on the first live run.

<!-- gh-comment-id:6023754504 --> @saadharis commented on GitHub (Oct 6, 2026): Thanks @BGonnermann — confirmed on **v0.1.40.1, built from source on Linux** (CUDA 12.6, sm_86; IQ3_XXS GSQ-RCO on 2×RTX 3090, `max_context 262144`). Your read of the source holds on a live model run. **The three repros, re-run on 0.1.40.1 (vs 0.1.39 in the original report):** | Request | 0.1.39 | **0.1.40.1** | |---|---|---| | OpenAI `stop: ["\n"]` | `'Red\nBlue\nGreen'` (byte-identical to no stop) | **`'Red'`** — 0 newlines, `finish_reason: "stop"` | | OpenAI `stop: ["5"]` on "count 1..10" | `'1 2 3 4 5 6 7 8 9 10'` | **`'1 2 3 4 '`** — `5` absent, `finish_reason: "stop"` | | Anthropic `/v1/messages` `stop_sequences: ["\n"]` | ignored, `stop_sequence: null` | **`stop_reason: "stop_sequence"`, `stop_sequence: "\n"`** | So including the Anthropic `stop_reason`/`stop_sequence` reporting you described. Tool calls (`finish_reason: "tool_calls"` with correct `arguments`) and the mmproj vision path both still pass after the upgrade — no regression. **Now the part where I have to correct my own report.** You asked specifically about `humaneval`, and I have to say it does **not** improve — but the cause is **not** the stop gap, and my original attribution was wrong. I re-ran it (164 items) and pulled the raw samples: ``` raw response : "```python\nfrom typing import List\n\n" <-- generation ends here task's until : ['\nclass', '\ndef', '\n#', '\nif', '\nprint'] ``` `humaneval` in lm-evaluation-harness is a **code-completion** task: the prompt already ends with the `def ...` line and docstring, and the model is expected to emit only the function **body**. Driven through a chat endpoint with `--apply_chat_template`, the model re-emits the whole definition from `from typing import List` — and the now-correct `\ndef` stop cuts generation **at that exact moment**, so no body is ever produced and every test fails. The stop you fixed is working *exactly* as specified; it is simply firing on a prompt shape this harness wasn't built for. Previously (0.1.39) it also scored 0.000, but for a completely different reason — the ignored stop let the output run on and the extractor got the re-emitted prompt inside a fence. Both are the chat-vs-completion mismatch; the missing `stop` was a symptom I mis-attributed as the cause. Please treat the "humaneval 0.0" line in my original report as **withdrawn** — it is not evidence about `stop` and not an engine defect. Two smaller notes from the run, in case they're useful: - **7 of 164** humaneval items came back with null `content` (`API returned null content` in the harness) — with `max_gen_toks=1024` the whole budget went to reasoning. A harness budget matter, not an engine one. - No MMLU regression observed: MMLU-stem scored 0.684 on 0.1.40.1 at 5 samples/subject (a smaller sample than the 0.874 figure I had at 15/subject, so not a like-for-like comparison, just a sanity check that nothing collapsed). Thanks for the fast turnaround on this and for reading it out of the source + tests — that pointed at exactly the right place, and `stop_strings()` / `StopMatcher` behaved as you described on the first live run.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
Niko1221/Strata#487
No description provided.