[GH-ISSUE #1178] serve: Special tokens (<|im_end|>) emitted during model thinking cause tasks to terminate early #491

Closed
opened 2026-11-04 01:43:28 +07:00 by bsakaguchi · 14 comments
Owner

Originally created by @TwoAnts on GitHub (Oct 6, 2026).
Original GitHub issue: https://github.com/Niko1221/Strata/issues/1178

Recently, I’ve been using a model (Qwen3.8 Flash Next IQ3_S) to fix Strata’s code related to special tokens. The model tends to output special tokens in its thinking, which causes the task to terminate immediately.

Strata may need to add some fallback handling to mitigate this issue.

Minimal test input:

Qwen 聊天模板里,助手回合的结束标记是什么?请原样写出,例如 "标记"。

Please check whether it terminates early and whether it can still produce output normally.

I can reproduce this locally multiple times: it either terminates during thinking, or fails to output the answer normally.

Originally created by @TwoAnts on GitHub (Oct 6, 2026). Original GitHub issue: https://github.com/Niko1221/Strata/issues/1178 Recently, I’ve been using a model (Qwen3.8 Flash Next IQ3_S) to fix Strata’s code related to special tokens. The model tends to output special tokens in its thinking, which causes the task to terminate immediately. Strata may need to add some fallback handling to mitigate this issue. Minimal test input: ``` Qwen 聊天模板里,助手回合的结束标记是什么?请原样写出,例如 "标记"。 ``` Please check whether it terminates early and whether it can still produce output normally. I can reproduce this locally multiple times: it either terminates during thinking, or fails to output the answer normally.
Author
Owner

@ladno64 commented on GitHub (Oct 6, 2026):

у меня такая же проблема.

<!-- gh-comment-id:6019027811 --> @ladno64 commented on GitHub (Oct 6, 2026): у меня такая же проблема.
Author
Owner

@TwoAnts commented on GitHub (Oct 6, 2026):

I made some small patches using DeepSeek: e5437d2

The main approach is to replace specific end tokens with their corresponding text and feed them back in to continue generation. This change can mitigate the issue, but it does not guarantee a complete fix. It may serve as a reference.

<!-- gh-comment-id:6019414550 --> @TwoAnts commented on GitHub (Oct 6, 2026): I made some small patches using DeepSeek: [e5437d2](https://github.com/TwoAnts/Strata/commit/e5437d20a828880f2d46b6eab475475d6015c3a6) The main approach is to replace specific end tokens with their corresponding text and feed them back in to continue generation. This change can mitigate the issue, but it does not guarantee a complete fix. It may serve as a reference.
Author
Owner

@ladno64 commented on GitHub (Oct 6, 2026):

у меня очередь команд на отправку в диалоге. пишу "1" и ллм понимает что надо продолжать работать.))

<!-- gh-comment-id:6019621510 --> @ladno64 commented on GitHub (Oct 6, 2026): у меня очередь команд на отправку в диалоге. пишу "1" и ллм понимает что надо продолжать работать.))
Author
Owner

@TwoAnts commented on GitHub (Oct 6, 2026):

I still hope it can be handled automatically. I feel that tools like llama.cpp have more complete handling for output, though that might be a big undertaking.

<!-- gh-comment-id:6019686122 --> @TwoAnts commented on GitHub (Oct 6, 2026): I still hope it can be handled automatically. I feel that tools like llama.cpp have more complete handling for output, though that might be a big undertaking.
Author
Owner

@ladno64 commented on GitHub (Oct 6, 2026):

Strata-main\serve\chat_template.jinja отправляйте его в крупную нейросеть вроде дипсика и пусть поищет ошибки.

<!-- gh-comment-id:6025976924 --> @ladno64 commented on GitHub (Oct 6, 2026): Strata-main\serve\chat_template.jinja отправляйте его в крупную нейросеть вроде дипсика и пусть поищет ошибки.
Author
Owner

@47Hunter47 commented on GitHub (Oct 12, 2026):

