[GH-ISSUE #2731] [Engine] a reply that ends inside its thinking still returns an empty answer on 0.2.0-beta (the #1814 shape) #1095

Closed
opened 2026-11-04 01:48:27 +07:00 by bsakaguchi · 6 comments
Owner

Originally created by @47Hunter47 on GitHub (Oct 16, 2026).
Original GitHub issue: https://github.com/Niko1221/Strata/issues/2731

Problem: a reply that ends inside its thinking with no answer comes back empty and nothing says why. The turn ends on the turn-end token just as the model is about to write its closing thinking tag, so finish_reason is stop, content is empty, and the reasoning stops mid-sentence.

Environment: Strata v0.2.0-beta (3d1fb480), a stock checkout of the tag - its own serve/, no local patches - with the engine built from that source (/props.build_info reports Strata 0.1.45.3). Ubuntu 26.04, RTX 3090 (24 GB), 64 GB RAM, 20 cores. Qwen3.8-Flash-Next IQ3_XXS, 250K context, --kv int8, sampling 1.0/0.95/20, reasoning_budget_tokens 16384, reasoning_close_retry off (its default).

Reproduce: POST /v1/chat/completions with #1178's minimal input - the question that asks for the assistant's turn-end marker verbatim, which is what makes the model reach for that token:

{"model": "qwen3.8-flash-next", "max_tokens": 8000, "temperature": 1.0,
 "messages": [{"role": "user", "content": "Qwen 聊天模板里,助手回合的结束标记是什么?请原样写出,例如 \"标记\"。"}]}

Expected: an answer - or, when the reply comes back empty, a sign of why it is empty.

Actual: 4 of 4 runs empty on this tag, finish_reason stop, content empty, reasoning_content 103-250 characters. The runs generated 44 to 115 tokens of an 8000-token cap (thinking capped at 6000): not a budget cut and not a length cut. On #1814's prompt (the closing thinking tag in a code fence) 1 of 4 runs. With reasoning_close_retry: true the replies stop being empty but are stubs - 9, 10, 12 and 80 characters on the same input - because the close happens exactly where the closing tag would start.

Evidence:

[strata] done: 68 tokens in 2 s (67.6 tok/s) (stop, cancel=False), expert cache 84.6% hit
[strata] done: 67 tokens in 1 s (87.2 tok/s) (stop, cancel=False), expert cache 93.5% hit
[strata] done: 44 tokens in 1 s (89.0 tok/s) (stop, cancel=False), expert cache 95.4% hit
[strata] done: 115 tokens in 1 s (102.0 tok/s) (stop, cancel=False), expert cache 93.4% hit

Reproduction status: reproduced locally

Retest on 0.2.0-beta, as the closing comment asked

Same end on the release's own checkout, so I am filing the retest here. The shape is unchanged from #1814: the turn-end token is a type-3 control token in this pack's tokenizer (id 248046, matched only with parse_special) and the closing thinking tag is type-4 (id 248069), so a turn that ends inside the thinking looks exactly like a turn that ended there on purpose. The reporting that would say so (ended_inside_thinking beside choices, a log line, a counter) does not exist on main (296b59d2) or on this tag.

reasoning_close_retry (new since #1053's shape landed) covers the empty reply but not the thought: it closes the thinking where the model was about to write its closing tag and answers with what is left, which is where the 9-80 character stubs come from.

The fix in #1840 was closed in the tracker reset; I reopened the same work on this base as #3207 - the marker's text goes back as ordinary text where the model was writing it (#1178), the thought continues from there, and the close is the fallback for the other shapes, all behind the same opt-in flag.

Originally created by @47Hunter47 on GitHub (Oct 16, 2026). Original GitHub issue: https://github.com/Niko1221/Strata/issues/2731 Problem: a reply that ends inside its thinking with no answer comes back empty and nothing says why. The turn ends on the turn-end token just as the model is about to write its closing thinking tag, so `finish_reason` is `stop`, `content` is empty, and the reasoning stops mid-sentence. Environment: Strata `v0.2.0-beta` (`3d1fb480`), a stock checkout of the tag - its own `serve/`, no local patches - with the engine built from that source (`/props.build_info` reports `Strata 0.1.45.3`). Ubuntu 26.04, RTX 3090 (24 GB), 64 GB RAM, 20 cores. Qwen3.8-Flash-Next IQ3_XXS, 250K context, `--kv int8`, sampling 1.0/0.95/20, `reasoning_budget_tokens` 16384, `reasoning_close_retry` off (its default). Reproduce: `POST /v1/chat/completions` with #1178's minimal input - the question that asks for the assistant's turn-end marker verbatim, which is what makes the model reach for that token: ``` {"model": "qwen3.8-flash-next", "max_tokens": 8000, "temperature": 1.0, "messages": [{"role": "user", "content": "Qwen 聊天模板里,助手回合的结束标记是什么?请原样写出,例如 \"标记\"。"}]} ``` Expected: an answer - or, when the reply comes back empty, a sign of why it is empty. Actual: 4 of 4 runs empty on this tag, `finish_reason` `stop`, `content` empty, `reasoning_content` 103-250 characters. The runs generated 44 to 115 tokens of an 8000-token cap (thinking capped at 6000): not a budget cut and not a length cut. On #1814's prompt (the closing thinking tag in a code fence) 1 of 4 runs. With `reasoning_close_retry: true` the replies stop being empty but are stubs - 9, 10, 12 and 80 characters on the same input - because the close happens exactly where the closing tag would start. Evidence: ``` [strata] done: 68 tokens in 2 s (67.6 tok/s) (stop, cancel=False), expert cache 84.6% hit [strata] done: 67 tokens in 1 s (87.2 tok/s) (stop, cancel=False), expert cache 93.5% hit [strata] done: 44 tokens in 1 s (89.0 tok/s) (stop, cancel=False), expert cache 95.4% hit [strata] done: 115 tokens in 1 s (102.0 tok/s) (stop, cancel=False), expert cache 93.4% hit ``` Reproduction status: reproduced locally ## Retest on 0.2.0-beta, as the closing comment asked Same end on the release's own checkout, so I am filing the retest here. The shape is unchanged from #1814: the turn-end token is a type-3 control token in this pack's tokenizer (id 248046, matched only with `parse_special`) and the closing thinking tag is type-4 (id 248069), so a turn that ends inside the thinking looks exactly like a turn that ended there on purpose. The reporting that would say so (`ended_inside_thinking` beside `choices`, a log line, a counter) does not exist on `main` (`296b59d2`) or on this tag. `reasoning_close_retry` (new since #1053's shape landed) covers the empty reply but not the thought: it closes the thinking where the model was about to write its closing tag and answers with what is left, which is where the 9-80 character stubs come from. The fix in #1840 was closed in the tracker reset; I reopened the same work on this base as #3207 - the marker's text goes back as ordinary text where the model was writing it (#1178), the thought continues from there, and the close is the fallback for the other shapes, all behind the same opt-in flag.
Author
Owner

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

Thanks for taking the time to report this.

We're resetting the tracker for 0.2.0-beta. There are more than 1,300 open issues and pull requests, too many for us to read properly, so we're closing everything that isn't being worked on right now. Closed here does not mean rejected.

To reopen it takes about two minutes:

  1. Re-test on 0.2.0-beta. It may already be fixed. Write down what you see.
  2. Start the title with its area: [Engine], [GUI], [TUI], [Benchmark], [Docs] or [Other].
  3. Fill in the parts of the issue form: what happened, the Strata version, your graphics card, memory and system.
  4. Comment /reopen. A check runs and either reopens the issue or lists what is still missing.

The rules are in CONTRIBUTING.md.

<!-- gh-comment-id:6271213921 --> @Niko1221 commented on GitHub (Oct 19, 2026): Thanks for taking the time to report this. We're resetting the tracker for 0.2.0-beta. There are more than 1,300 open issues and pull requests, too many for us to read properly, so we're closing everything that isn't being worked on right now. Closed here does not mean rejected. To reopen it takes about two minutes: 1. Re-test on 0.2.0-beta. It may already be fixed. Write down what you see. 2. Start the title with its area: [Engine], [GUI], [TUI], [Benchmark], [Docs] or [Other]. 3. Fill in the parts of the issue form: what happened, the Strata version, your graphics card, memory and system. 4. Comment `/reopen`. A check runs and either reopens the issue or lists what is still missing. The rules are in [CONTRIBUTING.md](https://github.com/Niko1221/Strata/blob/main/CONTRIBUTING.md).
Author
Owner

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

/reopen

<!-- gh-comment-id:6274367703 --> @47Hunter47 commented on GitHub (Oct 19, 2026): /reopen
Author
Owner

@github-actions[bot] commented on GitHub (Oct 19, 2026):

Reopened, thank you. A maintainer will pick it up from here.

<!-- gh-comment-id:6274371093 --> @github-actions[bot] commented on GitHub (Oct 19, 2026): Reopened, thank you. A maintainer will pick it up from here.
Author
Owner

@oinani0721 commented on GitHub (Oct 19, 2026):

Same end on a Mac (Metal), hit from Codex. Adding it as evidence from another backend and client. It was measured on an older build, not on 0.2.0-beta, but the block that closes the thinking for reasoning_close_retry (serve/server.py 4355-4400 on 296b59d2) reads the same on v0.2.0-beta (4872-4917).

Environment: Apple M5 Max, 128 GB, macOS 27.0.1. Strata built from main 296b59d2 (0.1.44.1) with that commit's own serve/; the engine also carries #2503, #2631, #2819 and two local patches (a conversation-cache disk tier, a wait for freed memory before the arena is planned). Unsloth's Qwen3.8-Flash-Next UD-Q6_K_XL, experts streamed from the GGUF (STRATA_METAL_STREAM=1, --mmap-experts), --max-context 262144, --spec 3 with MTP. Codex CLI 0.159.3 over /v1/responses. Metal decodes greedily whatever the request sends (#3006), so a rerun gives the same reply.

In use: over Oct 17-19, 4 of 431 Codex turns on Strata on this Mac ended on a reply that was a reasoning item alone, with no message and no call, so Codex ended the turn mid-task. All four were in one Codex thread about think-tag leakage, and each reasoning ended on an opening backtick (...look for actual generation content with `). The user's two follow-ups ("continue", then "why do you keep stopping") ended the same way.

Reproduce: a non-streaming /v1/responses request shaped like Codex's, with one function tool and effort xhigh. The user text asks for the closing thinking tag in backticks in the thinking, then a command:

{"model": "qwen3.8-flash-next-unsloth-ud-q6_k_xl", "stream": false, "tool_choice": "auto",
 "reasoning": {"effort": "xhigh"},
 "instructions": "You are a coding agent on the user's Mac. Use the exec_command tool to run shell commands.",
 "tools": [{"type": "function", "name": "exec_command", "description": "Runs a shell command and returns its output.",
            "parameters": {"type": "object", "properties": {"cmd": {"type": "string"}}, "required": ["cmd"]}}],
 "input": [{"type": "message", "role": "user", "content": [{"type": "input_text", "text":
   "我在排查 Qwen 模型的思考内容漏进正文的问题。请先在思考里写出 Qwen 思考块的结束标签(用反引号包起来),说一句它的作用,然后调用 exec_command 运行 `ls ~/Library/Logs/strata | head -3`。"}]}]}

In English: "I'm debugging Qwen's thinking leaking into the answer. First, in your thinking, write out the end tag of Qwen's thinking block (in backticks) and say in one sentence what it does, then call exec_command to run ls ~/Library/Logs/strata | head -3." The control asks for "a short plan in your thinking" instead of the tag.

request runs reply
tag prompt, no sampling fields 4 reasoning only, ending The Qwen thinking block end tag is and a backtick; output / reasoning tokens 80 / 79
tag prompt, temperature 1.0, top_p 0.95, top_k 20 10 the same (same counts, same ending)
control 3 reasoning, then the function_call; 125 / 86
tag prompt, "reasoning_close_retry": true 2 reasoning up to the same backtick, then a message whose whole text is </think> (the model finishing its sentence), then the function_call; 123 tokens
control, "reasoning_close_retry": true 2 unchanged, 125 / 86

Both retried runs log the reply ended inside its thinking with no answer: closing the thinking once and continuing (reasoning_close_retry). So in an agent turn the retry keeps the call: the stub you saw (here the 8 characters of the tag), then the call. The thought after the tag is still lost, which is the part #3207 keeps.

Token count (the pack's own tokenizer): a stopped reply's reasoning re-tokenizes to exactly reasoning_tokens, and output_tokens is one more. In the Codex turns that went on to a call, the reasoning re-tokenizes to one less than reasoning_tokens (the closing tag counts as reasoning). So the stopped replies end on one token that is neither reasoning text nor the closing tag, consistent with your reading (248046 where 248069 would go). That holds for the repro and for 3 of the 4 Codex stops; the fourth re-tokenizes to 3 tokens more than it counts, so it shows nothing either way.

Not run: v0.2.0-beta's engine, #3207, other packs on Metal.

<!-- gh-comment-id:6279301339 --> @oinani0721 commented on GitHub (Oct 19, 2026): Same end on a Mac (Metal), hit from Codex. Adding it as evidence from another backend and client. It was measured on an older build, not on 0.2.0-beta, but the block that closes the thinking for `reasoning_close_retry` (`serve/server.py` 4355-4400 on 296b59d2) reads the same on v0.2.0-beta (4872-4917). **Environment:** Apple M5 Max, 128 GB, macOS 27.0.1. Strata built from `main` 296b59d2 (0.1.44.1) with that commit's own `serve/`; the engine also carries #2503, #2631, #2819 and two local patches (a conversation-cache disk tier, a wait for freed memory before the arena is planned). Unsloth's Qwen3.8-Flash-Next UD-Q6_K_XL, experts streamed from the GGUF (`STRATA_METAL_STREAM=1`, `--mmap-experts`), `--max-context 262144`, `--spec 3` with MTP. Codex CLI 0.159.3 over `/v1/responses`. Metal decodes greedily whatever the request sends (#3006), so a rerun gives the same reply. **In use:** over Oct 17-19, 4 of 431 Codex turns on Strata on this Mac ended on a reply that was a reasoning item alone, with no message and no call, so Codex ended the turn mid-task. All four were in one Codex thread about think-tag leakage, and each reasoning ended on an opening backtick (`` ...look for actual generation content with ` ``). The user's two follow-ups ("continue", then "why do you keep stopping") ended the same way. **Reproduce:** a non-streaming `/v1/responses` request shaped like Codex's, with one function tool and effort `xhigh`. The user text asks for the closing thinking tag in backticks in the thinking, then a command: ```json {"model": "qwen3.8-flash-next-unsloth-ud-q6_k_xl", "stream": false, "tool_choice": "auto", "reasoning": {"effort": "xhigh"}, "instructions": "You are a coding agent on the user's Mac. Use the exec_command tool to run shell commands.", "tools": [{"type": "function", "name": "exec_command", "description": "Runs a shell command and returns its output.", "parameters": {"type": "object", "properties": {"cmd": {"type": "string"}}, "required": ["cmd"]}}], "input": [{"type": "message", "role": "user", "content": [{"type": "input_text", "text": "我在排查 Qwen 模型的思考内容漏进正文的问题。请先在思考里写出 Qwen 思考块的结束标签(用反引号包起来),说一句它的作用,然后调用 exec_command 运行 `ls ~/Library/Logs/strata | head -3`。"}]}]} ``` In English: "I'm debugging Qwen's thinking leaking into the answer. First, in your thinking, write out the end tag of Qwen's thinking block (in backticks) and say in one sentence what it does, then call exec_command to run `ls ~/Library/Logs/strata | head -3`." The control asks for "a short plan in your thinking" instead of the tag. | request | runs | reply | |---|---|---| | tag prompt, no sampling fields | 4 | reasoning only, ending `The Qwen thinking block end tag is ` and a backtick; output / reasoning tokens 80 / 79 | | tag prompt, `temperature 1.0, top_p 0.95, top_k 20` | 10 | the same (same counts, same ending) | | control | 3 | reasoning, then the `function_call`; 125 / 86 | | tag prompt, `"reasoning_close_retry": true` | 2 | reasoning up to the same backtick, then a message whose whole text is `</think>` (the model finishing its sentence), then the `function_call`; 123 tokens | | control, `"reasoning_close_retry": true` | 2 | unchanged, 125 / 86 | Both retried runs log `the reply ended inside its thinking with no answer: closing the thinking once and continuing (reasoning_close_retry)`. So in an agent turn the retry keeps the call: the stub you saw (here the 8 characters of the tag), then the call. The thought after the tag is still lost, which is the part #3207 keeps. **Token count** (the pack's own tokenizer): a stopped reply's reasoning re-tokenizes to exactly `reasoning_tokens`, and `output_tokens` is one more. In the Codex turns that went on to a call, the reasoning re-tokenizes to one less than `reasoning_tokens` (the closing tag counts as reasoning). So the stopped replies end on one token that is neither reasoning text nor the closing tag, consistent with your reading (248046 where 248069 would go). That holds for the repro and for 3 of the 4 Codex stops; the fourth re-tokenizes to 3 tokens more than it counts, so it shows nothing either way. **Not run:** v0.2.0-beta's engine, #3207, other packs on Metal.
Author
Owner

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

Thanks — the Mac numbers help, and two things in them line up with measurements from this box.

The ids. Re-checked against this pack's own tokenizer (no engine, the pack's tokenizer/ files): 248046 is type 3 CONTROL and decodes as <|im_end|>, 248069 is type 4 USER_DEFINED and decodes as </think>. A thought writing the marker between backticks really does reach the turn-end token: ... end tag is + backtick + the literal encodes to ... 4619, 369, 1510, 248046 with the literal collapsing to that single control id, and the same sentence with </think> ends on 248069. plain=[(0, len(literal))] turns the literal back into 6 ordinary tokens and decode is unchanged — that is the mechanism #3207's write-back uses, and it costs 4 extra tokens on that turn.

The </think> stub in your retry row. That reads like the model finishing the sentence it was writing: the forced close ends the thinking, and the tag it was mid-way through comes out as answer text. #3207 gives that text back where the model was writing it, so the thought continues and the call that follows it survives — which your table shows the retry also achieves, at the price of the thought after the tag.

A gap your report exposes. Your client is on /v1/responses. #3207's continuation sits in Service.run, so it is dialect-independent, but its report (ended_inside_thinking) is wired only into the chat-completions reply. Measured on the branch over HTTP with a mock engine: guard on → the turn is two passes and comes back as reasoning + message (and in the tool-shaped variant, reasoning + function_call), with the log line "the reply ended inside its thinking while writing <|im_end|>"; guard off → a reasoning item alone, status: completed, and nothing in the body that says why. In the same run the chat reply carries the flag beside choices and the Responses object does not carry it anywhere. Carrying it across to the Responses API is its own change; I will treat it as a follow-up rather than fold it into #3207.

Not run here: a Metal engine, and UD-Q6_K_XL.

<!-- gh-comment-id:6283128552 --> @47Hunter47 commented on GitHub (Oct 20, 2026): Thanks — the Mac numbers help, and two things in them line up with measurements from this box. **The ids.** Re-checked against this pack's own tokenizer (no engine, the pack's `tokenizer/` files): 248046 is type 3 CONTROL and decodes as `<|im_end|>`, 248069 is type 4 USER_DEFINED and decodes as `</think>`. A thought writing the marker between backticks really does reach the turn-end token: `... end tag is ` + backtick + the literal encodes to `... 4619, 369, 1510, 248046` with the literal collapsing to that single control id, and the same sentence with `</think>` ends on 248069. `plain=[(0, len(literal))]` turns the literal back into 6 ordinary tokens and `decode` is unchanged — that is the mechanism #3207's write-back uses, and it costs 4 extra tokens on that turn. **The `</think>` stub in your retry row.** That reads like the model finishing the sentence it was writing: the forced close ends the thinking, and the tag it was mid-way through comes out as answer text. #3207 gives that text back where the model was writing it, so the thought continues and the call that follows it survives — which your table shows the retry also achieves, at the price of the thought after the tag. **A gap your report exposes.** Your client is on `/v1/responses`. #3207's continuation sits in `Service.run`, so it is dialect-independent, but its report (`ended_inside_thinking`) is wired only into the chat-completions reply. Measured on the branch over HTTP with a mock engine: guard on → the turn is two passes and comes back as `reasoning` + `message` (and in the tool-shaped variant, `reasoning` + `function_call`), with the log line "the reply ended inside its thinking while writing `<|im_end|>`"; guard off → a `reasoning` item alone, `status: completed`, and nothing in the body that says why. In the same run the chat reply carries the flag beside `choices` and the Responses object does not carry it anywhere. Carrying it across to the Responses API is its own change; I will treat it as a follow-up rather than fold it into #3207. Not run here: a Metal engine, and UD-Q6_K_XL.
Author
Owner

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

Closing: the opt-in that already exists fixes this — reasoning_close_retry: true (#1053) in the model's strata-<model>.json continues a reply that ends inside its thinking.

Verified on 0.2.x with engine 0.1.47 (same card, model and IQ3_XXS quant as the report): two #1814-shaped inputs x 15 runs each -> 0/30 empty replies with the flag on. Without it the shape still reproduces, so turning the flag on is what matters.

The always-on reporting proposed in #3207 is not needed for the fix; that PR is closed too.

<!-- gh-comment-id:6336773509 --> @47Hunter47 commented on GitHub (Oct 22, 2026): Closing: the opt-in that already exists fixes this — `reasoning_close_retry: true` (#1053) in the model's `strata-<model>.json` continues a reply that ends inside its thinking. Verified on 0.2.x with engine 0.1.47 (same card, model and IQ3_XXS quant as the report): two #1814-shaped inputs x 15 runs each -> 0/30 empty replies with the flag on. Without it the shape still reproduces, so turning the flag on is what matters. The always-on reporting proposed in #3207 is not needed for the fix; that PR is closed too.
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#1095
No description provided.