Skip to content

Chat endpoint prematurely terminates when output contains "<im_end>" / ChatML special tokens (string-level stop matching) #1509

Description

@qoli
Image

Which version of LM Studio?
LM Studio 0.4.2+2 (0.4.2+2)

Which operating system?
macOS (Apple Silicon, M‑series)

What is the bug?
LM Studio’s built-in OpenAI-compatible chat server prematurely terminates generation when the output contains ChatML/Qwen special tokens such as:

"stop": [
  "<|im_end|>",
  "<im_end>",
  "</s>"
]

這些符號是什麼呢?

These tokens are treated as stop sequences even when they appear as normal text content. Generation is truncated and the UI shows:
"Stop reason: found EOS Token"

This makes it impossible to quote documentation, explain templates, or process text that contains these tokens.

Screenshots:
(attach screenshot showing “Stop reason: found EOS Token”)

Logs:
UI displays: Stop reason: found EOS Token
No crash or client disconnect. The server intentionally stops generation.

To Reproduce:

  1. Start LM Studio
  2. Load a Qwen / Qwen-Coder model (e.g. qwen3-coder-next)
  3. Use the built-in chat
  4. Send: Explain what <im_end> means in Qwen template.
  5. Generation immediately stops or returns partial output

Expected behavior:
The model should treat "<im_end>" as plain text and continue generating normally.

Actual behavior:
Generation stops whenever the string appears.

Additional technical details:
LM Studio appears to automatically inject stop sequences like:
"stop": ["<|im_end|>", "<im_end>", ""]

This suggests string-level matching instead of tokenizer-level EOS detection, causing false positives.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions