[PR #14906] [CLOSED] fix: treat unparseable qwen tool calls as content instead of aborting #14908

Closed
opened 2026-04-13 01:05:25 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/ollama/ollama/pull/14906
Author: @aayushbaluni
Created: 3/17/2026
Status: Closed

Base: mainHead: fix/14834-qwen-tool-call-xml-eof


📝 Commits (1)

  • af92861 fix: treat unparseable qwen tool calls as content instead of aborting

📊 Changes

1 file changed (+7 additions, -4 deletions)

View changed files

📝 model/parsers/qwen3coder.go (+7 -4)

📄 Description

Summary

Fixes #14834

When the qwen3-coder model streams malformed or incomplete XML in a tool call tag, xml.Unmarshal fails and the Add function returns the error, aborting the entire request. Users see a cryptic "qwen tool call parsing failed" error and get no response at all.

Root Cause

In model/parsers/qwen3coder.go, the Add method returns (nil, nil, nil, err) on any parseToolCall failure. This propagates the XML parse error up to the caller and terminates the generation.

Fix

Instead of returning the error, emit the raw (unparseable) tool call content back as regular text content. The request completes normally and the user still sees the model output. The warning is still logged for debugging.

// Before: returns error, aborting the request
if err != nil {
    return "", "", nil, err
}

// After: treats malformed XML as content, continues
if parseErr != nil {
    sb.WriteString(toolOpenTag)
    sb.WriteString(event.raw)
    sb.WriteString(toolCloseTag)
    continue
}

Test Plan

  1. Use qwen3-coder model with tool calling enabled
  2. Send a prompt that triggers malformed XML in tool call output
  3. Previously: request aborts with "qwen tool call parsing failed" error
  4. Now: the raw content is returned as text, request completes successfully

Made with Cursor


🔄 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/14906 **Author:** [@aayushbaluni](https://github.com/aayushbaluni) **Created:** 3/17/2026 **Status:** ❌ Closed **Base:** `main` ← **Head:** `fix/14834-qwen-tool-call-xml-eof` --- ### 📝 Commits (1) - [`af92861`](https://github.com/ollama/ollama/commit/af92861bb0a998c4d5136e950cb9683980e4b3fd) fix: treat unparseable qwen tool calls as content instead of aborting ### 📊 Changes **1 file changed** (+7 additions, -4 deletions) <details> <summary>View changed files</summary> 📝 `model/parsers/qwen3coder.go` (+7 -4) </details> ### 📄 Description ## Summary Fixes #14834 When the qwen3-coder model streams malformed or incomplete XML in a tool call tag, `xml.Unmarshal` fails and the `Add` function returns the error, aborting the entire request. Users see a cryptic "qwen tool call parsing failed" error and get no response at all. ## Root Cause In `model/parsers/qwen3coder.go`, the `Add` method returns `(nil, nil, nil, err)` on any `parseToolCall` failure. This propagates the XML parse error up to the caller and terminates the generation. ## Fix Instead of returning the error, emit the raw (unparseable) tool call content back as regular text content. The request completes normally and the user still sees the model output. The warning is still logged for debugging. ```go // Before: returns error, aborting the request if err != nil { return "", "", nil, err } // After: treats malformed XML as content, continues if parseErr != nil { sb.WriteString(toolOpenTag) sb.WriteString(event.raw) sb.WriteString(toolCloseTag) continue } ``` ## Test Plan 1. Use qwen3-coder model with tool calling enabled 2. Send a prompt that triggers malformed XML in tool call output 3. Previously: request aborts with "qwen tool call parsing failed" error 4. Now: the raw content is returned as text, request completes successfully Made with [Cursor](https://cursor.com) --- <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-13 01:05:25 -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#14908