mirror of
https://github.com/Niko1221/Strata.git
synced 2026-12-03 19:03:30 +07:00
[PR #525] [CLOSED] serve: rescue a tool call stranded in an unclosed thinking span #2676
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#2676
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/525
Author: @chimpera
Created: 10/2/2026
Status: ❌ Closed
Base:
main← Head:fix/tool-call-opens-inside-thinking📝 Commits (10+)
d8d4ad3Merge branch 'f-135-eng' into rel-0.1.357b600d5Merge branch 'f-135-small' into rel-0.1.35d9ab843Engine 0.1.35: Windows AMD uses its bundled HIP runtime (#468 #461), the low-RAM resident mode on Windows 32 GB PCs (#467), fixes #460 #459 #446 #447 #457 #448 #444; setup requires it57bd713sycl: pipeline the expert cache's profile fill (model load 3-4x faster)e3bdd74A prompt cancelled mid-read is logged and recorded with the tokens it read (#471)f2aaba1"The draft head does not fit" says what to change (#474)64987c8UPDATE.bat / update.sh: update Strata without starting the model (#475)6d0e648Opt-in: keep what the expert cache learned across restarts (--expert-profile-save, #477)5ccf3a7Engine 0.1.36: a cancelled prompt logged as read so far (#471), the draft-head hint (#474), UPDATE.bat (#475), --expert-profile-save (#477); setup requires itb750bbc#136: fused int8 tensor-core experts for the Q2_0 pack's prompt path, grouped on the GPU (opt-in STRATA_PF_FUSED=1)📊 Changes
6 files changed (+334 additions, -294 deletions)
View changed files
📝
docs/DETAILS.md(+4 -1)📝
serve/fixtures/format_fix_specimens.json(+246 -163)➖
serve/fixtures/stranded_tool_call_failures.json(+0 -33)📝
serve/frontend.py(+38 -23)📝
serve/server.py(+3 -0)📝
serve/test_server.py(+43 -74)📄 Description
Some chat templates render a tool call right after the reasoning block without ever emitting
</think>before it. The whole call then streams out asreasoning_content, and a client that runs tools from the content channel ends its turn with nothing to execute — seen live as agents stopping silently mid-task (transcript: thinking-only message,end_turn, thinking text ends with a complete<tool_call>block).The rescue is deliberately conservative: during generation the parser behaves exactly as before (no divert, nothing withheld). It keeps the reasoning text from the first
<tool_call>opener aside; a</think>after the opener clears it — a valid quoted call example inside a closed thinking span is a mention, not an act, and is never fired as a call. Only at end of generation, in a span that never closed, is the kept tail delivered astool_callevents, and only when every complete block parses against the request's tool schemas. Malformed or unfinished bodies stay reasoning; a reply cut by max tokens mid-call is untouched (#530 already names that case).Deferred rather than opt-in: a rescued call is by construction at the very end of the reply (the span never closed and generation ended), so nothing is delayed in practice — the only thing given up is
stream_toolsprogressive args for rescued calls, which arrive whole at end of stream.Tests: the live stranded shape (chunked at 1/7/10k ×
stream_toolson/off), a valid quoted example in a closed span (the review's false positive — the first version of this fix fired it as a real call), a stranded call with trailing thought, two stranded calls, a malformed mention in an unclosed span,</think>-before-opener, an unfinished call, and the content-channel path.🤖 Generated with Claude Code
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.