mirror of
https://github.com/Niko1221/Strata.git
synced 2026-12-03 19:03:30 +07:00
[PR #3960] [Engine] Serve: tool calls coerce parameters by declared type; recover damaged <=param> openers and </NAME> closers #4852
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#4852
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/3960
Author: @mnott
Created: 10/24/2026
Status: 🔄 Open
Base:
main← Head:pr/coder-l-toolcall-recovery📝 Commits (10+)
e861803fix(serve): recover damaged qwen3-coder tool-call openers (<=NAME>, bare )394d6f6test(serve): damaged-opener test tupleba3f805fix(serve): coerce tool parameters by declared type; recover damaged <=param> openers1de5c2dfix(serve): coerce tool arguments on every call path; recover a tool name fused with its first parameter9144d88fix(serve): a bare after opens declared parameter NAMEb75fbd8fix(serve): a parameter without a declared type is JSON-decoded again (dsv41 and schema-less calls)881636afix(serve): a parameter without a declared type is JSON-decoded again (test follows)f52c86afix(serve): a call cut inside a parameter name keeps its complete parameters instead of raising738d7a9fix(serve): a parameter closer ends the value before any tag-shaped follower510b7a0fix(serve): only call-format followers end a value; tags in file content stay verbatim📊 Changes
19 files changed (+2132 additions, -122 deletions)
View changed files
📝
serve/frontend.py(+616 -72)📝
serve/responses.py(+1 -13)📝
serve/server.py(+7 -31)➕
serve/test_live_tools.py(+164 -0)➕
serve/test_param_types.py(+214 -0)➕
serve/test_parser_bare_opener.py(+45 -0)➕
serve/test_parser_bare_param_opener.py(+49 -0)📝
serve/test_parser_call_scan.py(+1 -1)➕
serve/test_parser_cut_name.py(+46 -0)➕
serve/test_parser_damaged_opener.py(+147 -0)➕
serve/test_parser_damaged_param_openers.py(+62 -0)➕
serve/test_parser_followers.py(+95 -0)➕
serve/test_parser_json_args.py(+105 -0)➕
serve/test_parser_rules4.py(+111 -0)➕
serve/test_parser_stub.py(+147 -0)➕
serve/test_parser_xml_elems.py(+99 -0)📝
serve/test_server.py(+3 -5)➕
serve/test_stream_followers.py(+139 -0)➕
tools/replay_raw.py(+81 -0)📄 Description
Rebased onto v0.2.6.
Problem and result
Qwen3-coder style models sometimes write tool calls the parser rejects or misreads: a damaged opener (
<=NAME>, a bare<NAME>,<parameter=NAME:, a function name fused with its first parameter), a closer without>or with a degenerate tail, an empty stub after a value, or a parameter whose declared type is a number or object but arrives as text. The call then fails and the agent retries. With this change those forms parse as the model meant and parameters arrive with their declared types.Related discussion
Overview of our related macOS / Metal contributions: #4128. Focused fix, no scope agreement needed.
Approach
tool_useblock is emitted once, whole, with the parsed call's arguments.tools/replay_raw.pyfor replaying captured model output through the parser.Validation
Revision
17c8d4ff(26 commits onv0.2.6), macOS on Apple Silicon, Python 3 with pytest 9.Passed:
python3 -m pytest -q serve/test_live_tools.py serve/test_param_types.py serve/test_parser_bare_opener.py serve/test_parser_bare_param_opener.py serve/test_parser_call_scan.py serve/test_parser_cut_name.py serve/test_parser_damaged_opener.py serve/test_parser_damaged_param_openers.py serve/test_parser_followers.py serve/test_parser_json_args.py serve/test_parser_rules4.py serve/test_parser_stub.py serve/test_parser_xml_elems.py serve/test_server.py serve/test_stream_followers.py serve/test_frontend.py serve/test_answer_speed.py: 460 passed, 650 subtests passed.Failed:
serve/test_server.py::VisionArgs::test_min_tokens_is_passed_only_when_set: fails the same way on plainv0.2.6(the test's fake process has nopid); fixed separately in #4125.Not run:
Limits
The recovery covers the damaged forms observed with Qwen3-coder style models; other malformed shapes still fail as before.
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.