Conversation
GLM-4-9B-0414 emits `name\n{json}` with no delimiters, so the marker
driven pipeline never invoked the `.glm4` parser and the call leaked
into the response text.
Add `NamedJSONCallScanner`, a schema-anchored scanner (byte trie over
the declared tool names + balanced JSON object), shared by the recovery
lexer for streaming detection and by `GLM4ToolCallParser` as a fallback
when no `<arg_key>` markers are present. Detection is line-anchored and
only fires for a declared tool name, so ordinary `word\n{...}` prose is
untouched.
The integration harness now passes `tools:` to `generate`, as
`ChatSession` already does; markerless detection needs the declared
names. Re-enable `glm4EndToEnd`.
CharlieTLe
reviewed
Sep 16, 2026
CharlieTLe
left a comment
Contributor
There was a problem hiding this comment.
Some minor nits, but how should the following be supported:
write_file\n{"contents": "<tool_call>hello</tool_call> world"}
The current implementation would do:
write_file(contents: "hello world")
But is this the expected behavior?
Contributor
Author
@CharlieTLe thanks. this makes sense. GLM4 wrapper tags are now stripped only at payload boundaries, so literal tags inside JSON arguments are preserved. Added regression coverage as well. |
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.
Proposed changes
Fixes #491. Refs #481.
GLM-4-9B-0414 emits a tool call as the function name on its own line followed by the JSON arguments object, with no delimiters:
Design
GLM-4-0414 is handled as a second dialect of the existing
.glm4format, opted in through a parser capability flag (supportsMarkerlessNamedJSON), the same patternsupportsBareJSONuses today. No newToolCallFormat; existing formats are untouched.Detection is schema-anchored:
NamedJSONCallScannermatches a declared tool name at the start of a line, followed by a single newline and a balanced JSON object. Without declared tools the scanner does not exist, so ordinaryword\n{...}prose can never be misread as a call.Checklist
Put an
xin the boxes that apply.pre-commit run --all-filesto format my code / installed pre-commit prior to committing changesAI usage
accurately describes the code changes.