Preserve schema-declared JSON types in GLM tool calls - #1016
Preserve schema-declared JSON types in GLM tool calls#1016babyLegionite wants to merge 1 commit into
Conversation
|
Tested this on a GLM 5.3 deployment (the full model, not Flash; ds4 loads it with the GLM 5.2 shape, so Before: opencode rejected every tool call with numeric arguments, because they arrived as strings. For example, After rebuilding with this PR (on 6289c51):
The server unit tests ( Thanks for the fix! |
GLM tool calls currently quote every argument, so a tool declaring an integer receives
{"result":"40"}even when the model emits<arg_value>40</arg_value>. This breaks clients that enforce tool parameter types.Retain the request's parameter schemas and use explicit property types when parsing GLM output. Recover JSON integers, numbers, booleans, null, arrays, and objects while preserving strings such as
"001"and"true". Buffered and streamed responses share the parser; original generated tool text remains intact for replay/cache bookkeeping.Generated literals must be complete JSON before being emitted without quotes. Lexical checks reject strtod extensions such as NaN, Infinity, hexadecimal numbers, and leading zeros, including inside arrays/objects. Integer text is preserved without floating-point conversion.
Scope
This is conservative type recovery, not full JSON Schema validation. It supports explicit
typedeclarations and type arrays. Missing/unknown types, unions allowing strings, and schemas expressed only through$refor combinators retain the previous string behavior. Integer recovery requires integer notation; decimal/exponent notation is supported fornumber. Nested array/object values are preserved, not recursively coerced.Validation
make -j8 ds4_test ds4-server ds4_agent_test,./ds4_test --server,./ds4_agent_test, andmake -j8 cpupassed. CPU build only; no large CPU inference run.make -j8, test-target build,./ds4_test --server, and./ds4_agent_testpassed."001"remaining a string. Decode throughput was about 24 tokens/second on the short mixed-type calls; this is a smoke measurement, not a controlled performance benchmark.Based on
6289c516273979173abbc062209a81dd3706b804. No inference backend or model-weight changes. CUDA, SSD, distributed inference, and long-context quality benchmarks were not run; changes are limited to server-side argument parsing and its tests.