mirror of
https://github.com/Niko1221/Strata.git
synced 2026-12-03 19:03:30 +07:00
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#2939
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?
📋 Pull Request Information
Original PR: https://github.com/Niko1221/Strata/pull/970
Author: @talisp
Created: 10/5/2026
Status: ❌ Closed
Base:
main← Head:f-141-pr-toolcall-think📝 Commits (2)
f7b1781serve: a tool call written inside the thinking ends it implicitly3a08220serve: the template closes the thinking before a call left inside it📊 Changes
5 files changed (+333 additions, -6 deletions)
View changed files
📝
serve/chat_template.jinja(+14 -0)➕
serve/fixtures/casos_tool_call_raciocinio.json(+38 -0)📝
serve/frontend.py(+63 -4)📝
serve/server.py(+9 -2)➕
serve/test_reasoning_toolcall.py(+209 -0)📄 Description
Fixes #804.
What
Qwen3.8-Flash-Next sometimes writes a complete tool call inside the thinking, without
</think>first (4 of ~1,050 Hermes Agent replies here).OutputParseronly left the"reasoning"state on</think>, so the call ended up inreasoning_content: notool_calls,finish_reason=stop, and the agent stopped.Like vLLM's Qwen3 parser (PR vllm-project/vllm#35687, where
<tool_call>in the reasoning is an implicit end of it), a generated call now ends the thinking. Unlike vLLM, which fires on any<tool_call>, it fires only on a real call, so quoted markup stays reasoning. All three must hold:<tool_call>at the start of a line (right after\n, or as the very first text of the thinking);<function=(the same rule #700 uses in the content state).The text before it stays
reasoning_content, and the call goes through the normal"call"state. While the text after the tag is still whitespace or a prefix of<function=, it is held back, so streamed and whole outputs are identical (with and withoutstream_tools). An implicit call that never completes is returned as reasoning, as before.Each one is logged (
[strata] implicit end of thinking: ...) and counted inGET /metrics(totals.implicit_reasoning_ends, plus a per-request field), so it can be watched per model and quant.Complementary to #700 / #966: those handle drift after
</think>(content state); this handles the call that never left the reasoning state.Second commit (defense in depth, template)
When the history is rendered,
serve/chat_template.jinjacloses</think>before such a call left in an earlier assistant turn. This applies whencontentstarts with an open<think>and has a line-start<tool_call>\n<function=, or when there are notool_callsandreasoning_contentends with such a call. The model is then never shown a call inside<think>as an example. All 10chat_golden.jsoncases render byte-identical (now checked by a test). Note: the server reads the template from the pack'stokenizer/, so this part reaches users only when packs are rebuilt. It can be dropped from this PR if you prefer.Tests
serve/test_reasoning_toolcall.py, 12 tests:The 4 recorded failures (
serve/fixtures/): each gives exactly 1tool_call, with the reasoning before it kept. Checked fed 1 character at a time, in random chunks and whole, withstream_toolson and off. All 4 give 0 calls onmain.10 mention-only controls, none of which give a call:
<function=;>quote;</think>.They also stay correct when followed by
</think>and a real call.Server-level:
finish_reason=tool_calls, the log line, and the/metricscounter.Template:
chat_golden.jsonmatches 10/10, and both history repairs are covered.Full
serve/test_*.pyon this branch: 280 run, 9 skipped. 1 error,test_responses.OverHttp.test_json_schema_text_format, fails the same way on plainmainwhenjsonschemais not installed (the other jsonschema tests skip in that case; this one does not).In production
This has been running here since 2026-10-04 (Linux, L40S vGPU, Hermes Agent over the OpenAI API): first on IQ3_S / 0.1.38, and since today on UD-IQ4_XS / 0.1.39 with images on. It recovered 2 real cases that previously stopped the agent, with no regressions seen.
🤖 Generated with Claude Code
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.