mirror of
https://github.com/Niko1221/Strata.git
synced 2026-12-03 19:03:30 +07:00
[PR #4762] [CLOSED] [Engine] tool parser: a closing sequence with text after it stays in the value #5169
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#5169
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/4762
Author: @Tsury
Created: 10/30/2026
Status: ❌ Closed
Base:
main← Head:fix/tool-value-close📝 Commits (1)
1a1a5de[Engine] tool parser: a closing sequence with text after it stays in the value (#4701)📊 Changes
4 files changed (+56 additions, -23 deletions)
View changed files
📝
serve/frontend.py(+42 -20)📝
serve/test_dsv41.py(+1 -1)📝
serve/test_parser_call_scan.py(+4 -2)📝
serve/test_tool_corpus.py(+9 -0)📄 Description
Problem and result
A
write_filewhose content explains the call format, with</parameter>,</function>and</tool_call>on their own lines followed by more text, is cut at the first</parameter>. The rest of the file leaks into the answer and the client writes a short file with no error (#4701).After this change, the #4701 fixture gives one call with the whole document and no answer text, with recover on and off, whole and in pieces.
Related discussion
Fixes #4701. It extends #4078 and uses the rule the issue suggests.
Approach
A closing sequence only ends a value when the end of the output, another call, or
</think>follows it. If text follows, and a later close ends the output, the value goes on. If no later close arrives, the first one was the end, so a real call followed by prose behaves as before. Any<tool_call>in the following text also keeps the old result, so two calls with prose between them stay two calls.The cost
This cannot be decided at
</tool_call>: the next bytes settle it. So a complete call now waits for one more token, or forfinish(). That is why the diff is larger than the rule:param_end,call_endandfunction_endpassfinalthrough.finish()setsself.endingand feeds nothing once, so a waiting call completes through the normal path.test_parser_call_scanandtest_dsv41change, because they asserted that a call finishes on the last byte of</tool_call>.The
tool_callevent moves by one token at most in the normal case. If a model writes prose after a real call, that call is held until the end of the turn. It stays the same call with the same arguments.Validation
Passed:
The #4701 fixture gives 102 of 174 characters on unchanged
main(870aedd9) and 174 of 174 here, recover and streamed arguments on and off, whole and in pieces of 1 and 7.python -m pytest serveon Linux, Python 3.14: 1242 passed, 14 skipped.Before the fix, on a maintained v0.2.8 build on an RTX 5090 Laptop (Qwen3.8-Flash-Next IQ3_S, live server), the model copied such a document into
write_file: Responses and streamed Chat wrote 41 of 113 characters and leaked the rest into the answer; Chat cut the file too and added a second call.Not run: a model run of this branch.
Limits
A file with the closing sequence, then a whole quoted call after it, still ends at the first close. That text looks the same as two real calls with prose between them. If you think one token of delay in this path is the wrong trade, I will close this and leave the report on #4701.
🤖 Generated with Claude Code
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.