[GH-ISSUE #11662] Issues calling tools with qwen3:32b #69769

Open
opened 2026-05-04 19:08:23 -05:00 by GiteaMirror · 9 comments
Owner

Originally created by @mitar on GitHub (Aug 5, 2025).
Original GitHub issue: https://github.com/ollama/ollama/issues/11662

What is the issue?

It looks like Ollama does not parse correctly tool calling from qwen3:32b. I have a tool repeat_string and when I ask qwen3:32b to use it, it returns JSON, but that JSON is never parsed and is returned as content. See log below.

I am using Go API to call Ollama.

Relevant log output

"messages": [
  {
    "role": "system",
    "content": "Repeat the input twice, by concatenating the input string without any space. Return only the resulting string. Do not explain anything. You must use the tool."
  },
  {
    "role": "user",
    "content": "bar"
  },
  {
    "role": "assistant",
    "content": "{\"name\": \"repeat_string\", \"arguments\": {\"string\": \"bar\"}}"
  }
]

OS

Linux

GPU

No response

CPU

Intel

Ollama version

0.10.1

Originally created by @mitar on GitHub (Aug 5, 2025). Original GitHub issue: https://github.com/ollama/ollama/issues/11662 ### What is the issue? It looks like Ollama does not parse correctly tool calling from qwen3:32b. I have a tool `repeat_string` and when I ask qwen3:32b to use it, it returns JSON, but that JSON is never parsed and is returned as content. See log below. I am using Go API to call Ollama. ### Relevant log output ```shell "messages": [ { "role": "system", "content": "Repeat the input twice, by concatenating the input string without any space. Return only the resulting string. Do not explain anything. You must use the tool." }, { "role": "user", "content": "bar" }, { "role": "assistant", "content": "{\"name\": \"repeat_string\", \"arguments\": {\"string\": \"bar\"}}" } ] ``` ### OS Linux ### GPU _No response_ ### CPU Intel ### Ollama version 0.10.1
GiteaMirror added the bug label 2026-05-04 19:08:23 -05:00
Author
Owner

@rick-github commented on GitHub (Aug 5, 2025):

Can you provide a standalone program that demonstrates the problem?

#!/usr/bin/env python3

import ollama

def repeat_string(s):
  """
    Repeats the string
    Args:
      s: (string): the string to be repeated.
  """
  return s

messages = [
  {
    "role":"system",
    "content":"Repeat the input twice, by concatenating the input string without any space. Return only the resulting string. Do not explain anything. You must use the tool."
  },
  {
    "role": "user",
    "content": "bar"
  }
]

response = ollama.chat(
    model="qwen3:32b",
    messages=messages,
    tools=[repeat_string])

print(response.message.tool_calls)
$ ./11662.py
[ToolCall(function=Function(name='repeat_string', arguments={'s': 'bar'}))]
<!-- gh-comment-id:3153848418 --> @rick-github commented on GitHub (Aug 5, 2025): Can you provide a standalone program that demonstrates the problem? ```python #!/usr/bin/env python3 import ollama def repeat_string(s): """ Repeats the string Args: s: (string): the string to be repeated. """ return s messages = [ { "role":"system", "content":"Repeat the input twice, by concatenating the input string without any space. Return only the resulting string. Do not explain anything. You must use the tool." }, { "role": "user", "content": "bar" } ] response = ollama.chat( model="qwen3:32b", messages=messages, tools=[repeat_string]) print(response.message.tool_calls) ``` ```console $ ./11662.py [ToolCall(function=Function(name='repeat_string', arguments={'s': 'bar'}))] ```
Author
Owner

@mitar commented on GitHub (Aug 5, 2025):

I can try. It is from my Ollama integration library for Go, I upgraded ollama from 0.5.11 to 0.10.1 and it might be that tool calling integration now broke for some reason. I thought that it is model related, but it seems it is something about how I call tools.

<!-- gh-comment-id:3154013878 --> @mitar commented on GitHub (Aug 5, 2025): I can try. It is from my [Ollama integration library for Go](https://gitlab.com/tozd/go/fun), I upgraded ollama from 0.5.11 to 0.10.1 and it might be that tool calling integration now broke for some reason. I thought that it is model related, but it seems it is something about how I call tools.
Author
Owner

@mitar commented on GitHub (Aug 7, 2025):

My current hypothesis is: I think the issue is that I am adding explicit think=False flag which prefix the completion request with assistant\n<think>\n\n</think>\n\n which I think it is throwing off tool call parsing?

<!-- gh-comment-id:3162698757 --> @mitar commented on GitHub (Aug 7, 2025): My current hypothesis is: I think the issue is that I am adding explicit `think=False` flag which prefix the completion request with `assistant\n<think>\n\n</think>\n\n` which I think it is throwing off tool call parsing?
Author
Owner

@rick-github commented on GitHub (Aug 7, 2025):

--- 11662.py.orig	2025-08-07 10:04:25.245205613 +0200
+++ 11662.py	2025-08-07 10:04:42.070378489 +0200
@@ -24,6 +24,7 @@
 response = ollama.chat(
     model="qwen3:32b",
     messages=messages,
+    think=False,
     tools=[repeat_string])
 
 print(response.message.tool_calls)
$ ./11662.py 
[ToolCall(function=Function(name='repeat_string', arguments={'s': 'bar'}))]
<!-- gh-comment-id:3163000941 --> @rick-github commented on GitHub (Aug 7, 2025): ```diff --- 11662.py.orig 2025-08-07 10:04:25.245205613 +0200 +++ 11662.py 2025-08-07 10:04:42.070378489 +0200 @@ -24,6 +24,7 @@ response = ollama.chat( model="qwen3:32b", messages=messages, + think=False, tools=[repeat_string]) print(response.message.tool_calls) ``` ```console $ ./11662.py [ToolCall(function=Function(name='repeat_string', arguments={'s': 'bar'}))] ```
Author
Owner

@mitar commented on GitHub (Aug 7, 2025):

OK, I added a HTTP proxy to log all requests and responses between my client and Ollama. Broken example:

POST http://ollama:11434/api/chat HTTP/1.1
Host: ollama:11434
Content-Length: 628
Accept: application/x-ndjson
Accept-Encoding: gzip
Content-Type: application/json
User-Agent: ollama/0.0.0 (amd64 linux) Go/go1.24.6

{"model":"qwen3:32b","messages":[{"role":"system","content":"Repeat the input twice, by concatenating the input string without any space. Return only the resulting string. Do not explain anything. You must use the tool."},{"role":"user","content":"test"}],"stream":false,"tools":[{"type":"function","function":{"name":"repeat_string","description":"Repeats the input twice, by concatenating the input string without any space.","parameters":{"type":"object","required":["string"],"properties":{"string":{"type":"string","description":""}}}}}],"options":{"num_ctx":40960,"num_predict":-2,"seed":42,"temperature":0},"think":false}
HTTP/1.1 200 OK
Content-Length: 366
Content-Type: application/json; charset=utf-8
Date: Thu, 07 Aug 2025 21:15:34 GMT

{"model":"qwen3:32b","created_at":"2025-08-07T21:15:34.243252183Z","message":{"role":"assistant","content":"{\"name\": \"repeat_string\", \"arguments\": {\"string\": \"test\"}}"},"done_reason":"stop","done":true,"total_duration":5368408904,"load_duration":36120002,"prompt_eval_count":187,"prompt_eval_duration":1153943205,"eval_count":17,"eval_duration":4172556977}

It looks like model sometimes simply does not output tool tags.

I have example where it does:

POST http://ollama:11434/api/chat HTTP/1.1
Host: ollama:11434
Content-Length: 627
Accept: application/x-ndjson
Accept-Encoding: gzip
Content-Type: application/json
User-Agent: ollama/0.0.0 (amd64 linux) Go/go1.24.6

{"model":"qwen3:32b","messages":[{"role":"system","content":"Repeat the input twice, by concatenating the input string without any space. Return only the resulting string. Do not explain anything. You must use the tool."},{"role":"user","content":"foo"}],"stream":false,"tools":[{"type":"function","function":{"name":"repeat_string","description":"Repeats the input twice, by concatenating the input string without any space.","parameters":{"type":"object","required":["string"],"properties":{"string":{"type":"string","description":""}}}}}],"options":{"num_ctx":40960,"num_predict":-2,"seed":42,"temperature":0},"think":false}
HTTP/1.1 200 OK
Content-Length: 382
Content-Type: application/json; charset=utf-8
Date: Thu, 07 Aug 2025 21:14:57 GMT

{"model":"qwen3:32b","created_at":"2025-08-07T21:14:57.45876786Z","message":{"role":"assistant","content":"","tool_calls":[{"function":{"name":"repeat_string","arguments":{"string":"foo"}}}]},"done_reason":"stop","done":true,"total_duration":29126970953,"load_duration":47211329,"prompt_eval_count":187,"prompt_eval_duration":17845629426,"eval_count":20,"eval_duration":11227934608}
<!-- gh-comment-id:3165810328 --> @mitar commented on GitHub (Aug 7, 2025): OK, I added a HTTP proxy to log all requests and responses between my client and Ollama. Broken example: ``` POST http://ollama:11434/api/chat HTTP/1.1 Host: ollama:11434 Content-Length: 628 Accept: application/x-ndjson Accept-Encoding: gzip Content-Type: application/json User-Agent: ollama/0.0.0 (amd64 linux) Go/go1.24.6 {"model":"qwen3:32b","messages":[{"role":"system","content":"Repeat the input twice, by concatenating the input string without any space. Return only the resulting string. Do not explain anything. You must use the tool."},{"role":"user","content":"test"}],"stream":false,"tools":[{"type":"function","function":{"name":"repeat_string","description":"Repeats the input twice, by concatenating the input string without any space.","parameters":{"type":"object","required":["string"],"properties":{"string":{"type":"string","description":""}}}}}],"options":{"num_ctx":40960,"num_predict":-2,"seed":42,"temperature":0},"think":false} ``` ``` HTTP/1.1 200 OK Content-Length: 366 Content-Type: application/json; charset=utf-8 Date: Thu, 07 Aug 2025 21:15:34 GMT {"model":"qwen3:32b","created_at":"2025-08-07T21:15:34.243252183Z","message":{"role":"assistant","content":"{\"name\": \"repeat_string\", \"arguments\": {\"string\": \"test\"}}"},"done_reason":"stop","done":true,"total_duration":5368408904,"load_duration":36120002,"prompt_eval_count":187,"prompt_eval_duration":1153943205,"eval_count":17,"eval_duration":4172556977} ``` It looks like model sometimes simply does not output tool tags. I have example where it does: ``` POST http://ollama:11434/api/chat HTTP/1.1 Host: ollama:11434 Content-Length: 627 Accept: application/x-ndjson Accept-Encoding: gzip Content-Type: application/json User-Agent: ollama/0.0.0 (amd64 linux) Go/go1.24.6 {"model":"qwen3:32b","messages":[{"role":"system","content":"Repeat the input twice, by concatenating the input string without any space. Return only the resulting string. Do not explain anything. You must use the tool."},{"role":"user","content":"foo"}],"stream":false,"tools":[{"type":"function","function":{"name":"repeat_string","description":"Repeats the input twice, by concatenating the input string without any space.","parameters":{"type":"object","required":["string"],"properties":{"string":{"type":"string","description":""}}}}}],"options":{"num_ctx":40960,"num_predict":-2,"seed":42,"temperature":0},"think":false} ``` ``` HTTP/1.1 200 OK Content-Length: 382 Content-Type: application/json; charset=utf-8 Date: Thu, 07 Aug 2025 21:14:57 GMT {"model":"qwen3:32b","created_at":"2025-08-07T21:14:57.45876786Z","message":{"role":"assistant","content":"","tool_calls":[{"function":{"name":"repeat_string","arguments":{"string":"foo"}}}]},"done_reason":"stop","done":true,"total_duration":29126970953,"load_duration":47211329,"prompt_eval_count":187,"prompt_eval_duration":17845629426,"eval_count":20,"eval_duration":11227934608} ```
Author
Owner

@rick-github commented on GitHub (Aug 7, 2025):

$ diff -u 11662.py.orig 11662.py
--- 11662.py.orig       2025-08-07 10:04:25.245205613 +0200
+++ 11662.py    2025-08-07 23:51:19.449804155 +0200
@@ -24,6 +24,10 @@
 response = ollama.chat(
     model="qwen3:32b",
     messages=messages,
+    think=False,
+    options={
+      "num_ctx":40960,"num_predict":-2,"seed":42,"temperature":0,
+    },
     tools=[repeat_string])
 
 print(response.message.tool_calls)
$ for i in {0..99} ; do ./11662.py ; done | sort | uniq -c
    100 [ToolCall(function=Function(name='repeat_string', arguments={'s': 'bar'}))]

Try adding OLLAMA_DEBUG=2 to the server environment, running your test, and post the log from a failure.

<!-- gh-comment-id:3166096303 --> @rick-github commented on GitHub (Aug 7, 2025): ```diff $ diff -u 11662.py.orig 11662.py --- 11662.py.orig 2025-08-07 10:04:25.245205613 +0200 +++ 11662.py 2025-08-07 23:51:19.449804155 +0200 @@ -24,6 +24,10 @@ response = ollama.chat( model="qwen3:32b", messages=messages, + think=False, + options={ + "num_ctx":40960,"num_predict":-2,"seed":42,"temperature":0, + }, tools=[repeat_string]) print(response.message.tool_calls) ``` ```console $ for i in {0..99} ; do ./11662.py ; done | sort | uniq -c 100 [ToolCall(function=Function(name='repeat_string', arguments={'s': 'bar'}))] ``` Try adding OLLAMA_DEBUG=2 to the server environment, running your test, and post the log from a failure.
Author
Owner

@mitar commented on GitHub (Aug 8, 2025):

So it fails with test user string, while it work with foo user string.

Here is log with OLLAMA_DEBUG=2 enabled (there are more tests which are running, you can find these with repeat_string). The issue is that I do not see anything useful in these logs. This is why I went to log HTTP requests/responses.

At this point it looks to me like model simply behaves badly on some input and omits tool call tags.

<!-- gh-comment-id:3166675146 --> @mitar commented on GitHub (Aug 8, 2025): So it fails with `test` user string, while it work with `foo` user string. Here is log with [OLLAMA_DEBUG=2 enabled](https://gitlab.com/tozd/go/fun/-/jobs/10922273923) (there are more tests which are running, you can find these with `repeat_string`). The issue is that I do not see anything useful in these logs. This is why I went to log HTTP requests/responses. At this point it looks to me like model simply behaves badly on some input and omits tool call tags.
Author
Owner

@rick-github commented on GitHub (Aug 8, 2025):

The current user is not authorized to access the job log.

Add the log to this issue.

<!-- gh-comment-id:3167162026 --> @rick-github commented on GitHub (Aug 8, 2025): ``` The current user is not authorized to access the job log. ``` Add the log to this issue.
Author
Owner

@mitar commented on GitHub (Aug 8, 2025):

Oh, sorry. Project is otherwise public, but for logs with service logs enabled (using CI_DEBUG_SERVICES) GitLab seems to hide the logs.

job.log

<!-- gh-comment-id:3167349317 --> @mitar commented on GitHub (Aug 8, 2025): Oh, sorry. Project is otherwise public, but for logs with service logs enabled (using `CI_DEBUG_SERVICES`) GitLab seems to hide the logs. [job.log](https://github.com/user-attachments/files/21681535/job.log)
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/ollama#69769