mirror of
https://github.com/Niko1221/Strata.git
synced 2026-12-03 19:03:30 +07:00
[PR #2371] [Engine] read Python-style tool argument literals (True, None) by the declared type, whole and streamed #4011
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#4011
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/2371
Author: @anstaendig
Created: 10/14/2026
Status: 🔄 Open
Base:
main← Head:fix/tool-argument-schema-coercion📝 Commits (1)
faab1b4serve: read Python-style tool argument literals (True, None, +10) by the declared type, whole and streamed📊 Changes
3 files changed (+212 additions, -10 deletions)
View changed files
📝
serve/frontend.py(+47 -10)📝
serve/test_server.py(+22 -0)➕
serve/test_tool_argument_types.py(+143 -0)📄 Description
Problem and result
The model sometimes writes tool arguments Python-style, for example
<parameter=onlyMainContent>True</parameter>or<parameter=unlock>False</parameter>. That is not JSON, socoerce_valuepassed the text through and a boolean parameter reached the client as the string"True"/"False"(truthy either way). Strict tool servers reject it (expected boolean, received string, reported above with firecrawl-mcp, and with opencode on 0.2.2011c9e6: 12 of 55 boolean arguments).Reproduced on current
main(c62d5e3a) withOutputParser(stream_tools=True)and a tool declaringonlyMainContent: {"type": "boolean"}:tool_argsand the final call both give{"url": "https://x.y", "onlyMainContent": "True"}{"url": "https://x.y", "onlyMainContent": true}, fed whole and one character at a timeRelated discussion
Related to #1955 (boolean conversion in the completed-call parser only). This PR also covers the streamed arguments, which now go through the same
coerce_valueas the final call, so the concatenated fragments match it. Rebased ontomainafter the 0.2.0-beta tracker reset; the change is now a single commit on top of the currentcoerce_value.Approach
coerce_valuetakes the property's schema instead of only its type. Afterjson.loadsfails, a newliteral_valuereads a scalar by the declared type:boolean:true/falsein any case;null:null/None;integer:[+-]digits;number: decimal, finite only.Noneare read too.main): any type that includesstring; a schema without a top-level type (enum,anyOf,oneOf,const,$ref), soenum: ["None", "Low"]keeps"None"; anything that does not match."False"(quoted) stays a string. The lenient array/object reading from #4427 is unchanged.["string"]is now treated like"string"(verbatim) in both paths; before,{"a":1}in such a field was decoded to an object.Validation
macOS (Apple silicon), Python 3.12.13,
requirements.txtplusjsonschema, revisionfaab1b4a=mainc62d5e3a+ this commit. No GPU needed: these are parser and mock-engine tests.Passed:
python -m unittest serve.test_tool_argument_types: 8 tests OK. It checks whole output, character-wise streaming and every two-chunk split, and compares the concatenatedtool_argswith the final call. The same file against unchangedmaingives 28 failures.serve.test_server.UnfinishedToolCall.test_schema_typed_arguments_over_both_apis: OpenAI and Anthropic, streamed and not, through the HTTP server with a mock engine (boolean, integer, nullable, string,enumandanyOffields).serve/test_*.py: 1,300 tests, 1 failure, 18 skipped. Unchangedmaingives 1,298 tests with the same single failure (test_gpu_roles_server.Roles.test_every_card_off,SystemExit not raised), so this change adds no failure.git diff --check: clean.Failed:
None caused by this change. The one failure above also happens on unchanged
main.Not run:
No CUDA/HIP/SYCL build: no engine files are touched. No run with a real model or GPU, and no BFCL rerun, so the effect on benchmark scores is not measured.
Limits
string(for example["string", "null"]),Nonestays the string"None". The field accepts text, so this PR does not guess.🤖 Generated with Claude Code
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.