mirror of
https://github.com/Niko1221/Strata.git
synced 2026-12-03 19:03:30 +07:00
[PR #5493] [Other] serve/frontend: deduplicate rewritten non-string XML params, coerce Python bools, and skip empty/null placeholders #5467
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#5467
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/5493
Author: @OleksiyPenkov
Created: 11/7/2026
Status: 🔄 Open
Base:
main← Head:fix/xml-tool-call-param-coercion-dedup📝 Commits (1)
ffd6c47serve/frontend: deduplicate rewritten non-string XML params, coerce Python bools, and skip empty/null placeholders📊 Changes
3 files changed (+135 additions, -22 deletions)
View changed files
📝
serve/frontend.py(+45 -18)📝
serve/test_server.py(+76 -0)📝
serve/test_tool_corpus.py(+14 -4)📄 Description
Problem and result
While running a 20-task agentic tool-use campaign (2,704 tool calls on
Qwen3.8-Flash-Nextvia/v1/chat/completionsand/v1/responses), we encountered XML tool-call parameter slips inserve/frontend.pythat either brokestream_tools=Trueparity or failed downstream client JSON-schema validation:Rewritten non-string
<parameter=P>blocks in the same<tool_call>:<parameter=bounds>[...]</parameter>and immediately rewrites<parameter=bounds>[...]</parameter>inside the same<function=...>call,param_end(..., name=pname)(#4078's reopened-string heuristic) treated the first</parameter>as part of the value even for non-string parameters, merging both arrays into[...]\n</parameter>\n<parameter=bounds>\n[...], which fails JSON decoding and leaves the raw string inarguments[pname]. Furthermore, inOutputParser._scan(stream_tools=True), emitting"pname":...for every occurrence produced duplicate keys or a mismatch withcall.arguments.param_end's same-name reopen rule (allow_reopen) applies only to string/undeclared parameters (and whole-call boundary walkscall_end/function_end), andOutputParser._scan(ss == "raw") skips emitting a non-string parameter when the same parameter name appears again later in the call body.Python boolean literals (
True/False):<parameter=dry_run>True</parameter>orFalse,json.loadsraisesValueErrorandlenient_jsononly handles arrays/objects, returning the string"True"instead ofTrue.coerce_valuedecodes"true"/"false"(case-insensitive) to booleanTrue/Falsewhen_declares(declared, "boolean").Empty or
null/Noneplaceholders on non-string parameters:<parameter=timeout></parameter>,<parameter=bounds>null</parameter>, or<parameter=bounds>None</parameter>for optional non-string parameters, emitting"timeout": ""or"bounds": nullcaused strict client schema validators (where optional fields have"type": "array"without"null") to reject the tool call.coerce_valuereturns sentinel_SKIPwhen a non-string parameter is empty ornull/None, and bothparse_tool_callandOutputParser._scanomit the key.Related discussion
none
Approach
allow_reopen: bool = Falsetoparam_endso that #4078's reopened-parameter rule remains active for string/undeclared parameters and whole-call boundary walks (call_end,function_end), while non-string parameters end at their first</parameter>.coerce_value, added_SKIPsentinel for empty/null/Nonenon-string parameters and case-insensitive boolean coercion when_declares(declared, "boolean").OutputParser._scan, delayed emitting"pname":for non-string parameters untilss == "raw"completes, skipping_SKIPvalues and earlier occurrences of a parameter name that is repeated later in the same<function=...>block.Validation
Passed:
python -m unittest serve.test_tool_corpus serve.test_parser_call_scan serve.test_quoted_call_values serve.test_param_end_options serve.test_frontend serve.test_server.ToolCallParameterCoercionAndDedup serve.test_server.ToolCallRecovery serve.test_server.UnfinishedToolCallffd6c47onmain(51763da), Windows 11 x64 (10.0.26300), Python 3.12, Ryzen 9 9950X3D, 64 GB RAM, NVIDIA RTX 5070 Ti 16 GB + RTX 5060 Ti 16 GB.Ran 59 tests in 4.120s — OK(verifying whole, chunked, and single-byte-split parity forstream_tools=Falseandstream_tools=True).python -m unittest serve.test_tool_opener_misspelt serve.test_tool_routes serve.test_tool_name_alias serve.test_tool_name_mcp_member serve.test_tool_name_prefix serve.test_tool_name_space serve.test_tool_call_envelope serve.test_tool_call_unclosed serve.test_native_tool_parser serve.test_reasoning_rescue serve.test_reasoning_tools serve.test_parser_hold serve.test_parser_markdown_code serve.test_parser_track serve.test_dsv41ffd6c47onmain(51763da), Windows 11 x64, Python 3.12.Ran 199 tests in 35.802s — OK (skipped=1).Failed:
Not run:
serve/frontend.pyand unit tests inserve/test_server.pyandserve/test_tool_corpus.py.Limits
stream_tools=True), deduplication of a rewritten parameter applies to non-string parameters (which are buffered until</parameter>inss == "raw"); string parameters stream character-by-character and continue to use the #4078 reopened-tag rule.🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.