mirror of
https://github.com/Niko1221/Strata.git
synced 2026-12-03 19:03:30 +07:00
[GH-ISSUE #1168] Client-supplied stop sequences are ignored (OpenAI stop and Anthropic stop_sequences) — blocks agent/harness use #487
Labels
No labels
needs-format
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
Niko1221/Strata#487
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
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
stopparameter on/v1/chat/completionsand Anthropicstop_sequenceson/v1/messages. Generation only ends on the model's EOS token ids, so any client relying on a stop string receives untruncated output.Environment
alesha-pro/Qwen3.8-Flash-Next-abliterated-GSQ-RCO-Strata-GGUF→ IQ3_XXS (75.8 GB)262144; endpoints exercised:/v1/chat/completions,/v1/messagesReproduction
1. OpenAI
stopis ignoredExpected: generation halts at the first newline → a single line.
Actual:
Red\nBlue\nGreen— a full three-line answer, byte-identical to the same request withstopomitted entirely.2. The stop word is generated rather than honoured
Same request with
"stop": ["STOP"]→ the literal textSTOPappears incontent, i.e. it was emitted as ordinary output.3. Anthropic
stop_sequencesis ignored tooActual: the same three-line answer, and the response reports
"stop_sequence": null.4. There is no hidden switch for it
serve/(checkedstop,stop_sequences,.get("stop"),["stop"])stop_tokensin the source isrepeat_stop_tokens— a repetition loop-breaker, not a user-facing stop--stop*flag in--help, and no config key for itImpact
Clients that depend on stop sequences receive text they did not ask for:
humanevalscores 0.000 on this engine. The task sendsstop: ["\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.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". Wirestopon/v1/chat/completionsand map Anthropicstop_sequencesonto the same path, surfacing the matched string in the Anthropic response'sstop_sequencefield.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.
@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 thev0.1.40andv0.1.40.1tags. On currentmain,stop_strings()inserve/server.pyreads OpenAI'sstop(a string or a list) and Anthropic'sstop_sequences, the answer is cut before the first match, and the Anthropic response reportsstop_reason: "stop_sequence"with the matched string instop_sequence.serve/test_server.pyhas 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
humanevaltask on 0.1.40 and say whether it holds?@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):
stop: ["\n"]'Red\nBlue\nGreen'(byte-identical to no stop)'Red'— 0 newlines,finish_reason: "stop"stop: ["5"]on "count 1..10"'1 2 3 4 5 6 7 8 9 10''1 2 3 4 '—5absent,finish_reason: "stop"/v1/messagesstop_sequences: ["\n"]stop_sequence: nullstop_reason: "stop_sequence",stop_sequence: "\n"So including the Anthropic
stop_reason/stop_sequencereporting you described. Tool calls (finish_reason: "tool_calls"with correctarguments) 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:humanevalin lm-evaluation-harness is a code-completion task: the prompt already ends with thedef ...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 fromfrom typing import List— and the now-correct\ndefstop 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
stopwas 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 aboutstopand not an engine defect.Two smaller notes from the run, in case they're useful:
content(API returned null contentin the harness) — withmax_gen_toks=1024the whole budget went to reasoning. A harness budget matter, not an engine one.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()/StopMatcherbehaved as you described on the first live run.