Repository navigation
helios: allow lenient EOS close for GLM argument-tag tool calls - #514
Closed
jannerchang wants to merge 1 commit into
Closed
jannerchang wants to merge 1 commit into
jannerchang wants to merge 1 commit into
Conversation
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]>
Collaborator
|
A case file has been opened for 514. Future reviews will auto-run 90 minutes after code updates are pushed.
|
Collaborator
Review StoppedAuto-Review halted due to finding: It is low value or does not align with the project charter. |
Collaborator
|
Superseded by #573 |
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.
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::finishunconditionally returnsErr("incomplete GLM tool call")onTermination::Eos, aborting the stream even though the buffered call body is already complete and syntactically valid.Fix
const LENIENT_EOS_CLOSE: bool = false;toToolDialectinhelios/src/output/tagged.rs.const LENIENT_EOS_CLOSE: bool = true;only forArgumentTags(GLM) inhelios/src/output/argument_tags.rs.TaggedTools::finishreceivesTermination::Eosfor a dialect withLENIENT_EOS_CLOSE = true, attemptD::parse(&raw, &self.tools)and emit the parsedToolBegin/ToolArguments/ToolEndevents if valid and non-empty; otherwise fall through to the existingincomplete GLM tool callerror.output::argument_tags::tests::unclosed_glm_tool_call_at_eos_emits_parsed_call.LENIENT_EOS_CLOSE = falseand retain strict incomplete-call errors.Verification
cargo test --manifest-path helios/Cargo.toml --features runtime-core,server --lib -- output::argument_tags:: output::chatml::onmain(2771618): 24 passed, 0 failed, includingunclosed_glm_tool_call_at_eos_emits_parsed_call,malformed_calls_fail, andchatml::tests::terminal_cause_preserves_incomplete_call_errors_and_never_fabricates_calls.