EOS means end of sequence. The grammar and the engine can disagree about which token IDs end the output. A grammar-constrained decoder masks next-token IDs so the visible output can still satisfy its grammar. The serving engine also has stop-token IDs that terminate generation. If the engine recognizes an end token the grammar backend was never told about, the backend may treat that ID as ordinary allowed vocabulary while the engine treats it as stop. Generation ends before the closing quote and braces. A reported vLLM xgrammar integration reproduction shows exactly this contract mismatch. It is an issue report and reproduction, not proof that every backend or current release has the bug.

I would first capture the raw generated token IDs, the stop reason, grammar mask at the last step, model generation config and tokenizer's special tokens. Did generation hit an EOS token, a configured stop string, a length limit, or a transport cancellation? Those failure modes need different fixes. If it is the extra EOS case, enumerate all token IDs the engine can use to stop, pass that same set to the grammar backend, and allow those IDs only when the parser is in an accepting state. Also verify that padding or tool-control special tokens cannot slip through the grammar path. vLLM's structured-output documentation describes the public JSON and grammar modes, while the exact stop-token wiring is an implementation detail.

The regression test should put generation inside an open JSON string, make each possible stop ID highly likely in turn, and assert that it is masked until the document is complete. Then check legitimate termination immediately after a complete document, plus max-token exhaustion and client cancellation. A JSON parser at the response boundary should still reject incomplete output. Retrying may help a transient length cut, but it does not repair a mismatch between the grammar and the engine. The tokenizer, parser state and engine stop rules must agree on the same token stream.

The model’s tokenizer, generation configuration and request-level controls can contribute different termination rules. In the hypothetical case, A and B are labels for token IDs, not literal JSON characters. The causal claim is established only if the trace shows B was eligible in the current grammar mask, selected by the sampler and recognized as terminal by the engine before the parser reached a complete document.

The cited issue was reported in August 2026 and describes a TokenizerInfo construction path deriving one stop ID unless an explicit stop-token set is passed. Treat that report as evidence about the described integration, rather than a tested statement about an unspecified current package. Record engine version or commit, xgrammar version, tokenizer revision, generation configuration and request overrides when reproducing it. This repository does not include that GPU runtime, so the proposed regression is a test design rather than a claim that it was executed here.

At an open-string parser state, the test should enumerate the effective engine EOS IDs and check their grammar-mask bits. Then finish the smallest valid JSON document and check that legitimate termination becomes possible under the backend’s completion convention. Keep request stop strings and maximum length separate: either can intentionally truncate an unfinished document even if EOS masking is correct. A shared EOS set cannot make arbitrary cancellation or an exhausted token budget structurally valid.

At the response boundary, inspect both the finish reason and the parsed payload. Retry only under a bounded policy that distinguishes incomplete generation from a persistent configuration mismatch. If the output feeds a tool, validation must finish before the tool receives it. Grammar conformance establishes syntax under a specific decoding contract. It does not authorize an action or prove the JSON fields are semantically correct.