This is the shape #1814 describes and my PR #1840 targets: a turn that ends inside its thinking with no answer, so the client gets an empty reply with finish_reason: stop.

What I measured today on 0.1.43 (RTX 3090, IQ3_XXS, 250K context, --kv int8, guard on):

  • Asking the model to write its closing thinking tag: 4 runs, 2 ended inside the thinking (384 and 63 tokens), both were closed and continued so the client got an answer, totals.ended_inside_thinking = 2 in /metrics.
  • Asking it to write </tool_call> verbatim: 4 runs, 2 ended inside the thinking, one rescued by the continuation, one still empty after the cap of 2 continuations.

Your approach in e5437d2 (swap the ending token for its text and feed it back to continue) is the same idea as the continuation side of #1840. The differences: mine keeps the repair inside the same reply and caps it per reply so a model that keeps doing it cannot loop, and it reports the end even when the continuation is not enough, so the empty reply is at least identifiable. It is opt-in (literal_think_guard); with the flag off a server behaves as before.

The Chinese prompt in your report is a good third case for my corpus. If you run it against your build, the journal line the reply ended inside its thinking with no answer and totals.ended_inside_thinking in /metrics will show whether the dead end you hit is the same one, rather than a different early stop.

<!-- gh-comment-id:6121174765 --> @47Hunter47 commented on GitHub (Oct 12, 2026): This is the shape #1814 describes and my PR #1840 targets: a turn that ends inside its thinking with no answer, so the client gets an empty reply with `finish_reason: stop`. What I measured today on 0.1.43 (RTX 3090, IQ3_XXS, 250K context, `--kv int8`, guard on): - Asking the model to write its closing thinking tag: 4 runs, 2 ended inside the thinking (384 and 63 tokens), both were closed and continued so the client got an answer, `totals.ended_inside_thinking` = 2 in `/metrics`. - Asking it to write `</tool_call>` verbatim: 4 runs, 2 ended inside the thinking, one rescued by the continuation, one still empty after the cap of 2 continuations. Your approach in e5437d2 (swap the ending token for its text and feed it back to continue) is the same idea as the continuation side of #1840. The differences: mine keeps the repair inside the same reply and caps it per reply so a model that keeps doing it cannot loop, and it reports the end even when the continuation is not enough, so the empty reply is at least identifiable. It is opt-in (`literal_think_guard`); with the flag off a server behaves as before. The Chinese prompt in your report is a good third case for my corpus. If you run it against your build, the journal line `the reply ended inside its thinking with no answer` and `totals.ended_inside_thinking` in `/metrics` will show whether the dead end you hit is the same one, rather than a different early stop.
Author
Owner

@TwoAnts commented on GitHub (Oct 12, 2026):

Currently I mainly run into two situations:

  1. When the context contains <|im_end|>, the model may output an end token early during the thinking phase, causing the task to be interrupted abnormally. -> This severely affects usage in long conversations.

  2. When hindsight does reflection/consolidation, it requires the answer to be in JSON format, and Strata directly throws an error for answers that do not conform to JSON syntax. -> This causes the hindsight task to fail.

In fact, these are both shortcomings of the model. Of course, now that models are becoming more and more human-like, it is normal for them to occasionally make mistakes. They cannot be treated as precision machines.

My original intention with these workarounds was to make minor fixes as much as possible. Strata's serve layer is implemented in Python, so it can indeed be patched more flexibly.

