mirror of
https://github.com/Niko1221/Strata.git
synced 2026-12-03 19:03:30 +07:00
[PR #1881] [CLOSED] [Engine] serve: a tool call whose </tool_call> is missing ends at its own </function> #3733
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#3733
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/1881
Author: @LeGeRyChEeSe
Created: 10/10/2026
Status: ❌ Closed
Base:
main← Head:pr/tool-call-unclosed📝 Commits (1)
fe6abbdserve: a tool call whose </tool_call> is missing ends at its own when another <tool_call> or text follows, instead of merging into the next call or losing its arguments📊 Changes
2 files changed (+74 additions, -0 deletions)
View changed files
📝
serve/frontend.py(+10 -0)➕
serve/test_tool_call_unclosed.py(+64 -0)📄 Description
Problem and result
When the model leaves out a call's
</tool_call>,call_endfalls back to the next</tool_call>anywhere in the output. Two cases go wrong, with or withouttool_call_recovery, streamed or not:<tool_call>read(a.py) (no closer)<tool_call>write(b.py, "x = 1")</tool_call>readwith{"path": "b.py", "content": "x = 1"}read(a.py), thenwrite(b.py, "x = 1")<tool_call>read(a.py) (no closer)Done.readwith{}(streamed) or no callread(a.py), then the contentDone.The first is the worse one: an agent runs the first tool with the second tool's arguments. The bug is still present in v0.2.2.
Related discussion
No open issue found (searched 2026-10-22: "missing </tool_call>", "unclosed tool_call", "tool_call closing tag"). Related, all closed: #210 (call_end), #211 (a call cut before its closer), #1172 (recover's batch in one wrapper, opt-in), #1431.
This pull request was closed in the 0.2.0-beta tracker reset; it is rebased on v0.2.2 and unchanged in content.
Approach
OutputParser.feed, the wrapped-call branch (a few lines). After the call's own</function>- found byfunction_end, which walks the parameters withparam_end, so a value that holds</function>or<tool_call>does not count - the next non-blank text decides:</tool_call>(or the start of it, still arriving): closes the call, as before;<function=or<parameter=(or the start of one, still arriving): left to recover's batch (opt-in), unchanged;<tool_call>, text): the call ends at its</function>, and what follows is read as usual.Nothing changes for a call that has its closer. New regression test:
serve/test_tool_call_unclosed.py.Validation
Revision: v0.2.2 (
011c9e60) plus this one commit. Environment: Windows 11, Python 3.13, RTX 4070 SUPER.Passed:
python -m unittest serve.test_tool_call_unclosedon v0.2.2 without the change: 4 tests, 24 sub-test failures (for example[('read', {})] != [('read', {'path': 'a.py'})]). With the change: 4 tests, OK. The tests cover the two cases above, closed calls unchanged, and a parameter value that holds</function>and<tool_call>, each withstream_toolsandrecoveron and off, fed 1, 3 and 7 characters at a time.python -m pytest serve -qon this branch: 916 passed, 17 skipped.serve/changes, #1882 and #1883) answered a request with a declared tool by a tool call, streamed and not. That request has a closed call, so it only shows that nothing regressed.Failed:
none observed.
Not run:
OutputParser.Limits
This only reads what the model wrote more faithfully; a model that omits the closer still does so.
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.