You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Beginning of output truncated when --thinking #108
If I add the --thinking flag to this, then the client doesn't get the beginning <think> tag from the model.
For tool calls the client actually gets the right output at first, but then model doesn't see it in its history that it sent the first line or so, and then begins trying to omit the first line intentionally to match what it sees that it thinks worked.
Without thinking, tool calls succeed and the output looks correct in the client.
I doubt it's relevant, but I'm on a Mac Studio M2 Max 64gb (also --prefill-size 128 was too high and I was getting GPU timeouts).
sidenote: vllm-mlx has the same problem. I wonder if it's a config or usage issue of MLX. llama w/ metal and LM Studio (GGUF or MLX) don't have this problem.
So the model never emits an opening tag — it starts inside the block and only emits </think>. SwiftLM's parser assumed output always begins outside the block, so it filed all the reasoning as content with a stray </think> in it. Hence no <think> at the start, and a replayed assistant turn that begins mid-thought, which is what teaches the model to drop its own first line on the next round.
The fix detects the unclosed tag in the rendered prompt and starts the parser inside the thinking block, so reasoning goes to reasoning_content and content stays clean. Note this is detected per request rather than per model, since it varies by version — Qwen3-1.7B does not pre-open, Qwen3.6 does.
I also fixed a separate bug found alongside it: text held pending a partial tag was never flushed at end of stream, so a response ending in something resembling a tag start was dropped.
Verified end-to-end in both streaming and non-streaming mode, though on a smaller model with your template transplanted onto it rather than Qwen3.6-27B-OptiQ itself — a confirmation on your setup, especially the tool-call flow, would be welcome.
--thinking, non-streaming → reasoning lands in reasoning_content, content is "Tokyo", no leaked tags
--thinking, streaming → same split across 148 chunks
no --thinking (control) → the template emits an already-closed block, detection stays off, output unchanged
Worth noting for anyone hitting this on other models: the template can live in either tokenizer_config.json or a separate chat_template.jinja, and whether it pre-opens varies by version even within one family — Qwen3-1.7B does not, Qwen3.5-4B and Qwen3.6 do. That's why the fix inspects the rendered prompt per request instead of matching on model name.
Still worth a confirmation on Qwen3.6-27B-OptiQ-4bit with your tool-call flow, since that part I could not reproduce locally.
@coolaj86 — I reproduced your tool-call scenario end to end, and #115 fixes it. Two-round exchange (ask with a tool available, then replay the assistant turn plus the tool result), thinking enabled, two binaries differing only in Server.swift:
Before:
[round1] reasoning_content: None
[round1] content: 'The user is asking for the weather in Paris and wants me to use the tool. I have access to…'
[round1] tool_calls: ['get_weather({"city":"Paris"})']
[round1] LEAKED TAGS IN CONTENT: ['</think>']
[round2] LEAKED TAGS IN CONTENT: ['</think>']
After:
[round1] reasoning_content: 226 chars
[round1] content: None
[round1] tool_calls: ['get_weather({"city":"Paris"})']
[round2] content: 'The weather in Paris is currently 18°C with light rain.'
LEAKED TAGS: none
The tool call itself succeeds in both — matching your note that tool calls work while the surrounding text is wrong. What the client receives before the fix is the model's private reasoning as content with a stray </think> inside it, and that malformed turn is what gets replayed into history.
One thing I could not do, and where I could use your help. I downloaded mlx-community/Qwen3.6-27B-OptiQ-4bit specifically to test against your model, and it produces garbage on current main for me, with or without thinking:
The same binary is coherent on Qwen3.5-4B-4bit, so it is that model specifically. I filed it separately as #118 with the config analysis.
Since you clearly get sensible output from this model, something differs between our setups. If you have a moment:
Are you building from source, or running a release binary — and which version?
Does a plain non-streaming request without tools return coherent text for you?
Your answer would tell us whether #118 is a regression on main, something about my build, or specific to how the model is loaded from ~/.lmstudio/models/ versus the HF cache. The verification above was done on Qwen3.5-4B-4bit, whose chat template pre-opens <think> in the same form as your Qwen3.6 model — so the fix is validated on that shape, just not on your exact model yet.
Release b674 is out with this fix included (plus #118, which affected your OptiQ model specifically) — no need to build from source to verify. If the tool-call flow still misbehaves on your setup with b674, please reopen.
Activity
[-]Beginning truncated when --thinking[/-][+]Beginning of output truncated when --thinking[/+]solderzzc commentedon Aug 5, 2026
Reproduced and fixed in #115 — and your instinct that it isn't MLX-specific was right, which is also why vllm-mlx shows it.
It's the chat template. Qwen3.6 appends
<think>\nto the generation prompt when thinking is enabled:So the model never emits an opening tag — it starts inside the block and only emits
</think>. SwiftLM's parser assumed output always begins outside the block, so it filed all the reasoning ascontentwith a stray</think>in it. Hence no<think>at the start, and a replayed assistant turn that begins mid-thought, which is what teaches the model to drop its own first line on the next round.The fix detects the unclosed tag in the rendered prompt and starts the parser inside the thinking block, so reasoning goes to
reasoning_contentandcontentstays clean. Note this is detected per request rather than per model, since it varies by version — Qwen3-1.7B does not pre-open, Qwen3.6 does.I also fixed a separate bug found alongside it: text held pending a partial tag was never flushed at end of stream, so a response ending in something resembling a tag start was dropped.
Verified end-to-end in both streaming and non-streaming mode, though on a smaller model with your template transplanted onto it rather than Qwen3.6-27B-OptiQ itself — a confirmation on your setup, especially the tool-call flow, would be welcome.
solderzzc commentedon Aug 5, 2026
Follow-up: I've now verified this against a real, unmodified model rather than a transplanted template.
mlx-community/Qwen3.5-4B-4bitships the same pre-opening form as Qwen3.6, inchat_template.jinjarather thantokenizer_config.json:With #115, on that model:
--thinking, non-streaming → reasoning lands inreasoning_content,contentis"Tokyo", no leaked tags--thinking, streaming → same split across 148 chunks--thinking(control) → the template emits an already-closed block, detection stays off, output unchangedWorth noting for anyone hitting this on other models: the template can live in either
tokenizer_config.jsonor a separatechat_template.jinja, and whether it pre-opens varies by version even within one family — Qwen3-1.7B does not, Qwen3.5-4B and Qwen3.6 do. That's why the fix inspects the rendered prompt per request instead of matching on model name.Still worth a confirmation on Qwen3.6-27B-OptiQ-4bit with your tool-call flow, since that part I could not reproduce locally.
solderzzc commentedon Aug 6, 2026
@coolaj86 — I reproduced your tool-call scenario end to end, and #115 fixes it. Two-round exchange (ask with a tool available, then replay the assistant turn plus the tool result), thinking enabled, two binaries differing only in
Server.swift:Before:
After:
The tool call itself succeeds in both — matching your note that tool calls work while the surrounding text is wrong. What the client receives before the fix is the model's private reasoning as
contentwith a stray</think>inside it, and that malformed turn is what gets replayed into history.One thing I could not do, and where I could use your help. I downloaded
mlx-community/Qwen3.6-27B-OptiQ-4bitspecifically to test against your model, and it produces garbage on currentmainfor me, with or without thinking:The same binary is coherent on
Qwen3.5-4B-4bit, so it is that model specifically. I filed it separately as #118 with the config analysis.Since you clearly get sensible output from this model, something differs between our setups. If you have a moment:
Your answer would tell us whether #118 is a regression on
main, something about my build, or specific to how the model is loaded from~/.lmstudio/models/versus the HF cache. The verification above was done onQwen3.5-4B-4bit, whose chat template pre-opens<think>in the same form as your Qwen3.6 model — so the fix is validated on that shape, just not on your exact model yet.fix: parse reasoning when the chat template pre-opens <think> (#108) (#…
solderzzc commentedon Aug 7, 2026
Release b674 is out with this fix included (plus #118, which affected your OptiQ model specifically) — no need to build from source to verify. If the tool-call flow still misbehaves on your setup with b674, please reopen.
test: cover load-path defect shapes with synthetic checkpoints (#143)