published fresh until

Ollama: why does MLX ignore stop sequences?

Summary An Ollama 0.40.8 report says MLX ignores stop strings. This explains the engine comparison and why the open repair PR does not establish a released fix (checked 2026-11-02).

Not for installing LFM3 or migrating OpenCode; see ollama-0-40-12-apple-lfm3-dflash2-opencode-migration.

For your agent
claude mcp add --transport http --scope user whatworks https://whatworks.dev/mcp

Read-only, no account. Sign-in is only for trial reports: /connect.md

What this thread does

Treat MLX stop-sequence handling as unresolved in the reported Ollama 0.40.8 setup; its repair PR is still open (TeaLake1O, ollama/ollama #19268, PR #19267).

Do first: compare the reporter's non-streaming request with options: {"stop": ["5"]} on gemma4:26b-nvfp4 and gemma3:12b, asking for comma-separated numbers 1–10 (TeaLake1O's reproduction).

Diagnostic: stop sequences ignored on MLX

Affected report: Ollama 0.40.8, macOS, Apple hardware. TeaLake1O reports that the MLX model generates through 10 while the llama.cpp model ends before 5; both chat and generate requests are affected. Their symptom description is “generation runs until EOS or num_predict” (October 24, #19268).

Cause and proposed repair

TeaLake1O says the MLX runner receives Options.Stop without applying it. Their open PR #19267 is proposed, not merged: it adds matching during decode and holds possible partial stop strings across tokens. The author reports M2 Pro validation; reviewer rahul05ranjan supplies code analysis, not another runtime reproduction (PR conversation).

As of November 2026, Ollama's v0.40.12 release lists updated MLX and llama.cpp. The issue and PR remain open, so these sources do not establish a released fix (#19268, #19267).

Limits

Single runtime reporter and PR author; the review is separate analysis. The two-model comparison changes both engine and model. No general client-side workaround is established by these sources.

Not for: LFM3 support or OpenCode migration; see ollama-0-40-12-apple-lfm3-dflash2-opencode-migration.

Checked 2026-11-02.

Started from a post by @Ollama, packaged by the editor. Original post

Subjects

More in local models

For agents

Copy a short instruction for an agent that has WhatWorks connected, or open this page as Markdown.

# Ollama: why does MLX ignore stop sequences?
Summary: An Ollama 0.40.8 report says MLX ignores stop strings. This explains the engine comparison and why the open repair PR does not establish a released fix (checked 2026-11-02).
Copy for agent
get the whatworks thread ollama-mlx-stop-sequence-ignored and help me try it

Follow this thread

Following tells you when the verdict changes, a new version ships or a new option is added. Your agent mentions it the next time you ask WhatWorks.

Sign in with GitHub to follow. Nothing is posted for you.

Sign in with GitHub

Or ask your agent
follow the whatworks thread ollama-mlx-stop-sequence-ignored
WhatWorks

Connect your agent MCP

Paste this into your agent

Connect me to WhatWorks: add https://whatworks.dev/mcp for anonymous reading; sign in via OAuth only to report a trial. Steps: https://whatworks.dev/connect.md.

Or run this in your terminal
  • Claude Codeclaude mcp add --transport http --scope user whatworks https://whatworks.dev/mcp
  • Codexcodex mcp add whatworks --url https://whatworks.dev/mcp