Repository navigation
Conversation
gpt-oss speaks in analysis, commentary, and final channels. The server treated that text as content, so the next turn was rejected for containing channel tags. Select the harmony parser for these models, return analysis as reasoning and functions.* commentary as tool calls, and accept assistant history that replays reasoning plus tool calls. Co-Authored-By: Grok <noreply@x.ai>
This branch has not been deployed
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
mlx_lm.serverhad no harmony tool parser, so gpt-oss returned raw<|channel|>text ascontent. The checkpoint chat template then rejects that history (You have passed a message containing <|channel|> tags), and the next turn 404s.Nothing on main parses harmony tool calls. #1867 (closed, withdrawn) only split non-streaming text into content and reasoning, and put the commentary tool payload back into content.
This adds a harmony parser and selects it for gpt-oss:
reasoningto=functions.<name>→ a tool call (recipient-first, as the chat template writes it, and channel-first, as the model emits it, including<|constrain|>json)content<|call|>is an extra eos, so a tool turn stops for the clienttool_callsplusreasoning/reasoning_content(as OpenAI-compatible agent clients send it) is rewritten to the template'sthinkingfield. A tool-call turn cannot carry bothcontentandthinking, so a preamble is dropped when analysis is present.The checkpoint chat template is unchanged.
Test plan
python -m unittest tests.test_tool_parsinggpt-oss-20b-MXFP4-Q8selects the parser, round-trips a tool turn through the streaming detokenizer, and rendersreasoning+tool_callswithout raisingmlx_lm.serverwithgpt-oss-20b-MXFP4-Q8: a file read, then a shell call, then the final answer, all HTTP 200 with no channel-tag 404🤖 Generated with Claude Code