[Frontend] Constrain non-strict GLM-4.7 tool calls with a shallow structural tag (#56403)

Signed-off-by: Shijin Zhang <75300765+Dovis01@users.noreply.github.com>
Co-authored-by: Flora Feng <4florafeng@gmail.com>
This commit is contained in:
Shijin Zhang
2026-10-02 14:31:53 -04:00
committed by GitHub
co-authored by Flora Feng
parent f700178f90
commit d1a974c140
5 changed files with 729 additions and 2 deletions
+5
View File
@@ -506,6 +506,11 @@ class DelegatingParser(Parser):
is_auto = request.tool_choice == "auto"
single_call = request.parallel_tool_calls is False
strict_level = self.tool_strict_level
if (
strict_level == ToolStrictLevel.AUTO
and tool_parser.default_tool_strict_level is not None
):
strict_level = tool_parser.default_tool_strict_level
if single_call and not (is_auto and structured_outputs is not None):
# Limiting the call count needs the call envelope in the grammar.
# Auto with structured outputs keeps its format-only grammar, so the