Both of the above problems are currently solved by intercepting and retrying at the serve layer.

  1. For the premature-ending issue, I mainly special-case three patterns: `<|im_end|>`, the triple-backtick pattern ...<|im_end|>''', and <think>...<|im_end|></think>, replace them back with text, feed them back, and continue generation (with some retry caps, of course). Of course, for those in the main body, there is nothing I can do; the code still cannot make semantic-level distinctions (though adding a jev might help a bit, lol). But this has already greatly reduced the frequency and mitigated the problem. f99e638

  2. For the JSON format issue, I also added a small loop at the serve layer that points out the error and corrects it, and the problem is basically solved. f839590

However, I mostly had an agent help me with the implementation, so it is somewhat crude.

I think the overall direction of changes is to strengthen Strata's detection of unreasonable outputs at the serve layer, and to allow some iterative retry dialogue between the serve layer and the model before giving the final answer. (this could be an extensible and reasonably well-structured implementation)

This is very similar to how humans check before delivering work results.

<!-- gh-comment-id:6124679835 --> @TwoAnts commented on GitHub (Oct 12, 2026): Currently I mainly run into two situations: 1. When the context contains `<|im_end|>`, the model may output an end token early during the thinking phase, causing the task to be interrupted abnormally. -> This severely affects usage in long conversations. 2. When hindsight does reflection/consolidation, it requires the answer to be in JSON format, and Strata directly throws an error for answers that do not conform to JSON syntax. -> This causes the hindsight task to fail. In fact, these are both shortcomings of the model. Of course, now that models are becoming more and more human-like, it is normal for them to occasionally make mistakes. They cannot be treated as precision machines. My original intention with these workarounds was to make minor fixes as much as possible. Strata's serve layer is implemented in Python, so it can indeed be patched more flexibly. Both of the above problems are currently solved by intercepting and retrying at the serve layer. 1. For the premature-ending issue, I mainly special-case three patterns: \`<|im_end|>\`, the triple-backtick pattern `...<|im_end|>'''`, and `<think>...<|im_end|></think>`, replace them back with text, feed them back, and continue generation (with some retry caps, of course). Of course, for those in the main body, there is nothing I can do; the code still cannot make semantic-level distinctions (though adding a jev might help a bit, lol). But this has already greatly reduced the frequency and mitigated the problem. [f99e638 ](https://github.com/TwoAnts/Strata/commit/f99e6388e435462a233663b8ef9b3f00c3111304) 2. For the JSON format issue, I also added a small loop at the serve layer that points out the error and corrects it, and the problem is basically solved. [f839590](https://github.com/TwoAnts/Strata/commit/f839590af630564c17670fb141dd2bdbc39d7359) However, I mostly had an agent help me with the implementation, so it is somewhat crude. I think the overall direction of changes is to strengthen Strata's detection of unreasonable outputs at the serve layer, and to allow some iterative retry dialogue between the serve layer and the model before giving the final answer. (this could be an extensible and reasonably well-structured implementation) This is very similar to how humans check before delivering work results.
Author
Owner

@47Hunter47 commented on GitHub (Oct 12, 2026):

Your first point is the shape I have been chasing: the turn ends inside the thinking with no answer, so the client gets an empty reply with finish_reason: stop. Measured today on 0.1.43 (RTX 3090, Qwen3.8-Flash-Next IQ3_XXS, 250K context, --kv int8):

  • asking the model to show its closing thinking tag: 4 runs, 2 ended inside the thinking (384 and 63 tokens in). The guard closed the thinking and continued, and both answered (364 and 353 chars); /metrics showed totals.ended_inside_thinking = 2.
  • asking it to write </tool_call> verbatim: 4 runs, 2 ended inside the thinking. One was continued (the answer came back as <|), the other kept ending inside its thinking until the guard hit its cap of 2 continuations and that reply stayed empty.

So the guard I opened in #1840 (opt-in literal_think_guard) is not a complete fix, but it does two things that may help your harness: it continues the reply once or twice, and it says why a reply is empty when it cannot (log line, totals.ended_inside_thinking in /metrics, and ended_inside_thinking: true beside choices), so a client can retry instead of treating the turn as a normal empty answer.

If you can run your <|im_end|>-in-context prompt with the flag on, that counter will tell you whether it is the same end or a different one. And if it fires, the raw turn would be a useful addition to the five real turns in serve/fixtures/literal_think_specimens.json.

Your second point (the hindsight JSON error) is a separate issue, so I have nothing to add there.

<!-- gh-comment-id:6125473833 --> @47Hunter47 commented on GitHub (Oct 12, 2026): Your first point is the shape I have been chasing: the turn ends inside the thinking with no answer, so the client gets an empty reply with `finish_reason: stop`. Measured today on 0.1.43 (RTX 3090, Qwen3.8-Flash-Next IQ3_XXS, 250K context, `--kv int8`): - asking the model to show its closing thinking tag: 4 runs, 2 ended inside the thinking (384 and 63 tokens in). The guard closed the thinking and continued, and both answered (364 and 353 chars); `/metrics` showed `totals.ended_inside_thinking` = 2. - asking it to write `</tool_call>` verbatim: 4 runs, 2 ended inside the thinking. One was continued (the answer came back as `<|`), the other kept ending inside its thinking until the guard hit its cap of 2 continuations and that reply stayed empty. So the guard I opened in #1840 (opt-in `literal_think_guard`) is not a complete fix, but it does two things that may help your harness: it continues the reply once or twice, and it says why a reply is empty when it cannot (log line, `totals.ended_inside_thinking` in `/metrics`, and `ended_inside_thinking: true` beside `choices`), so a client can retry instead of treating the turn as a normal empty answer. If you can run your `<|im_end|>`-in-context prompt with the flag on, that counter will tell you whether it is the same end or a different one. And if it fires, the raw turn would be a useful addition to the five real turns in `serve/fixtures/literal_think_specimens.json`. Your second point (the hindsight JSON error) is a separate issue, so I have nothing to add there.
Author
Owner

@47Hunter47 commented on GitHub (Oct 12, 2026):

I ran your minimal input here, guard on (0.1.43, same build as above: RTX 3090, Qwen3.8-Flash-Next IQ3_XXS, 250K context, --kv int8).

Your prompt, 4 runs: 4/4 ended inside the thinking (116, 68, 139 and 63 tokens generated), each one closed and continued on the first attempt — journal: the reply ended inside its thinking with no answer ... closing the thinking so the model answers (1 of 2, literal_think_guard) — and 0 empty replies. totals.ended_inside_thinking 6 → 10.

The trigger you describe for long conversations, a transcript that already carries <|im_end|> followed by an ordinary question: 4 runs, 4/4 the same shape (125, 396, 65, 111 tokens), 0 empty. totals.ended_inside_thinking 10 → 14.

So on this build your case is not occasional, it is every run — 8/8 — and the guard rescued all eight. But the replies it rescued were mostly stubs: <|im_start|>, ", "marker" (that one is at least the answer), one <|im_end|> inside a fence, and one that resumed as planning prose instead of an answer. That is your diagnosis in f99e638: the literal re-tokenizes to the token that stops the turn, so the model cannot write it, and the guard only decides what happens after the stop. Write-back repairs the content, continuation repairs the empty reply — neither is the whole fix, and a turn like this needs both.

On the shape of the work: f99e638's "a turn that ends mid-structure is continued" is the same decision #1840 makes, covering the thinking case plus the quoted-marker and unclosed-fence cases #1840 does not. Mine is opt-in, capped per reply, and says why when it cannot continue; #1886 takes a third read, tying the parser transition to the real control-token identity. If you open f99e638 as a PR, the maintainer can run the three against one corpus, which is the comparison worth having before any of them lands. I would rather lose most of #1840 to your broader shape than have two half-fixes in the tree.

Your second point (the hindsight JSON error) is a different class from this one — as its own issue or PR it would get a proper review, and f839590 is already opt-in, which is the shape #1886 asked of #1840.

One offer: a specimen of this turn would fit the corpus in #1840 (serve/fixtures/literal_think_specimens.json, five real no-answer/answered/length-cut turns). Cutting one needs a serve started with STRATA_DEBUG=1, which the running server was not, so I could not cut it today; I can add one on the next restart with the flag on.

<!-- gh-comment-id:6128234719 --> @47Hunter47 commented on GitHub (Oct 12, 2026): I ran your minimal input here, guard on (`0.1.43`, same build as above: RTX 3090, Qwen3.8-Flash-Next IQ3_XXS, 250K context, `--kv int8`). Your prompt, 4 runs: **4/4 ended inside the thinking** (116, 68, 139 and 63 tokens generated), each one closed and continued on the first attempt — journal: `the reply ended inside its thinking with no answer ... closing the thinking so the model answers (1 of 2, literal_think_guard)` — and 0 empty replies. `totals.ended_inside_thinking` 6 → 10. The trigger you describe for long conversations, a transcript that already carries `<|im_end|>` followed by an ordinary question: 4 runs, **4/4 the same shape** (125, 396, 65, 111 tokens), 0 empty. `totals.ended_inside_thinking` 10 → 14. So on this build your case is not occasional, it is every run — 8/8 — and the guard rescued all eight. But the replies it rescued were mostly stubs: `<|im_start|>`, `"`, `"marker"` (that one is at least the answer), one `<|im_end|>` inside a fence, and one that resumed as planning prose instead of an answer. That is your diagnosis in `f99e638`: the literal re-tokenizes to the token that stops the turn, so the model cannot write it, and the guard only decides what happens *after* the stop. Write-back repairs the content, continuation repairs the empty reply — neither is the whole fix, and a turn like this needs both. On the shape of the work: `f99e638`'s "a turn that ends mid-structure is continued" is the same decision #1840 makes, covering the thinking case plus the quoted-marker and unclosed-fence cases #1840 does not. Mine is opt-in, capped per reply, and says why when it cannot continue; #1886 takes a third read, tying the parser transition to the real control-token identity. If you open `f99e638` as a PR, the maintainer can run the three against one corpus, which is the comparison worth having before any of them lands. I would rather lose most of #1840 to your broader shape than have two half-fixes in the tree. Your second point (the hindsight JSON error) is a different class from this one — as its own issue or PR it would get a proper review, and `f839590` is already opt-in, which is the shape #1886 asked of #1840. One offer: a specimen of this turn would fit the corpus in #1840 (`serve/fixtures/literal_think_specimens.json`, five real `no-answer`/`answered`/`length-cut` turns). Cutting one needs a serve started with `STRATA_DEBUG=1`, which the running server was not, so I could not cut it today; I can add one on the next restart with the flag on.
Author
Owner

