mirror of
https://github.com/Niko1221/Strata.git
synced 2026-12-03 19:03:30 +07:00
[PR #5040] [CLOSED] [Engine] tool parser: streamed arguments keep a file that lists the closing tags #5295
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#5295
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/5040
Author: @Tsury
Created: 11/3/2026
Status: ❌ Closed
Base:
main← Head:fix-4701-stream📝 Commits (1)
854c07cfix(parser): streamed arguments keep a file that lists the closing tags📊 Changes
2 files changed (+15 additions, -2 deletions)
View changed files
📝
serve/frontend.py(+6 -2)📝
serve/test_tool_corpus.py(+9 -0)📄 Description
Problem and result
v0.2.10 fixed #4701 for the final
tool_callevent, but not for the streamed arguments. On a stream, a client builds a call from thetool_argsdeltas, so it still gets the cut file.Before this change, on v0.2.10 (commit
ffa80d73), awrite_filecall whose content lists the three closing tags, fed toOutputParser(stream_tools=True):contenttool_call# Tool calls\n\nThe closing tags, in order:\n# Tool calls\n\nThe closing tags, in order:\nSo the streamed JSON and the final call differ, and only when text arrives in small pieces, which is what a running engine sends. Chat Completions yields
tool_argsas deltas and only records the finaltool_callinfinished, so the client never sees the whole value. The Anthropic route also emitstool_argsas deltas.After this change, the streamed arguments equal the final call at every chunk size.
Related discussion
Follows #4701. My earlier #4762 was closed in favour of the fix that shipped.
Approach
_close_verdictreturned"end"whenafterheld</function>and</tool_call>had not arrived yet._scanthen committed the value, so the later text could not change the verdict.call_endsaw the whole sequence later, which is why the final call stayed right._close_verdictnow returns"hold"when what follows</function>is empty or a prefix of</tool_call>, unless the output has ended.rawstate would leave a typed value unclosed when the call body is cut at its known end. The body's end is confirmed at that point, so that one_scanruns with_finalset.dsml-typed-argumentsandtest_reasoning_then_two_callsfailed without this part.No change for a value with no closing tags in it: the hold lasts until
</tool_call>arrives.Validation
Passed:
python -m unittest discover -s serve -t . -p 'test_*.py'on this branch (v0.2.10 + this commit), Linux, Python 3.12,MockEngine: 1385 tests, 17 skipped, no failures.4701-*cases added toserve/test_tool_corpus.pyrun whole, in pieces of 1, 3 and 7, and cut in two at every byte, with and withoutstream_tools. Two of the four cases pin neighbouring behaviour: text after a whole call, and two calls with text between.Failed:
serve/frontend.pychange,test_every_specimen_whole_and_in_piecesandtest_every_specimen_cut_in_two_at_every_bytefail on4701-closing-tags-in-a-file, as the table shows.Not run:
Limits
The hold only covers
</function>followed by a partial</tool_call>. A value cut by the token limit behaves as before.🤖 Generated with Claude Code
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.