[GH-ISSUE #5105] Tool calls cut by an end-of-turn token render as "Not run" and execute nothing #2384

Closed
opened 2026-11-04 01:58:52 +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/5105

Tool calls cut by an end-of-turn token render as "Not run" and execute nothing

(HTTP 200, finish_reason: "stop", no log line)

Environment

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

What the user sees

Mid tool-use, a round produces a tool card whose arguments never fill in (the argument area stays at
"(being written)") and whose status ends as Not run. The tool never executes, the assistant's visible text
is empty, and the turn is over — the user has to re-send. Nothing about the response looks like a failure:
HTTP 200, finish_reason: "stop", no error chunk, and the journal for that round ends at
done: 625 tokens in 25 s (stop, cancel=False).

This is hard to tell apart from an MCP/bash fault from the outside; an actual MCP-side failure does log
tool <name>: error, …, and this one logs nothing at all, because the tool is never reached.

Where it happens

The turn ends because the model emits an end-of-turn token while still inside a tool call, and the generation
loop stops on it:

if t in self.stop_ids:
    ...
    finish = "stop"
    raw_ids.append(t)
    break

OutputParser.finish() then refuses to emit the half-written call, and says so in its own docstring: an
already-announced call "stays unfinished: its JSON is not closed and no tool_call follows it, #211". So no
tool_call event exists, and the server's tool-execution entry points (ev.kind == "tool_call") are never
reached — MCP is not involved anywhere in this path.

Meanwhile the request runs with stream_tools=True, so tool_start was already sent the moment the tool name
was decoded. The web app is left holding a card in writing, which it sweeps at stream end:

for (const t of m.tools || []) if (t.state === "writing" || t.state === "running") { t.state = "skipped"; ... }

That sweep is the "Not run". To be clear: I think refusing to execute a call with truncated arguments is
correct — running half a command is worse. My complaint is that the resulting turn is silently dead: the
client cannot distinguish "the model decided to stop" from "the harness lost a call", and there is no log line
or counter to measure it. Some truncated shapes are recovered natively (the tool_args_repaired /
function_done streaming path — I verified that a call cut after a complete </function> still lands as a
normal tool_calls); what reaches "Not run" are the shapes that path cannot close.

What I have and have not verified

Verified: the finish_reason / event behaviour above; that the cut is not a stop-word and not the client's
reading loop (raw SSE replays arrive complete); and that reasoning_close_retry (#1053) fires on this model —
the reply ended inside its thinking appeared twice in ~1 h of normal use and those rounds continued correctly.

Not verified, and I'd rather flag it than assert it:

  • The parser.state at the cut for a real "Not run" (call vs rcall). The journal doesn't record it, so the
    trigger condition in fix 1 below is inference from the finish() docstring, not an observation.
  • The frequency. Every way I tried to count it from the journal was biased — the last progress line of a
    successful call round also reads writing a tool call — so I have no trustworthy rate, which is itself part
    of the problem.
  • I have not pinned one single confirmed instance end-to-end; I'm reporting the shape, not a measurement.

Possible fixes

  1. Write the turn once more with the cut call dropped from the prompt — the #1053 mechanism, a different
    trigger. When the loop ends with finish == "stop", parser.state is a call state, nothing visible has been
    streamed yet, and no retry has happened: strip the half-call out of prompt + seg, log it once, continue.
    Prefix-cache reuse should make this cheap. The "nothing visible sent yet" guard matters — retrying after
    content was streamed would repeat text on the wire.
  2. A machine-readable signal when it is not retried: e.g. strata_truncated_tool_calls alongside
    strata_rejected_tool_calls, plus a /metrics counter. Even if you decide a retry is wrong, this makes the
    event measurable and lets a client label the round differently than a user cancellation.
  3. If you consider the current behaviour correct by design, a one-line log would still help: right now the only
    symptom is an absent tool line, which took me a long time to even attribute to this code path.

One data point against the obvious fix: I tried continuing from the half-call as an assistant prefix — 6/6
times the model narrated a finished command ("the command ran, output: CONT_OK") instead of closing the call,
because in the history the command looks already executed. So a retry has to be without the cut call (fix 1),
not after it.

Workaround we're running: "reasoning_close_retry": true removes the sibling case (EOS inside think).
The tool-call case falls outside that branch's conditions, so it remains.

Happy to test patches or a counter build against this model — the round volume here makes it easy to spot.

Originally created by @Freedominmyheart on GitHub (Nov 3, 2026). Original GitHub issue: https://github.com/Niko1221/Strata/issues/5105 ### Tool calls cut by an end-of-turn token render as "Not run" and execute nothing (HTTP 200, `finish_reason: "stop"`, no log line) **Environment** - strata 0.2.9, engine binary 0.1.55 (`BUILD.json`, built locally for gfx1151 / ROCm 7.14) - model `qwen3.8-flash-next-unsloth-ud-iq4_xs` - client: the bundled web app (`serve/web`), `stream: true`, 6 MCP servers / 49 namespaced tools **What the user sees** Mid tool-use, a round produces a tool card whose arguments never fill in (the argument area stays at "(being written)") and whose status ends as **Not run**. The tool never executes, the assistant's visible text is empty, and the turn is over — the user has to re-send. Nothing about the response looks like a failure: HTTP 200, `finish_reason: "stop"`, no `error` chunk, and the journal for that round ends at `done: 625 tokens in 25 s (stop, cancel=False)`. This is hard to tell apart from an MCP/bash fault from the outside; an actual MCP-side failure does log `tool <name>: error, …`, and this one logs nothing at all, because the tool is never reached. **Where it happens** The turn ends because the model emits an end-of-turn token while still inside a tool call, and the generation loop stops on it: if t in self.stop_ids: ... finish = "stop" raw_ids.append(t) break `OutputParser.finish()` then refuses to emit the half-written call, and says so in its own docstring: an already-announced call "stays unfinished: its JSON is not closed and no `tool_call` follows it, #211". So no `tool_call` event exists, and the server's tool-execution entry points (`ev.kind == "tool_call"`) are never reached — **MCP is not involved anywhere in this path**. Meanwhile the request runs with `stream_tools=True`, so `tool_start` was already sent the moment the tool *name* was decoded. The web app is left holding a card in `writing`, which it sweeps at stream end: for (const t of m.tools || []) if (t.state === "writing" || t.state === "running") { t.state = "skipped"; ... } That sweep is the "Not run". To be clear: I think refusing to execute a call with truncated arguments is correct — running half a command is worse. My complaint is that the resulting turn is *silently* dead: the client cannot distinguish "the model decided to stop" from "the harness lost a call", and there is no log line or counter to measure it. Some truncated shapes *are* recovered natively (the `tool_args_repaired` / `function_done` streaming path — I verified that a call cut after a complete `</function>` still lands as a normal `tool_calls`); what reaches "Not run" are the shapes that path cannot close. **What I have and have not verified** Verified: the `finish_reason` / event behaviour above; that the cut is not a stop-word and not the client's reading loop (raw SSE replays arrive complete); and that `reasoning_close_retry` (#1053) fires on this model — `the reply ended inside its thinking` appeared twice in ~1 h of normal use and those rounds continued correctly. Not verified, and I'd rather flag it than assert it: - The `parser.state` at the cut for a real "Not run" (`call` vs `rcall`). The journal doesn't record it, so the trigger condition in fix 1 below is inference from the `finish()` docstring, not an observation. - The frequency. Every way I tried to count it from the journal was biased — the last progress line of a *successful* call round also reads `writing a tool call` — so I have no trustworthy rate, which is itself part of the problem. - I have not pinned one single confirmed instance end-to-end; I'm reporting the shape, not a measurement. **Possible fixes** 1. **Write the turn once more with the cut call dropped from the prompt** — the #1053 mechanism, a different trigger. When the loop ends with `finish == "stop"`, `parser.state` is a call state, nothing visible has been streamed yet, and no retry has happened: strip the half-call out of `prompt + seg`, log it once, continue. Prefix-cache reuse should make this cheap. The "nothing visible sent yet" guard matters — retrying after content was streamed would repeat text on the wire. 2. **A machine-readable signal when it is not retried**: e.g. `strata_truncated_tool_calls` alongside `strata_rejected_tool_calls`, plus a `/metrics` counter. Even if you decide a retry is wrong, this makes the event measurable and lets a client label the round differently than a user cancellation. 3. If you consider the current behaviour correct by design, a one-line log would still help: right now the only symptom is an absent `tool` line, which took me a long time to even attribute to this code path. One data point against the obvious fix: I tried *continuing* from the half-call as an assistant prefix — 6/6 times the model narrated a finished command ("the command ran, output: `CONT_OK`") instead of closing the call, because in the history the command looks already executed. So a retry has to be *without* the cut call (fix 1), not after it. **Workaround we're running**: `"reasoning_close_retry": true` removes the sibling case (EOS inside ` think`). The tool-call case falls outside that branch's conditions, so it remains. Happy to test patches or a counter build against this model — the round volume here makes it easy to spot.
bsakaguchi 2026-11-04 01:58:52 +07:00
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:6604647568 --> @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#2384
No description provided.