Skip to content

vllm.entrypoints.openai.responses.harmony

Harmony ↔ Responses API conversion utilities.

Handles two directions
  1. Response Input → Harmony Messages (input parsing)
  2. Harmony Messages → Response Output Items (output parsing)

Functions:

_parse_browser_tool_call(message, recipient)

Parse browser tool calls (search, open, find) into web search items.

_parse_chat_format_message(chat_msg)

Parse an OpenAI chat-format dict into Harmony messages.

_parse_final_message(message, incomplete=False, logprobs=None)

Parse final channel messages into output message items.

logprobs covers every text token of the message, so it is attached to the first content part.

_parse_function_call(message, recipient, incomplete=False)

Parse function calls into function tool call items.

_parse_harmony_format_message(chat_msg)

Reconstruct a Message from Harmony-format dict, preserving channel, recipient, and content_type.

_parse_mcp_call(message, recipient, incomplete=False)

Parse MCP calls into MCP call items.

_parse_mcp_recipient(recipient)

Parse MCP recipient into (server_label, tool_name).

For dotted recipients like "repo_browser.list": - server_label: "repo_browser" (namespace/server) - tool_name: "list" (specific tool)

For simple recipients like "filesystem": - server_label: "filesystem" - tool_name: "filesystem"

_parse_message_no_recipient(message, incomplete=False, logprobs=None)

Parse a Harmony message with no recipient based on its channel.

_parse_reasoning(message)

Parse reasoning/analysis content into reasoning items.

construct_harmony_previous_input_messages(request)

Build a Harmony message list from request.previous_input_messages.

Filters out system/developer messages to match OpenAI behavior where instructions are always taken from the most recent Responses API request.

harmony_to_response_output(message, function_tool_names, incomplete=False, logprobs=None)

Parse a Harmony message into a list of output response items.

This is the main dispatcher that routes based on channel and recipient.

response_input_to_harmony(response_msg, prev_responses)

Convert a single ResponseInputOutputItem into a Harmony Message.

Returns None for system/developer messages with empty content so the caller can skip them. Reasoning items with empty or absent content (e.g. placeholders from history replay) are converted to empty assistant messages to preserve the conversation structure.

response_previous_input_to_harmony(chat_msg)

Parse a message from request.previous_input_messages into Harmony messages.

Supports both OpenAI chat format ({"role": "..."}) and Harmony format ({"author": {"role": "..."}}).