[GH-ISSUE #5110] [engine 0.1.55]. Replies ending on the stop token in three positions #2388

Open
opened 2026-11-04 01:58:53 +07:00 by bsakaguchi · 1 comment
Owner

Originally created by @Freedominmyheart on GitHub (Nov 3, 2026).
Original GitHub issue: https://github.com/Niko1221/Strata/issues/5110

Replies ending on the stop token in three positions: two healable, one silent

Environment: strata 0.2.9 / engine 0.1.55 (built locally, gfx1151, ROCm 7.14), model
qwen3.8-flash-next-unsloth-ud-iq4_xs, client = bundled web app (serve/web), stream: true,
6 MCP servers / 49 namespaced tools.

Summary

Across ~4 h of ordinary agent use (a long session, thinking on, tool use heavy), replies keep
ending on the end-of-turn token early. The token arrives in one of three positions and each has a
different observable:

# EOS lands in What the user sees Auto-healed?
1 inside think "Thought for N s" panel ends mid-sentence, no answer at all yes, with reasoning_close_retry: true (#1053)
2 inside a tool call's arguments tool card appears, arguments stay "(being written)", status ends Not run, tool never executes no
3 inside answer content answer stops mid-sentence, often right after an inline code span cannot be, in general

All three report finish_reason: "stop" and cancel=False, which is the common defect: nothing in
the response distinguishes "the model finished" from "the model stopped early"
, and cases 2 and 3
produce no log line at all.

The number I'd most like the maintainers to look at: the #1053 recovery fired twice in ~1 hour
of normal use (the reply ended inside its thinking with no answer). A healthy model should not be
EOS-ing inside its own reasoning twice an hour. So I suspect the root cause is below the HTTP layer
— model/numerics/sampling — and the three symptoms above are just where that lands.

Case 1 — EOS inside the thinking (confirmed, and it has a fix)

Journal, twice (20:26:22, 20:27:04 in one session):

[strata] the reply ended inside its thinking with no answer: closing the thinking once and
         continuing (reasoning_close_retry)

…followed by a correct tool call / answer in the same round. Two things this proves: the behaviour is
real on this model, and reasoning_close_retry works as documented. Before enabling it the same
rounds simply returned the reasoning text with an empty answer.

Case 2 — EOS inside a tool call ("Not run")

Chain, as far as I can read it:

  1. generation loop stops on the token:
    if t in self.stop_ids: … finish = "stop"; raw_ids.append(t); break
  2. OutputParser.finish() declines to emit the half-written call — its docstring: an already
    announced call "stays unfinished: its JSON is not closed and no tool_call follows it, #211"
  3. so no tool_call event exists → the tool-execution entry points (ev.kind == "tool_call") are
    never reached → MCP is not involved anywhere in this path (a real MCP-side failure logs
    tool <name>: error, …; this logs nothing, which is how I finally separated them)
  4. the request runs with stream_tools=True, so tool_start was already sent when the name was
    decoded — the client is left holding a card it then sweeps:
    for (const t of m.tools || []) if (t.state === "writing" || …) { t.state = "skipped"; … }

Refusing to execute truncated arguments is right; my objection is that the turn is silently dead and
unmeasurable.

Note: some truncated shapes are recovered. In a harness test a call cut after a complete
</function> still arrived as a normal tool_calls (the native function_done /
tool_args_repaired path), so what reaches "Not run" is what that path can't close.

Case 3 — EOS inside answer content

The answer just ends mid-sentence. The user's observation, repeatedly: it stops right after an
inline code span
. I tested the obvious theory (a stop word) and it is wrong — see below. I am
reporting the pattern, not a cause.

Analysis process (mostly things I ruled out)

  • Stop word / stop parameter — refuted. Direct SSE request whose text contained backticks,
    thinking on and off: full text arrived, finish_reason: stop. Also stop_strings() only applies
    when the client sends stop; our config sends none, and StopMatcher is not in play.
  • OutputParser withholding text around backticks — refuted by unit test: text with paired and
    unpaired backticks, chunked at 5 chars, thinking both ways → zero loss, buf empty at finish().
  • the web client's read loop — clean; no early break, and raw SSE replay in the same browser
    arrives complete.
  • code-fence rendering swallowing text — I published this as the root cause and it was wrong.
    My node harness measured the wrong object; the real codeBlock() renders an unterminated block
    normally. Worth naming because it is a tempting false positive.
  • a second client on the socket — 8080 binds 127.0.0.1 only, one ESTAB connection (an ssh
    tunnel). One user, one browser page.
  • server errors / OOM / load — journal for every affected round is
    done: N tokens in T s (stop, cancel=False), no exception, no cancel=True.
  • one confounder I created myself: the single-chat store writes to localStorage, and once the
    chat passes the ~5 MB quota setItem throws and the page swallows it — so after a reload the
    restored history is the last version that fitted. That looks exactly like a truncated answer.
    Fixed locally (try progressively smaller shapes, then say so), but flagging it because it will
    bite anyone with a long chat and it muddies exactly this investigation.

Hypotheses for the early EOS, with a knob each

Ordered by how cheap they are to falsify. All untested.

  1. Speculative decoding. Our usage blocks report real draft activity
    (predicted_n: 136, draft_n: 114, draft_n_accepted: 96). If a draft can be accepted across a
    position where the target would not have emitted EOS, early termination is exactly the symptom.
    Knob: disable speculative decoding and re-run the same session.
  2. gfx1151 numeric defaults on this machine. The engine log says HC_Q8 (8-bit hyper-connection
    projections used on the verify read) is on by default for gfx1151, plus "19 exact speed
    switches on by default", and states output is no longer bit-identical. If EOS logits shift
    slightly under verify-path quantisation, an early stop is a plausible first-order effect, and it
    would explain why this is much more visible here than in CI. Knob: STRATA_HC_Q8=0, and
    STRATA_GFX1151_DEFAULTS=0 as a bisect.
  3. Tokenizer special-token adjacency / the tool-call grammar in the chat template. EOS
    concentrate in the structured regions (inside think, inside <tool_call>), which is where the
    template's grammar decides "this turn is over". Knob: replay one failing prompt through the
    template with a different model card, or dump the logits at the cut position.
  4. The checkpoint itself (a local quant): least interesting for upstream, but if 1–3 are clean
    then this is a model-quality report, not a server one.

The deliberate probe I could run — 12 completions forced to emit four inline code spans each — ended
at a backtick 1/12 times. So inline code is a correlate, not a cause; anyone writing "backticks
stop the model" will chase nothing.

What I'd like

  1. Case 2, a retry mirroring #1053: when the loop ends with finish == "stop" and the parser is
    in a call state and nothing visible has been streamed yet, drop the half-call out of
    prompt + seg and write the turn once. The "nothing visible yet" guard is what keeps it from
    repeating text on the wire. Prefix-cache reuse should make it cheap.
    (I tried the obvious alternative — continue from the half-call as an assistant prefix — 6/6
    times the model narrated "the command ran, output: CONT_OK" instead of closing the call,
    because in the history the command already looks executed. So it has to be without the cut call.)
  2. A counter and a log line for cases 2 and 3, e.g. strata_truncated_tool_calls next to
    strata_rejected_tool_calls, and a /metrics counter. Case 3's only current symptom is an
    absent log line, which is why this took so long to attribute.
  3. For case 3, at minimum a distinguishable finish_reason (or a flag) so a client can render
    "incomplete" instead of "the model had a short answer". I know nothing general can tell "finished"
    from "cut" mid-content — that's why I'm asking for signal, not for a heal.

Honest limits of this report

Verified: case 1 (server's own log line, twice); that case 2 bypasses MCP entirely; that #1053 works;
the ruled-out list above. Not verified: the parser.state at a real case-2 cut (no log field
records it), any trustworthy frequency for cases 2–3 (every journal-side counting method I tried is
biased — the last progress line of a successful call round also reads writing a tool call), and
any of the four hypotheses.

Happy to run a bisect on 1 and 2 — with this session length, a difference shows up within an hour.

Originally created by @Freedominmyheart on GitHub (Nov 3, 2026). Original GitHub issue: https://github.com/Niko1221/Strata/issues/5110 # Replies ending on the stop token in three positions: two healable, one silent **Environment**: strata 0.2.9 / engine 0.1.55 (built locally, gfx1151, ROCm 7.14), model `qwen3.8-flash-next-unsloth-ud-iq4_xs`, client = bundled web app (`serve/web`), `stream: true`, 6 MCP servers / 49 namespaced tools. ## Summary Across ~4 h of ordinary agent use (a long session, thinking on, tool use heavy), replies keep ending on the end-of-turn token **early**. The token arrives in one of three positions and each has a different observable: | # | EOS lands in | What the user sees | Auto-healed? | |---|---|---|---| | 1 | inside ` think` | "Thought for N s" panel ends mid-sentence, **no answer at all** | yes, with `reasoning_close_retry: true` (#1053) | | 2 | inside a tool call's arguments | tool card appears, arguments stay "(being written)", status ends **Not run**, tool never executes | no | | 3 | inside answer content | answer stops mid-sentence, often right after an inline code span | cannot be, in general | All three report `finish_reason: "stop"` and `cancel=False`, which is the common defect: **nothing in the response distinguishes "the model finished" from "the model stopped early"**, and cases 2 and 3 produce no log line at all. **The number I'd most like the maintainers to look at**: the #1053 recovery fired twice in ~1 hour of normal use (`the reply ended inside its thinking with no answer`). A healthy model should not be EOS-ing inside its own reasoning twice an hour. So I suspect the root cause is below the HTTP layer — model/numerics/sampling — and the three symptoms above are just where that lands. ## Case 1 — EOS inside the thinking (confirmed, and it has a fix) Journal, twice (20:26:22, 20:27:04 in one session): [strata] the reply ended inside its thinking with no answer: closing the thinking once and continuing (reasoning_close_retry) …followed by a correct tool call / answer in the same round. Two things this proves: the behaviour is real on this model, and `reasoning_close_retry` works as documented. Before enabling it the same rounds simply returned the reasoning text with an empty answer. ## Case 2 — EOS inside a tool call ("Not run") Chain, as far as I can read it: 1. generation loop stops on the token: `if t in self.stop_ids: … finish = "stop"; raw_ids.append(t); break` 2. `OutputParser.finish()` declines to emit the half-written call — its docstring: an already announced call *"stays unfinished: its JSON is not closed and no `tool_call` follows it, #211"* 3. so no `tool_call` event exists → the tool-execution entry points (`ev.kind == "tool_call"`) are never reached → **MCP is not involved anywhere in this path** (a real MCP-side failure logs `tool <name>: error, …`; this logs nothing, which is how I finally separated them) 4. the request runs with `stream_tools=True`, so `tool_start` was already sent when the *name* was decoded — the client is left holding a card it then sweeps: `for (const t of m.tools || []) if (t.state === "writing" || …) { t.state = "skipped"; … }` Refusing to execute truncated arguments is right; my objection is that the turn is silently dead and unmeasurable. Note: some truncated shapes *are* recovered. In a harness test a call cut after a complete `</function>` still arrived as a normal `tool_calls` (the native `function_done` / `tool_args_repaired` path), so what reaches "Not run" is what that path can't close. ## Case 3 — EOS inside answer content The answer just ends mid-sentence. The user's observation, repeatedly: it stops **right after an inline code span**. I tested the obvious theory (a stop word) and it is wrong — see below. I am reporting the pattern, not a cause. ## Analysis process (mostly things I ruled out) - **Stop word / `stop` parameter** — refuted. Direct SSE request whose text contained backticks, thinking on and off: full text arrived, `finish_reason: stop`. Also `stop_strings()` only applies when the *client* sends `stop`; our config sends none, and `StopMatcher` is not in play. - **`OutputParser` withholding text around backticks** — refuted by unit test: text with paired and unpaired backticks, chunked at 5 chars, `thinking` both ways → zero loss, `buf` empty at `finish()`. - **the web client's read loop** — clean; no early `break`, and raw SSE replay in the same browser arrives complete. - **code-fence rendering swallowing text** — *I published this as the root cause and it was wrong.* My node harness measured the wrong object; the real `codeBlock()` renders an unterminated block normally. Worth naming because it is a tempting false positive. - **a second client on the socket** — 8080 binds 127.0.0.1 only, one ESTAB connection (an ssh tunnel). One user, one browser page. - **server errors / OOM / load** — journal for every affected round is `done: N tokens in T s (stop, cancel=False)`, no exception, no `cancel=True`. - **one confounder I created myself**: the single-chat store writes to `localStorage`, and once the chat passes the ~5 MB quota `setItem` throws and the page swallows it — so after a reload the restored history is the last version that fitted. That looks exactly like a truncated answer. Fixed locally (try progressively smaller shapes, then say so), but flagging it because it will bite anyone with a long chat and it muddies exactly this investigation. ## Hypotheses for the early EOS, with a knob each Ordered by how cheap they are to falsify. All untested. 1. **Speculative decoding.** Our `usage` blocks report real draft activity (`predicted_n: 136, draft_n: 114, draft_n_accepted: 96`). If a draft can be accepted across a position where the target would not have emitted EOS, early termination is exactly the symptom. Knob: disable speculative decoding and re-run the same session. 2. **gfx1151 numeric defaults on this machine.** The engine log says `HC_Q8` (8-bit hyper-connection projections used on the *verify read*) is on by default for gfx1151, plus "19 exact speed switches on by default", and states output is no longer bit-identical. If EOS logits shift slightly under verify-path quantisation, an early stop is a plausible first-order effect, and it would explain why this is much more visible here than in CI. Knob: `STRATA_HC_Q8=0`, and `STRATA_GFX1151_DEFAULTS=0` as a bisect. 3. **Tokenizer special-token adjacency / the tool-call grammar in the chat template.** EOS concentrate in the structured regions (inside ` think`, inside `<tool_call>`), which is where the template's grammar decides "this turn is over". Knob: replay one failing prompt through the template with a different model card, or dump the logits at the cut position. 4. **The checkpoint itself** (a local quant): least interesting for upstream, but if 1–3 are clean then this is a model-quality report, not a server one. The deliberate probe I could run — 12 completions forced to emit four inline code spans each — ended at a backtick 1/12 times. So inline code is a **correlate, not a cause**; anyone writing "backticks stop the model" will chase nothing. ## What I'd like 1. **Case 2, a retry mirroring #1053**: when the loop ends with `finish == "stop"` and the parser is in a call state and *nothing visible has been streamed yet*, drop the half-call out of `prompt + seg` and write the turn once. The "nothing visible yet" guard is what keeps it from repeating text on the wire. Prefix-cache reuse should make it cheap. (I tried the obvious alternative — continue *from* the half-call as an assistant prefix — 6/6 times the model narrated "the command ran, output: `CONT_OK`" instead of closing the call, because in the history the command already looks executed. So it has to be without the cut call.) 2. **A counter and a log line** for cases 2 and 3, e.g. `strata_truncated_tool_calls` next to `strata_rejected_tool_calls`, and a `/metrics` counter. Case 3's only current symptom is an *absent* log line, which is why this took so long to attribute. 3. **For case 3, at minimum a distinguishable `finish_reason`** (or a flag) so a client can render "incomplete" instead of "the model had a short answer". I know nothing general can tell "finished" from "cut" mid-content — that's why I'm asking for signal, not for a heal. ## Honest limits of this report Verified: case 1 (server's own log line, twice); that case 2 bypasses MCP entirely; that #1053 works; the ruled-out list above. **Not** verified: the `parser.state` at a real case-2 cut (no log field records it), any trustworthy frequency for cases 2–3 (every journal-side counting method I tried is biased — the last progress line of a *successful* call round also reads `writing a tool call`), and any of the four hypotheses. Happy to run a bisect on 1 and 2 — with this session length, a difference shows up within an hour.
Author
Owner

@github-actions[bot] commented on GitHub (Nov 3, 2026):

Thanks for the issue. To keep the tracker readable, every item needs an area prefix in the title and the parts of the issue form filled in. This one is missing:

  • Start the title with its area: [Engine], [GUI], [TUI], [Benchmark], [Docs] or [Other], then a short description. Example: "[Engine] decode stops after 2 minutes".
  • Add your graphics card with its VRAM, your RAM and your operating system.

Edit the issue (title and description) and this note goes away on its own. If it is still missing parts in 5 days it will be closed, which is not a rejection: fix it and comment /reopen.

Details: CONTRIBUTING.md

<!-- gh-comment-id:6604904973 --> @github-actions[bot] commented on GitHub (Nov 3, 2026): Thanks for the issue. To keep the tracker readable, every item needs an area prefix in the title and the parts of the issue form filled in. This one is missing: - [ ] Start the title with its area: [Engine], [GUI], [TUI], [Benchmark], [Docs] or [Other], then a short description. Example: "[Engine] decode stops after 2 minutes". - [ ] Add your graphics card with its VRAM, your RAM and your operating system. Edit the issue (title and description) and this note goes away on its own. If it is still missing parts in 5 days it will be closed, which is not a rejection: fix it and comment `/reopen`. Details: [CONTRIBUTING.md](https://github.com/Niko1221/Strata/blob/main/CONTRIBUTING.md)
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#2388
No description provided.