fix: drop a tool call that generation never finished - #742
Open
Javinator9889 wants to merge 1 commit into
Open
Javinator9889 wants to merge 1 commit into
Javinator9889 wants to merge 1 commit into
Conversation
When neither </tool_call> nor </function> is present the call was cut off,
normally by the output limit while writing a large argument. Taking the
remainder of the text fabricates a complete-looking call from a partial one,
and the client cannot tell: the arguments JSON is well formed because it is
rebuilt from the parsed parameters. A shell heredoc cut mid-body becomes an
unterminated `cat <<EOF` that hangs whatever runs it.
Drop the block instead. The response still carries finish_reason "length",
which is the honest signal to retry with a larger budget. The </function>
fallback is kept: a block missing only the outer tag is complete.
Measured on qwen3.5:9b, a 300-line heredoc at max_tokens=400:
before, tool_calls=true with 1580 chars of arguments and no closing EOF;
after, tool_calls=false with finish_reason "length". A complete call is
unaffected: finish_reason "tool_calls", arguments {"command":"echo hello"}.
Refs ROCm#741
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.
Fixes #741.
When neither
</tool_call>nor</function>is present, generation was cut offinside the call — normally by the output limit while writing a large argument.
The parser took the remainder of the text as the block and emitted a
complete-looking tool call built from partial input:
The client cannot detect this, because the
argumentsJSON is well formed — itis rebuilt from the parsed parameters, not copied from the raw text. A shell
heredoc cut mid-body becomes an unterminated
cat <<EOF.This drops the block instead, so no tool call is emitted. The response still
carries
finish_reason: "length", which is the honest signal that the clientshould retry with a larger budget. The
</function>fallback is kept: a blockmissing only the outer tag is complete.
Applied to the three models that share the pattern:
qwen3_5vl,qwen3_6_moe,qwen3_5_omni.Verified on
qwen3.5:9b, 300-line heredoc atmax_tokens=400:tool_calls: true, 1580 chars of arguments, no closingEOFtool_calls: false,finish_reason: lengthfinish_reason: tool_calls,{"command":"echo hello"}