mirror of
https://github.com/Niko1221/Strata.git
synced 2026-12-03 19:03:30 +07:00
[PR #231] [CLOSED] fix(serve): report a tool call cut off by the end of the output as unfinished #2517
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#2517
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/231
Author: @alphastorm
Created: 9/30/2026
Status: ❌ Closed
Base:
main← Head:fix/211-unfinished-tool-call📝 Commits (1)
5325ba2fix(serve): report a tool call cut off by the end of the output as unfinished📊 Changes
4 files changed (+115 additions, -8 deletions)
View changed files
📝
serve/frontend.py(+4 -3)📝
serve/server.py(+12 -5)📝
serve/test_mcp.py(+13 -0)📝
serve/test_server.py(+86 -0)📄 Description
Fixes #211 (the second trigger of #210: the output ends inside a call).
When the model's output ended inside a tool call whose name had already streamed,
OutputParser.finish()closed its JSON with_close_scan()and emittedtool_call, and the answer ended withfinish_reason: "tool_calls"/stop_reason: "tool_use". A client could not tell the call was cut and ran it with truncated arguments. In the web app's chat, an unfinished MCP call ran with empty arguments.Change
frontend.py,finish(): an announced call that never reached</function>stays unfinished. Its JSON is not closed and notool_callfollows itstool_start. A call missing only its</tool_call>is still whole.server.py: the OpenAI and Anthropic streams say"tool_calls"/"tool_use"only when every streamed call got itstool_call; otherwise the engine's reason stands ("stop"/"end_turn").anthropic_collectleaves out atool_useblock whose input never closed, since it has no input to give. The MCP loop needs no change: the call is not run, and the web app already shows a started call as "Not run" when the answer ends."length"/"max_tokens"; the non-streamed Anthropic answer leaves out the cuttool_useblock, where it used to carry the truncated input.Tests (
python -m unittest serve.test_server serve.test_mcp serve.test_detok)UnfinishedToolCall: the parser (fed 1, 7 and all characters at a time), and the four API shapes for a cut call and, as a control, a whole call.ToolLoop.test_a_call_the_output_ends_inside_is_not_run.On
bbaaabb(0.1.28) the new tests fail (5 failures: the cut-call cases and the MCP case; the whole-call control passes). With the change the suite passes (72 tests, 3 skipped) on Python 3.13.15 and 3.14.7, macOS arm64 with the mock engine. No GPU or real model was run, and the web app was not opened.🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.