mirror of
https://github.com/Niko1221/Strata.git
synced 2026-12-03 19:03:30 +07:00
[PR #523] [CLOSED] serve: a tool call that opens inside thinking is an implicit think end #2673
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#2673
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/523
Author: @chimpera
Created: 10/2/2026
Status: ❌ Closed
Base:
main← Head:fix/tool-call-opens-inside-thinking📝 Commits (1)
f321b94serve: a tool call that opens inside thinking is an implicit think end📊 Changes
2 files changed (+96 additions, -7 deletions)
View changed files
📝
serve/frontend.py(+35 -7)📝
serve/test_server.py(+61 -0)📄 Description
The problem
The chat template opens
<think>in the prompt, but only the model can close it. When the model goes from its reasoning straight to a tool call, it sometimes never emits</think>— so the entire tool call stays inside the thinking span, andOutputParserchannels it all asreasoning.Through the OpenAI API surface that means the call arrives as
reasoning_content: a client that runs tools from the content channel sees a thinking-only message withfinish_reason: stopand nothing to execute. Observed live on a Qwen3.8-Flash-Next deployment: agents stopping silently mid-task; the transcript showsend_turnmessages whose reasoning tail contains a complete, well-formed<tool_call>block (2 occurrences in one overnight session).The fix
An
OutputParserin thereasoningstate that finds<tool_call>treats it as an implicit think end:CALL_STARTtoo, so an opener split across deltas is not leaked as thinking),</think>still wins when it comes first; nothing changes for well-formed output.Two guards keep false positives harmless:
call_from_reasoning) instead of raising — the historical content-span behavior of failing the stream is untouched,finish()is still never reported as a whole call.Tests
ReasoningToolCallinserve/test_server.py: the opener-inside-thinking case (across chunk steps 1/7/10000 and bothstream_toolssettings),</think>-before-opener precedence, the malformed-mention fallback, and the unfinished-call case. Full suite: 104 tests OK (python -m unittest serve.test_server).🤖 Generated with Claude Code
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.