fix: handle Harmony <|call|> EOG token for GPT-OSS tool calling#1812
Merged
gianni-cor merged 11 commits intoApr 30, 2026
Merged
Conversation
GPT-OSS models use <|call|> as a frame delimiter in Harmony tool-call protocol. This token is in the EOG set, causing generation to stop silently before tool calls reach the SDK. Add Harmony model detection and <|call|>-specific handling in the generation loop: render the token as visible text (special=true) so the SDK can parse frame boundaries, then stop generation for the turn-based tool execution protocol.
jesusmb1995
previously approved these changes
Apr 30, 2026
Contributor
|
/review |
gianni-cor
approved these changes
Apr 30, 2026
Contributor
|
/review |
Contributor
|
/review |
aegioscy
previously approved these changes
Apr 30, 2026
Contributor
|
/review |
aegioscy
approved these changes
Apr 30, 2026
Contributor
|
/review |
Contributor
|
/review |
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.
Summary
GPT-OSS 20B tool calling was broken — the model emits a Harmony tool call frame but generation stops silently before
<|call|>reaches the SDK, resulting in 0 parsed tool calls and no visible frame delimiter.Root cause
<|call|>(token 200012) is in the model's EOG set. When sampled, it renders as 0 bytes (control token withspecial=false) and immediately triggers the generation loop break. The model produces the tool call JSON but the output is truncated with no frame boundary visible to the SDK.Fix
<|call|>token ID<|call|>before the generic EOG break whenisHarmonyModel_andparams_.use_jinjaare true<|call|>as visible text usingcommon_token_to_piece(lctx_, tokenId, true)so the SDK can parse frame boundariesTextLlmContext.cppandMtmdLlmContext.cppharmonyMultiTurnTools.js) demonstrating sequential tool execution across turns