Skip to content

SWF(bug): stop empty stop sequences matching every output - #49

Merged
maplepaladin73 merged 1 commit into
mainfrom
devin/1795371427-empty-stop-sequence
Nov 22, 2026
Merged

maplepaladin73 merged 1 commit into
mainfrom
devin/1795371427-empty-stop-sequence

Conversation

@maplepaladin73

@maplepaladin73 maplepaladin73 commented Nov 22, 2026 •

Copy link
Copy Markdown
Owner

stop: [""] no longer matches every output: empty stop strings are ignored in both the final strip (inference_impl/tail.rs) and the streaming holdback (chat_stream/handle_token/tail.rs).

Summary

strip_stop_sequences_matched used strip_suffix(""), which always succeeds, so any request containing an empty stop reported a matched stop (finish_reason: "stop", Anthropic stop_sequence: "") even when the model never stopped. The streaming path had the same root cause: find("") returns Some(0), so the stream was cut to nothing on the first token. Both now skip empty strings before matching; non-empty stops in the same list still match as before.

Failing run (before the fix)

test api::chat_stream::handle_token::tail::empty_stop_tests::empty_stop_sequences_never_match ... FAILED
test api::inference_impl::tail::tests::empty_stop_sequences_never_match ... FAILED

---- api::chat_stream::handle_token::tail::empty_stop_tests::empty_stop_sequences_never_match stdout ----
assertion `left == right` failed: text="hello", stops=[""]
  left: ""
 right: "hello"

---- api::inference_impl::tail::tests::empty_stop_sequences_never_match stdout ----
assertion `left == right` failed: text="hello", stops=[""]
  left: ("hello", Some(""))
 right: ("hello", None)

test result: FAILED. 0 passed; 2 failed; 0 ignored; 0 measured; 3213 filtered out

Passing run (after the fix)

test api::chat_stream::handle_token::tail::empty_stop_tests::empty_stop_sequences_never_match ... ok
test api::inference_impl::tail::tests::empty_stop_sequences_never_match ... ok
test result: ok. 2 passed; 0 failed; 0 ignored; 0 measured; 3213 filtered out

Full spark binary suite: test result: ok. 3201 passed; 0 failed; 14 ignored (rebased on main after #51, no local workarounds).

Why this is the root cause

An empty string is a suffix and a substring of every string, so strip_suffix("") / find("") match unconditionally. Filtering empties at the two match sites is the minimal fix; the tests cover [""], empty text, ["", "STOP"] in both orders, overlapping stops, and no stops.

Try it

ATLAS_SKIP_BUILD=1 CUDARC_CUDA_VERSION=13000 cargo test -p spark-server --bin spark empty_stop_sequences_never_match

(Needs bash scripts/ci_gpu_stubs.sh on a GPU-less host.)

Test plan

  • ATLAS_SKIP_BUILD=1 CUDARC_CUDA_VERSION=13000 cargo clippy --workspace --tests — clean
  • bash scripts/check-license-headers.sh — valid: 4262, invalid: 0
  • typos — clean
  • cargo fmt --all -- --check — clean
  • Added regression tests

Untested

No live GPU/model run: the change is in pure string handling, exercised directly by the unit tests.

CLA


Software Factory opened this PR for Robert
Implemented in session Stop empty stop sequences matching every output
Review with Devin · Open in Devin Desktop


@devin-ai-integration

Copy link
Copy Markdown

I'll fix CI failures and address comments from users with write access. I'll skip comments containing "(aside)".

  • Disable automatic comment, CI, and merge conflict monitoring

@devin-ai-integration devin-ai-integration Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Devin Review: No Issues Found

Devin Review analyzed this PR and found no bugs or issues to report.

Devin Review

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
@devin-ai-integration
devin-ai-integration Bot force-pushed the devin/1795371427-empty-stop-sequence branch from 7266665 to d5dc780 Compare November 22, 2026 18:28
@maplepaladin73
maplepaladin73 merged commit 736f013 into main Nov 22, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant