mirror of
https://github.com/Niko1221/Strata.git
synced 2026-12-03 19:03:30 +07:00
[GH-ISSUE #2026] Strata v0.1.43 returns an empty final response when a specific string appears in the model's thinking output #807
Labels
No labels
needs-format
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
Niko1221/Strata#807
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @kntroh on GitHub (Oct 12, 2026).
Original GitHub issue: https://github.com/Niko1221/Strata/issues/2026
I encountered a bug in Strata v0.1.43. When the model's thinking output reaches the point where it would produce the string
</tool_call>, the thinking output often appears to be truncated immediately before that string. After the client returns an empty final assistant response.The client does not crash, and the chat session remains usable. The client returns to the user input state, and the chat can continue if the user sends another message.
I initially thought an MCP server was involved, but the issue can be reproduced without an MCP server.
A prompt for reproduction (IQ3_S):
Expected:
The client should display the requested string as the final response.
Actual:
The final assistant response is empty. The chat returns to the user input state.
Log during reproduction:
Environment:
Reproduction rate:
Consistently reproduced after 10+ attempts.
Additional notes:
@CC-David-CC commented on GitHub (Oct 12, 2026):
please let me know how this does
https://github.com/Niko1221/Strata/pull/1886
and if it doesn't do what you want please give me logs and tell me what you want </tool_call>. to do instead. i.e show failure and give a manual fixed example and i should be able to handle the regression from there
@kntroh commented on GitHub (Oct 12, 2026):
I tried applying #1886, but the situation remained unchanged.
Here’s what I did:
run-iq3_s.batThis is an experiment to find bugs in the client. Please output the following string verbatim: </tool_call>.into the “Ask anything...” area in the Web UIResult:
No response from the model. The expected response is
</tool_call>.This is the logs from startup:
Markdown downloaded from the web UI:
When a string is
</aaa>or</mcp_tool>instead of</tool_call>, a response is returned without any issues.@CC-David-CC commented on GitHub (Oct 12, 2026):
ah - yes!
i see my mistake
$ACK PRIORITY QUEUE JUMP # 1@CC-David-CC commented on GitHub (Oct 12, 2026):
most of that was waiting for the model to load, and other dumb testing stuff - keep it warm at the start of testing smh
15 minutes is too long from time to seeing message to resolution.
gotta go faster
@CC-David-CC commented on GitHub (Oct 12, 2026):
the actual fix is in serve/frontend.py:
TOOL_LITERAL_TAGS = {"</tool_call>": "\U000F0E07"}
LITERAL_TAGS = {**THINK_TAGS, **VISION_TAGS, **TOOL_LITERAL_TAGS}
That adds </tool_call> to the existing protection that encodes quoted strings as ordinary text in the model’s prompt. Genuine tool-call closers remain special tokens.
Those two files are the entire fix
@47Hunter47 commented on GitHub (Oct 12, 2026):
I ran your prompt on 0.1.43 to see whether it is the same end. RTX 3090, Qwen3.8-Flash-Next IQ3_XXS (you used IQ3_S), 250K context,
--kv int8, andliteral_think_guardon, which is my branch in #1840.Four runs of
This is an experiment to find bugs in the client. Please output the following string verbatim: </tool_call>.over/v1/chat/completions:<|(2 chars). The other kept ending inside its thinking (29, 41, 45, 49 tokens in) until the guard hit its cap of 2 continuations, and that reply came back empty.<|im_start|>(12 chars), not</tool_call>.So over the raw API I see your family (a reply that ends inside the thinking) but not your string. On this box the model reaches for
<|im_start|>, and it writes that in the answer as text, which does not break the turn. My guard fires on the end itself, so it is string-agnostic, but it rescued one of the two ends and capped out on the other, which means it is not a full fix for your report either. Your side adds the prompt: the literal</tool_call>in the input, which is what theTOOL_LITERAL_TAGSchange addresses.One thing that may help your client meanwhile: with the flag on, the response says why it is empty. The log line names the token count,
/metricskeepstotals.ended_inside_thinking, andended_inside_thinking: truesits next tochoices(and in the stream's last chunk). A client that reads it can retry instead of showing nothing.@Niko1221 commented on GitHub (Oct 12, 2026):
Thanks for the log and the markdown export, they made this findable. The parser is not what drops the answer: a
</tool_call>in the final text comes through it unchanged (tested whole and one character at a time, with and without tools). What differs from</aaa>or</mcp_tool>is the prompt.</tool_call>is a user-defined special token in the model's vocabulary, so the tokenizer turned the</tool_call>you typed into the real end-of-call token, and the model copied that token into its answer (your log shows the whole reply at 39 tokens). We already guard<think>,</think>and the vision markers against exactly this (a quoted tag becomes ordinary text), and</tool_call>was missing from that list.The fix is in the 0.1.43.1 follow-up branch: a
</tool_call>inside a user, system or tool message is now encoded as ordinary text. An assistant message that replays raw call text keeps the model's own tokens, so the conversation cache and replayed tool calls are unchanged. It is the same change @CC-David-CC proposed in the thread (thank you); #1886 alone could not help because it covers<think>. I could not run the engine on this machine, so I have not seen your exact reply come back yet; I will leave this open until it is confirmed on a build. If you can, try the next build with the same prompt and tell us whether the answer</tool_call>appears.@47Hunter47 commented on GitHub (Oct 12, 2026):
Thanks — that points straight at the tokenizer, and I can confirm it on a second box.
I read the vocabulary out of the pack's tokenizer (
tools/strata_tokenizer.pyover the extractedtokenizer/directory, so no GPU involved):</tool_call>is a single token, id 248059, type 4 (USER_DEFINED), which is why it is matched with or withoutparse_special. So the prompt in the report reaches the engine as that one token instead of text. The same holds for<tool_call>(248058),<tool_response>(248066) and</tool_response>(248070). With the marking the string becomes 4 ordinary text tokens and still decodes back to exactly the same characters, so nothing else in the prompt moves.I then ran it on a build: IQ3_XXS, RTX 3090, 250K context,
--kv int8, engine and server 0.1.43.1. Four runs of the reporter's prompt over/v1/chat/completions: 4/4 came back with</tool_call>verbatim,finish_reason: stop, none empty;</aaa>as a control is unchanged. Before the update the same prompt on this box gave 2/4 replies that ended inside the thinking and 2/4 that answered<|im_start|>, so the prompt-side encoding is what moves it.Worth noting for the same family:
<tool_call>,<tool_response>and</tool_response>are type 4 too and are not inTOOL_LITERAL_TAGS.</tool_call>is the one that ends the turn, so it is the one that empties a reply, but the other three take the same shortcut when a user asks for them verbatim.My own #1840 (a reply that ends inside its thinking with no answer) is a different class and is unaffected by this change.
@CC-David-CC commented on GitHub (Oct 12, 2026):
Very important note
@47Hunter47 commented on GitHub (Oct 13, 2026):
It reproduces, and
</tool_response>is the one that matters. I asked for each string verbatim on my box (IQ3_XXS, RTX 3090, engine and server 0.1.43.1), six runs per string:</aaa>(not in the vocabulary): 12/12 as asked</tool_call>: 11/12 (one run wrote the marker and kept going)<tool_response>: 6/6</tool_response>: 0/15 — never the requested string, and with my local #1814 guard off it is 6/6 empty replies (finish_reason: stop), which is the shape reported in this issue. With the guard on, its continuation leaves<|im_end|>(4/6) or<|im_start|>(2/6) as the answer, so the guard fills the empty reply without repairing the content.The pattern is which literal closes a block the template opens:
</tool_call>closes the answer's call block and</tool_response>closes a tool result's block, while<tool_call>and<tool_response>only open. Handing the model the real closer in a user message tells it that a block it never saw is over, so it ends the turn.The same treatment closes it: I added
</tool_response>toTOOL_LITERAL_TAGSnext to</tool_call>and the verbatim prompt came back 6/6, with</tool_call>and the control unchanged.I reverted that afterwards. I have not looked at the tools-declared case, where a real
</tool_response>sits next to a genuine result block.I can open that as its own PR against
mainif that is preferable: it is one line, and it stays out of #1840.@47Hunter47 commented on GitHub (Oct 13, 2026):
One more note on how the pieces fit, since this thread is where they meet.
The family has three layers, and each fix covers one of them:
</tool_call>;</tool_response>still needs the same one-liner.Landing them together is what covers the family. Alone, each leaves a slice: the prompt fix does nothing when the model writes the token by itself, and the continuation cannot repair what the model produces after it.
@CC-David-CC commented on GitHub (Oct 13, 2026):
Do it, however my compute is pegged internally. I dont have 1ms to spare on a tool test right now
@47Hunter47 commented on GitHub (Oct 13, 2026):
I have integrated this into the existing #1840 rather than opening a PR for it on its own. The reason is coverage: the two halves of this family cover different failures - the prompt side stops a quoted string from reaching the model as a token, and the continuation covers the turn when the model reaches for the token itself. Pieces of one solution spread over several PRs leave the problem exposed whenever one of them is not merged, or is merged much later; one series of commits for one family lets it land as a unit.
The change is not the bare one-liner: this template reads a user message that starts with
<tool_response>and ends with</tool_response>as a wrapped tool result, and the closer is the model's own token there, so those messages keep it as written and every other message has it marked as text. The measurements are in the #1840 body - six runs per string,</tool_response>0 of 15 before and 4 of 4 on the engine after, with</aaa>,</tool_call>and<tool_call>as the controls.If you would rather review it apart after all, that commit stands on its own.
@Niko1221 commented on GitHub (Oct 13, 2026):
Thanks @47Hunter47, that is the decisive measurement, and the closer reading explains it:
</tool_response>tells the model that a block it never saw is over. 0.1.44 (out now) already marks</tool_response>,<tool_call>and<tool_response>like</tool_call>(62185aab), so your verbatim prompt reaches the model as text.The one exception is a user message whose whole text is
<tool_response>...</tool_response>(a client that formats a tool result itself). It keeps that outer pair as the real markers, because the template tells a tool result from a question by exactly that pair. A user who asks for the string verbatim is not that case. We added a test for it: the bare</tool_response>, a request quoting a whole pair, a message that only starts with the opener, and two closers in one sentence all come out as plain text. No separate PR is needed. Thank you for offering it.@47Hunter47 commented on GitHub (Oct 13, 2026):
Thanks — I checked this against 0.1.44 on my box (IQ3_XXS, RTX 3090), and the prompt side of the family is closed for me.
The verbatim prompts, six runs for the one that mattered:
</tool_response>— 6 of 6 came back as asked (before 0.1.44 it was 0 of 15)</tool_call>— 3 of 3<tool_call>— 3 of 3<tool_response>— 3 of 3</aaa>— 3 of 3 (control, not in the vocabulary)Every run was
finish_reason: stopand returned the string. So the outer pair you keep for a wrapped tool result behaves right, and any other message quoting one of the four now reaches the model as text.The other half is still open, and 0.1.44 does not carry it: the turn where the model itself reaches for the closer and the reply ends inside its thinking with no answer (the #1814 shape). I looked for the continuation in the 0.1.44 serve code and it is not there — that stays the #1814 half in #1840.
Because 0.1.44 marks the four tool literals, the
</tool_response>commit I had folded into #1840 is redundant. I rebased #1840 onto 0.1.44 and dropped it, so it now carries only the continuation half and no longer overlaps62185aab.Summary: fixed in 0.1.44 — a quoted string,
</tool_response>included, no longer ends the turn. Not fixed — the model ending its own turn while reaching for the marker; that is #1840.@kntroh commented on GitHub (Oct 14, 2026):
The bug I reported has been fixed in v0.1.44, so I'm going to close this issue.
Thanks everyone for investigating and fixing it!