Skip to content

server: emit GLM tool-call args with their real JSON types (fixes #569)#582

Open
gilbert-barajas wants to merge 1 commit into
antirez:mainfrom
gilbert-barajas:fix/569-toolcall-json-types
Open

server: emit GLM tool-call args with their real JSON types (fixes #569)#582
gilbert-barajas wants to merge 1 commit into
antirez:mainfrom
gilbert-barajas:fix/569-toolcall-json-types

Conversation

@gilbert-barajas

Copy link
Copy Markdown

parse_glm_generated_message_ex hardcoded is_string="true" on every GLM tool-call argument, so numbers/arrays/booleans/null were JSON-escaped into strings ("10", "[]", "true") — which schema-validating clients (zod/ajv, Chatwise) reject. GLM's <arg_value> wire format carries no type attribute, unlike DeepSeek's DSML string="true|false" that the DSML path already honors via json_minify_raw_value.

Adds glm_arg_value_is_raw_json() — true only when the whole value is one complete, valid, non-string JSON value (number / true/false/null / [...] / {...}), reusing the json_skip_value primitive json_minify_raw_value already relies on. Plain text and JSON string literals stay quoted, so is_string is "false" for raw JSON values and "true" otherwise.

Verified with a new parser test (test_parse_glm_tool_call_arg_types): the #569 curl's args now emit max_results: 10, exclude_domains: [], safe_search: true, cursor: null, opts: {…} with correct types, while query stays a string. Also fixes an existing test that had encoded the bug ("timeout": "10""timeout": 10). +70/−2.

Fixes #569

…irez#569)

parse_glm_generated_message_ex hardcoded is_string="true" when adding every
GLM tool-call argument, so numbers, arrays, booleans and null were all
JSON-escaped into strings ("10", "[]", "true"), which schema-validating
clients (zod/ajv, Chatwise) reject. GLM's <arg_value> wire format carries no
type attribute, unlike DeepSeek's DSML string="true|false" that the DSML path
already honors via json_minify_raw_value.

Add glm_arg_value_is_raw_json(): true only when the whole value is one
complete, valid, non-string JSON value (number / true|false|null / [...] /
{...}), reusing the json_skip_value primitive json_minify_raw_value relies on.
Plain text and JSON string literals stay quoted. is_string is then "false"
for raw JSON values, "true" otherwise.

Adds test_parse_glm_tool_call_arg_types (number/array/bool/null/object emit
raw, strings stay quoted) and fixes an existing test that had encoded the bug
("timeout": "10" -> "timeout": 10).

Fixes antirez#569
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

server: GLM tool-call parser stringifies all argument values (numbers/arrays become strings), breaking schema-validating clients

1 participant