[GH-ISSUE #11232] Parser generates incorrect tool calls compared to Qwen3 model output #7399

Closed
opened 2026-04-12 19:29:18 -05:00 by GiteaMirror · 2 comments
Owner

Originally created by @Tarmenale2 on GitHub (Jun 28, 2025).
Original GitHub issue: https://github.com/ollama/ollama/issues/11232

Originally assigned to: @jmorganca on GitHub.

What is the issue?

When Qwen3 returns multiple tool calls, Ollama builds an empty tool call or skips the last call, even though the model output is correct.


Prompt given to the model:

What is the current UTC time and your GPS position? Give also user names for id 1, 3, 4, 8. Use the tool if available.

EXPECTED RESPONSE:

EXPECTED TOOL CALL: Tool5_getUtcNow
{ "name": "Tool5_getUtcNow", "arguments": {} }
EXPECTED TOOL CALL: Tool6_getGpsPosition
{ "name": "Tool6_getGpsPosition", "arguments": {} }
EXPECTED TOOL CALL: Tool4_getUserName
{ "name": "Tool4_getUserName", "arguments": { "userId": 1 } }
EXPECTED TOOL CALL: Tool4_getUserName
{ "name": "Tool4_getUserName", "arguments": { "userId": 3 } }
EXPECTED TOOL CALL: Tool4_getUserName
{ "name": "Tool4_getUserName", "arguments": { "userId": 4 } }
EXPECTED TOOL CALL: Tool4_getUserName
{ "name": "Tool4_getUserName", "arguments": { "userId": 8 } }

ACTUAL tool calls built by Ollama:

  • Tool5_getUtcNow (OK)
  • Tool6_getGpsPosition (OK)
  • Tool4_getUserName (empty arguments) ← INCORRECT
  • Tool4_getUserName (userId: 1)
  • Tool4_getUserName (userId: 3)
  • Tool4_getUserName (userId: 4)
  • (userId: 8 is missing)

Expected behavior:
All tool calls should be built exactly as provided by the model output. No empty calls, none skipped.


Suggested fix:
Validate required fields before accepting a tool call, and continue parsing after invalid calls.
See attached patch/PR for a working solution.


Please review and do fix in tools.go file or other place where you believe that correct fix should be applied.
tools.go.txt


I've done this change locally and it works with this fix correctly, but you should double check code as I'm not a GO LANG developer.

Relevant log output


OS

No response

GPU

No response

CPU

Intel

Ollama version

0.9.3 (and also checked on main branch)

Originally created by @Tarmenale2 on GitHub (Jun 28, 2025). Original GitHub issue: https://github.com/ollama/ollama/issues/11232 Originally assigned to: @jmorganca on GitHub. ### What is the issue? When Qwen3 returns multiple tool calls, Ollama builds an empty tool call or skips the last call, even though the model output is correct. --- **Prompt given to the model:** ``` What is the current UTC time and your GPS position? Give also user names for id 1, 3, 4, 8. Use the tool if available. ``` **EXPECTED RESPONSE:** ``` EXPECTED TOOL CALL: Tool5_getUtcNow { "name": "Tool5_getUtcNow", "arguments": {} } EXPECTED TOOL CALL: Tool6_getGpsPosition { "name": "Tool6_getGpsPosition", "arguments": {} } EXPECTED TOOL CALL: Tool4_getUserName { "name": "Tool4_getUserName", "arguments": { "userId": 1 } } EXPECTED TOOL CALL: Tool4_getUserName { "name": "Tool4_getUserName", "arguments": { "userId": 3 } } EXPECTED TOOL CALL: Tool4_getUserName { "name": "Tool4_getUserName", "arguments": { "userId": 4 } } EXPECTED TOOL CALL: Tool4_getUserName { "name": "Tool4_getUserName", "arguments": { "userId": 8 } } ``` **ACTUAL tool calls built by Ollama:** * Tool5\_getUtcNow (OK) * Tool6\_getGpsPosition (OK) * Tool4\_getUserName (empty arguments) ← **INCORRECT** * Tool4\_getUserName (userId: 1) * Tool4\_getUserName (userId: 3) * Tool4\_getUserName (userId: 4) * (userId: 8 **is missing**) --- **Expected behavior:** All tool calls should be built exactly as provided by the model output. No empty calls, none skipped. --- **Suggested fix:** Validate required fields before accepting a tool call, and continue parsing after invalid calls. See attached patch/PR for a working solution. --- Please review and do fix in **tools.go** file or other place where you believe that correct fix should be applied. [tools.go.txt](https://github.com/user-attachments/files/20961899/tools.go.txt) --- I've done this change locally and it works with this fix correctly, but you should double check code as I'm not a GO LANG developer. ### Relevant log output ```shell ``` ### OS _No response_ ### GPU _No response_ ### CPU Intel ### Ollama version 0.9.3 (and also checked on main branch)
GiteaMirror added the bug label 2026-04-12 19:29:18 -05:00
Author
Owner

@jmorganca commented on GitHub (Jun 28, 2025):

@Tarmenale2 thanks for reporting. A fix is on the way in #11233

<!-- gh-comment-id:3015985344 --> @jmorganca commented on GitHub (Jun 28, 2025): @Tarmenale2 thanks for reporting. A fix is on the way in #11233
Author
Owner

@Tarmenale2 commented on GitHub (Jun 29, 2025):

@Tarmenale2 thanks for reporting. A fix is on the way in #11233

@jmorganca: Thank you!

<!-- gh-comment-id:3016373079 --> @Tarmenale2 commented on GitHub (Jun 29, 2025): > [@Tarmenale2](https://github.com/Tarmenale2) thanks for reporting. A fix is on the way in [#11233](https://github.com/ollama/ollama/pull/11233) @jmorganca: Thank you!
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/ollama#7399