Skip to content

helios: allow lenient EOS close for GLM argument-tag tool calls - #514

Closed
jannerchang wants to merge 1 commit into
NVIDIA:mainfrom
jannerchang:pr/glm-lenient-eos-tool-close
Closed

jannerchang wants to merge 1 commit into
NVIDIA:mainfrom
jannerchang:pr/glm-lenient-eos-tool-close

Conversation

@jannerchang

Copy link
Copy Markdown

Problem

In multi-turn tool-calling workloads with GLM models (e.g. GLM-5.3-Flash), the model occasionally emits a complete <tool_call>name<arg_key>...</arg_key><arg_value>...</arg_value> call and then hits EOS directly without emitting the trailing </tool_call> closing tag.

Currently, TaggedTools::finish unconditionally returns Err("incomplete GLM tool call") on Termination::Eos, aborting the stream even though the buffered call body is already complete and syntactically valid.

Fix

  • Add const LENIENT_EOS_CLOSE: bool = false; to ToolDialect in helios/src/output/tagged.rs.
  • Enable const LENIENT_EOS_CLOSE: bool = true; only for ArgumentTags (GLM) in helios/src/output/argument_tags.rs.
  • When TaggedTools::finish receives Termination::Eos for a dialect with LENIENT_EOS_CLOSE = true, attempt D::parse(&raw, &self.tools) and emit the parsed ToolBegin / ToolArguments / ToolEnd events if valid and non-empty; otherwise fall through to the existing incomplete GLM tool call error.
  • Add unit test output::argument_tags::tests::unclosed_glm_tool_call_at_eos_emits_parsed_call.
  • Other dialects (ChatML/Qwen, etc.) keep LENIENT_EOS_CLOSE = false and retain strict incomplete-call errors.

Verification

  • cargo test --manifest-path helios/Cargo.toml --features runtime-core,server --lib -- output::argument_tags:: output::chatml:: on main (2771618): 24 passed, 0 failed, including unclosed_glm_tool_call_at_eos_emits_parsed_call, malformed_calls_fail, and chatml::tests::terminal_cause_preserves_incomplete_call_errors_and_never_fabricates_calls.

GLM models occasionally emit a complete <tool_call>name<arg_key>...</arg_key><arg_value>...</arg_value> sequence and terminate directly with EOS without the trailing </tool_call> closing tag, causing TaggedTools::finish to abort the stream with 'incomplete GLM tool call'.

Add ToolDialect::LENIENT_EOS_CLOSE (default false, enabled only for GLM ArgumentTags). When Termination::Eos arrives inside an open tool call for a dialect with LENIENT_EOS_CLOSE = true, attempt to parse the buffered tool call body and emit the parsed call if valid; otherwise preserve the existing incomplete-call error. Other dialects (ChatML/Qwen, etc.) retain strict behavior.

Signed-off-by: JannerChang <[email protected]>
@flare-autobot

Copy link
Copy Markdown
Collaborator

A case file has been opened for 514.
Case File Intake Report

Future reviews will auto-run 90 minutes after code updates are pushed.

  • Re-review sooner: Call @flare-autobot after push.
  • Opt-out: Include #autobot:ignore in the PR or any comment.

@flare-autobot

Copy link
Copy Markdown
Collaborator

Review Stopped

Auto-Review halted due to finding: It is low value or does not align with the project charter.
Value Proposition Report

@lukealonso

Copy link
Copy Markdown
Collaborator

Superseded by #573

@lukealonso lukealonso closed this Nov 28, 2026
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.

3 participants