Module harmony

Module harmony 

Source
Expand description

OpenAI Harmony format parsing for GPT-OSS models.

The Harmony format uses channels to separate different types of content:

  • analysis: Chain-of-thought reasoning (internal, not for end users)
  • commentary: Tool call preambles and explanations
  • final: User-facing response content

Tool calls in Harmony are indicated by the recipient field being set to:

  • functions.tool_name for user-defined tools
  • browser.search, browser.open, browser.find for browser tool
  • python for python tool

This module provides incremental parsing of Harmony-formatted token streams.

Structs§

HarmonyAccumulated
Accumulated content for each channel
HarmonyContext
Context for tracking Harmony parsing state within a sequence.
HarmonyDelta
Incremental delta from Harmony parsing
HarmonyToolCall
A tool call parsed from Harmony format

Enums§

HarmonyChannel
Channel types in Harmony format

Functions§

is_harmony_encoding_ready
Check if the Harmony encoding has been initialized.
is_harmony_template
Check if a chat template uses Harmony format by looking for Harmony markers.
prewarm_harmony_encoding
Pre-initialize the Harmony encoding. This MUST be called from a non-async context (e.g., during pipeline loading) before any async code runs. The openai-harmony crate uses reqwest::blocking which creates its own tokio runtime, so it cannot be called from within an existing async context.