[PR #13561] harmony: handle embedded analysis segments in tool call JSON #60968

Open
opened 2026-04-29 16:03:59 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/ollama/ollama/pull/13561
Author: @Code4me2
Created: 12/25/2025
Status: 🔄 Open

Base: mainHead: harmony-tool-parsing


📝 Commits (1)

  • 0b7d8ed harmony: handle embedded analysis segments in tool call JSON

📊 Changes

2 files changed (+215 additions, -2 deletions)

View changed files

📝 harmony/harmonyparser.go (+133 -2)
📝 harmony/harmonyparser_test.go (+82 -0)

📄 Description

Relates to #11691

Models using the harmony parser may output analysis/thinking segments
before JSON arguments in tool calls. For example:

<|channel|>analysis<|message|>I need to list files.{"path": "/tmp"}

Previously this would fail JSON parsing. Now the parser:

  • Extracts and strips harmony analysis segments before JSON
  • Preserves the thinking content separately
  • Uses brace-matching to extract complete JSON objects

This brings the harmony parser in line with Qwen3VL and Cogito parsers
which already handle mixed thinking/tool call content via event-based
parsing.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/ollama/ollama/pull/13561 **Author:** [@Code4me2](https://github.com/Code4me2) **Created:** 12/25/2025 **Status:** 🔄 Open **Base:** `main` ← **Head:** `harmony-tool-parsing` --- ### 📝 Commits (1) - [`0b7d8ed`](https://github.com/ollama/ollama/commit/0b7d8eda683da1288aa74c986b854c8e213c3d0b) harmony: handle embedded analysis segments in tool call JSON ### 📊 Changes **2 files changed** (+215 additions, -2 deletions) <details> <summary>View changed files</summary> 📝 `harmony/harmonyparser.go` (+133 -2) 📝 `harmony/harmonyparser_test.go` (+82 -0) </details> ### 📄 Description Relates to #11691 Models using the harmony parser may output analysis/thinking segments before JSON arguments in tool calls. For example: <|channel|>analysis<|message|>I need to list files.{"path": "/tmp"} Previously this would fail JSON parsing. Now the parser: - Extracts and strips harmony analysis segments before JSON - Preserves the thinking content separately - Uses brace-matching to extract complete JSON objects This brings the harmony parser in line with Qwen3VL and Cogito parsers which already handle mixed thinking/tool call content via event-based parsing. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
GiteaMirror added the pull-request label 2026-04-29 16:03:59 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/ollama#60968