@47Hunter47 commented on GitHub (Oct 12, 2026):

Follow-up, with the write-back in and the credit where it belongs: I ported the thinking case of your shape 3 into the guard from #1840 (06dfdc8c), so the text the stop token stood for is written back as ordinary text — the tokenizer's plain spans, so it can travel in the next pass's prompt without stopping that pass at once — and the thought goes on from there. Your backtick/fence shapes for the answer and your own caps I did not port; those are still yours if you open f99e638 as a PR.

It is what fixed the answer, not only the emptiness. Your minimal input, 4 runs on 0.1.43 here (RTX 3090, Qwen3.8-Flash-Next IQ3_XXS, 250K context, --kv int8), before and after:

reply owed to empty answered the answer
the close alone 0/4 4/4 `<
the close + the write-back 0/4 4/4 `<

All 8 runs ended inside the thinking, so the guard fired on every one of them; with the close alone they were non-empty but 3 of the 4 were stubs, and your diagnosis is the reason. The context-carries-<|im_end|> variant answered 4/4 with the write-back too (its longer answers still come back in the template's own vocabulary — <|im_start|>user\n... — which is the model, not the guard).

Detection and reporting are unchanged: one journal line per end, totals.ended_inside_thinking, and ended_inside_thinking: true beside choices. Two write-backs per reply, then the close, then the cap reports an empty reply; a thought that repeats whole passages is #728's loop, not a marker it mentions, and goes straight to the close.

Your second point (the hindsight JSON error) is still a different class from this one — if you open f839590 as its own issue or PR it can be reviewed on its own terms.

<!-- gh-comment-id:6129390623 --> @47Hunter47 commented on GitHub (Oct 12, 2026): Follow-up, with the write-back in and the credit where it belongs: I ported the *thinking* case of your shape 3 into the guard from #1840 (`06dfdc8c`), so the text the stop token stood for is written back as ordinary text — the tokenizer's `plain` spans, so it can travel in the next pass's prompt without stopping that pass at once — and the thought goes on from there. Your backtick/fence shapes for the answer and your own caps I did not port; those are still yours if you open `f99e638` as a PR. It is what fixed the answer, not only the emptiness. Your minimal input, 4 runs on 0.1.43 here (RTX 3090, Qwen3.8-Flash-Next IQ3_XXS, 250K context, `--kv int8`), before and after: | reply owed to | empty | answered | the answer | | --- | --- | --- | --- | | the close alone | 0/4 | 4/4 | `<|im_start|>`, a plan leaked into the answer, `<|im_start|>assistant ...`, `<|im_end|>` | | the close + the write-back | 0/4 | 4/4 | `<|im_end|>`, `"<|im_end|>"`, `<|im_end|>`, `"<|im_end|>"` | All 8 runs ended inside the thinking, so the guard fired on every one of them; with the close alone they were non-empty but 3 of the 4 were stubs, and your diagnosis is the reason. The context-carries-`<|im_end|>` variant answered 4/4 with the write-back too (its longer answers still come back in the template's own vocabulary — `<|im_start|>user\n...` — which is the model, not the guard). Detection and reporting are unchanged: one journal line per end, `totals.ended_inside_thinking`, and `ended_inside_thinking: true` beside `choices`. Two write-backs per reply, then the close, then the cap reports an empty reply; a thought that repeats whole passages is #728's loop, not a marker it mentions, and goes straight to the close. Your second point (the hindsight JSON error) is still a different class from this one — if you open `f839590` as its own issue or PR it can be reviewed on its own terms.
Author
Owner

@TwoAnts commented on GitHub (Oct 13, 2026):

Hi, really love your positive attitude. 👍👍👍

Just to share my perspective:

These fixes are actually all addressing long-tail issues. It feels more like cleaning up after the model. This is actually unrelated to the core of the inference engine, so I feel it should really be called a post-fix.

For these complex edge cases, the code may never be able to fix them all or fix them cleanly, and it may overcorrect. A lot of fix code combined could eventually become a giant pile of shit.

I suspect this may also be something the author wants to avoid as much as possible.

I think we may need to see what the author thinks. Whether he would allow a post-fix-like module to identify, correct, and retry various special cases, or whether he would rather integrate these fixes himself so they can be maintained going forward.

@Niko1221

<!-- gh-comment-id:6145407070 --> @TwoAnts commented on GitHub (Oct 13, 2026): Hi, really love your positive attitude. 👍👍👍 Just to share my perspective: These fixes are actually all addressing long-tail issues. It feels more like cleaning up after the model. This is actually unrelated to the core of the inference engine, so I feel it should really be called a post-fix. For these complex edge cases, the code may never be able to fix them all or fix them cleanly, and it may overcorrect. A lot of fix code combined could eventually become a giant pile of shit. I suspect this may also be something the author wants to avoid as much as possible. I think we may need to see what the author thinks. Whether he would allow a post-fix-like module to identify, correct, and retry various special cases, or whether he would rather integrate these fixes himself so they can be maintained going forward. @Niko1221
Author
Owner

@47Hunter47 commented on GitHub (Oct 13, 2026):

@TwoAnts I share the worry, and I think the repo has answered most of it already.

Recovery at the serve layer, behind a config key with a counter next to it, is not a new idea here. reasoning_loop_recovery works that way: it stops a generation, drains it, carries on from the same tokens, and reports reasoning_recoveries. docs/DETAILS.md calls it "a policy, not a numerical engine fix or a guarantee of an answer," and it says the recovery can mistake real work for a loop, so measure the answer quality next to the completion rate. tool_call_recovery has the same shape for calls written inside the reasoning, and it ships off by default. One key per class, with its own corpus and its own counter, is the pattern Strata already uses. I read literal_think_guard as the fourth member of that family rather than a new kind of patch, and that pattern is my answer to your worry about the fixes piling up.

I would still split two things the thread keeps together. When a quoted or mid-line </think> ends up in the answer (#1886), the parser is simply wrong, and that should be fixed every time with no flag at all. When the turn really does end inside its thinking and there is no answer to parse, an optional repair is the only thing left to do. Those are different problems. One flag over both would make things worse instead of simpler.

There is one place where the repo has already decided against retrying. structured.py says "Failed generations are errors, never silently retried or returned as successful structured output," so I would keep JSON repair out of the layer and leave it to the prompt or the client.

@Niko1221 what is genuinely your call here is scope, not shape. If you want this class handled, it can reuse the two recoveries that are already in the tree. If you would rather not, the half I would keep either way is the one that says why a reply came back empty, because that changes no output a client gets.

<!-- gh-comment-id:6150902864 --> @47Hunter47 commented on GitHub (Oct 13, 2026): @TwoAnts I share the worry, and I think the repo has answered most of it already. Recovery at the serve layer, behind a config key with a counter next to it, is not a new idea here. `reasoning_loop_recovery` works that way: it stops a generation, drains it, carries on from the same tokens, and reports `reasoning_recoveries`. `docs/DETAILS.md` calls it "a policy, not a numerical engine fix or a guarantee of an answer," and it says the recovery can mistake real work for a loop, so measure the answer quality next to the completion rate. `tool_call_recovery` has the same shape for calls written inside the reasoning, and it ships off by default. One key per class, with its own corpus and its own counter, is the pattern Strata already uses. I read `literal_think_guard` as the fourth member of that family rather than a new kind of patch, and that pattern is my answer to your worry about the fixes piling up. I would still split two things the thread keeps together. When a quoted or mid-line `</think>` ends up in the answer (#1886), the parser is simply wrong, and that should be fixed every time with no flag at all. When the turn really does end inside its thinking and there is no answer to parse, an optional repair is the only thing left to do. Those are different problems. One flag over both would make things worse instead of simpler. There is one place where the repo has already decided against retrying. `structured.py` says "Failed generations are errors, never silently retried or returned as successful structured output," so I would keep JSON repair out of the layer and leave it to the prompt or the client. @Niko1221 what is genuinely your call here is scope, not shape. If you want this class handled, it can reuse the two recoveries that are already in the tree. If you would rather not, the half I would keep either way is the one that says why a reply came back empty, because that changes no output a client gets.
Author
Owner

@Niko1221 commented on GitHub (Oct 13, 2026):

Thanks for the report. To keep the tracker current we are closing issues older than three days: 0.1.44 is out with a long list of fixes, and many older reports are covered by it or by 0.1.43.1.

If this still happens on 0.1.44, please leave a comment here with your engine log (and the version line it prints), and we will reopen it. A new issue that links this one works too.

<!-- gh-comment-id:6156029100 --> @Niko1221 commented on GitHub (Oct 13, 2026): Thanks for the report. To keep the tracker current we are closing issues older than three days: [0.1.44](https://github.com/Niko1221/Strata/releases/tag/v0.1.44) is out with a long list of fixes, and many older reports are covered by it or by 0.1.43.1. If this still happens on 0.1.44, please leave a comment here with your engine log (and the version line it prints), and we will reopen it. A new issue that links this one works too.
Author
Owner

@47Hunter47 commented on GitHub (Oct 14, 2026):

I re-ran this on a stock 0.1.44, so this shape is not covered by the release:

  • a checkout of the tag v0.1.44 (ed4773eb) — the tag's own serve/, no local patches; literal_think_guard does not exist there, so none of my code is in the path.
  • build_info = Strata 0.1.44, engine 0.1.44, RTX 3090, Qwen3.8-Flash-Next IQ3_XXS, 250K context, --kv int8, sampling 1.0/0.95/20, thinking budget 16384.

The minimal input from #1178 (Qwen 聊天模板里,助手回合的结束标记是什么?请原样写出,例如 "标记"。), 8 runs, max_tokens 4000, temperature 1.0: 8 of 8 came back with an empty content and finish_reason: stop (86 to 255 tokens generated). One turn, as the engine log prints it:

[strata] req openai: msgs=1 tools=0 max_tokens_raw=4000/None max_new=4000 thinking=True stream=False prompt_tokens=76
[strata] thinking capped at 3000 of max_tokens 4000 to leave room for the answer (budget 16384)
[strata] thinking: 76 of budget 3000 (max 4000) tokens, 86.3 tok/s, 1 s
[strata] done: 89 tokens in 1 s (81.9 tok/s) (stop, cancel=False), expert cache 98.1% hit
[strata] raw: '...使用 ChatML 格式:<|im_start|>user\n内容<|im_end|>'

89 tokens out of a 3000-token thinking budget, ended with stop: no budget cut and no length cut — the raw text stops where the model was about to write <|im_end|> and nothing reaches content.

The prompt from #1814 ("In a markdown code fence, show exactly how the closing thinking tag looks..."), 10 runs: 3 empty, same shape (the reasoning ends on Could be something like ", the closing tag for thought: `, they likely mean a tag like <|im_end|>).

On that tree /metrics has no ended_inside_thinking, so an empty reply carries no sign of why it is empty. That is what #1840 adds, both layers behind literal_think_guard: with it on, the same two prompts came back 0 empty of 8 on the same box, and each end is reported (the response field, the journal line, /metrics).

So the class is still there on 0.1.44 as it ships, and the fix for it is the review of #1840.

<!-- gh-comment-id:6160396382 --> @47Hunter47 commented on GitHub (Oct 14, 2026): I re-ran this on a **stock 0.1.44**, so this shape is not covered by the release: - a checkout of the tag `v0.1.44` (`ed4773eb`) — the tag's own `serve/`, no local patches; `literal_think_guard` does not exist there, so none of my code is in the path. - `build_info` = `Strata 0.1.44`, engine 0.1.44, RTX 3090, Qwen3.8-Flash-Next IQ3_XXS, 250K context, `--kv int8`, sampling 1.0/0.95/20, thinking budget 16384. **The minimal input from #1178** (`Qwen 聊天模板里,助手回合的结束标记是什么?请原样写出,例如 "标记"。`), 8 runs, `max_tokens` 4000, temperature 1.0: **8 of 8 came back with an empty `content` and `finish_reason: stop`** (86 to 255 tokens generated). One turn, as the engine log prints it: ``` [strata] req openai: msgs=1 tools=0 max_tokens_raw=4000/None max_new=4000 thinking=True stream=False prompt_tokens=76 [strata] thinking capped at 3000 of max_tokens 4000 to leave room for the answer (budget 16384) [strata] thinking: 76 of budget 3000 (max 4000) tokens, 86.3 tok/s, 1 s [strata] done: 89 tokens in 1 s (81.9 tok/s) (stop, cancel=False), expert cache 98.1% hit [strata] raw: '...使用 ChatML 格式:<|im_start|>user\n内容<|im_end|>' ``` 89 tokens out of a 3000-token thinking budget, ended with `stop`: no budget cut and no length cut — the raw text stops where the model was about to write `<|im_end|>` and nothing reaches `content`. The prompt from #1814 ("In a markdown code fence, show exactly how the closing thinking tag looks..."), 10 runs: 3 empty, same shape (the reasoning ends on `Could be something like "`, `` the closing tag for thought: ` ``, `they likely mean a tag like <|im_end|>`). On that tree `/metrics` has no `ended_inside_thinking`, so an empty reply carries no sign of why it is empty. That is what #1840 adds, both layers behind `literal_think_guard`: with it on, the same two prompts came back 0 empty of 8 on the same box, and each end is reported (the response field, the journal line, `/metrics`). So the class is still there on 0.1.44 as it ships, and the fix for it is the review of #1840.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
Niko1221/Strata#491
No description provided.