Add Harmony (GPT-OSS) Tool Calling Support in FL - #973
Draft
Sayan Shaw (sayanshaw24) wants to merge 2 commits into
Draft
Add Harmony (GPT-OSS) Tool Calling Support in FL#973Sayan Shaw (sayanshaw24) wants to merge 2 commits into
Sayan Shaw (sayanshaw24) wants to merge 2 commits into
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
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.
Add Harmony (GPT-OSS) Tool Calling Support in FL
Summary
Adds data-driven tool calling support for GPT-OSS (Harmony) models, which use a fundamentally different protocol from ChatML-style models (Phi, Qwen). No model-specific code branches — all format knowledge is captured in a
ToolCallConfigstruct that the accumulator interprets at runtime.Problem
ChatML models emit tool calls as:
GPT-OSS models use header-based routing:
Key differences:
to=functions.X), not in the JSON body{"name": ..., "arguments": ...}object)<|call|>is both EOT and EOS (generation stops naturally)<|end|>for intermediate calls,<|call|>for the final oneChanges
New:
tool_call_config.hToolCallConfigstruct withMode::kSimple(ChatML) andMode::kHeaderInspection(Harmony)Harmony()preset: message_token, header_regex, channel_token, end_tokensFromModelType(model_type)factory:"gptoss"→ Harmony, everything else → SimpleModified:
tool_call_stream_accumulator.hToolCallConfigIdle → InHeader → InBody → Emit<|end|>+<|call|>for parallel calls)Modified:
chat_session.ccmodel_.GetGenAIConfig().model->typeand pass the appropriateToolCallConfigNew tests:
tool_call_stream_accumulator_test.ccHarmonyBasicToolCall— single tool call in one chunkHarmonyToolCallSplitAcrossChunks— streaming token-by-tokenHarmonyRegularTextNotToolCall— header withoutto=functions.Xis visible textHarmonyParallelToolCalls— two calls, first ends with<|end|>, second with<|call|>HarmonyTextBeforeToolCall— preamble text preservedHarmonyFlushUnterminatedHeader— graceful EOS mid-headerHarmonyFlushUnterminatedBody— graceful EOS mid-bodyDesign Principles
ToolCallConfigcaptures all protocol knowledge; no if/else on model name in the accumulatorMode::kSimple(default) — zero behavior changeModeenum + preset; adding a new model with existing protocol = one line inFromModelType<|end|>(not EOS) vs<|call|>(EOS) design naturally supports parallel callsDepends On
bot_token_id/eot_token_idresolution from genai_config.jsonTesting
gpt-oss-20b-generic-cpumodel pending