server: emit GLM tool-call args with their real JSON types (fixes #569)#582
Open
gilbert-barajas wants to merge 1 commit into
Open
server: emit GLM tool-call args with their real JSON types (fixes #569)#582gilbert-barajas wants to merge 1 commit into
gilbert-barajas wants to merge 1 commit into
Conversation
…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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
parse_glm_generated_message_exhardcodedis_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 DSMLstring="true|false"that the DSML path already honors viajson_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 thejson_skip_valueprimitivejson_minify_raw_valuealready relies on. Plain text and JSON string literals stay quoted, sois_stringis"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 emitmax_results: 10,exclude_domains: [],safe_search: true,cursor: null,opts: {…}with correct types, whilequerystays a string. Also fixes an existing test that had encoded the bug ("timeout": "10"→"timeout": 10). +70/−2.Fixes #569