[GH-ISSUE #11621] Qwen3-Coder missing Tools and FIM support in template #33435

Closed
opened 2026-04-22 16:05:22 -05:00 by GiteaMirror · 64 comments
Owner

Originally created by @d1g1t on GitHub (Aug 1, 2025).
Original GitHub issue: https://github.com/ollama/ollama/issues/11621

What is the issue?

As per https://github.com/QwenLM/Qwen3-Coder/blob/main/README.md, both Tool calling and FIM usage are supported

Current template - https://ollama.com/library/qwen3-coder:30b/blobs/c6a614465b37

Relevant log output


OS

No response

GPU

No response

CPU

No response

Ollama version

No response

Originally created by @d1g1t on GitHub (Aug 1, 2025). Original GitHub issue: https://github.com/ollama/ollama/issues/11621 ### What is the issue? As per https://github.com/QwenLM/Qwen3-Coder/blob/main/README.md, both Tool calling and FIM usage are supported Current template - https://ollama.com/library/qwen3-coder:30b/blobs/c6a614465b37 ### Relevant log output ```shell ``` ### OS _No response_ ### GPU _No response_ ### CPU _No response_ ### Ollama version _No response_
GiteaMirror added the bug label 2026-04-22 16:05:22 -05:00
Author
Owner

@nicolasembleton commented on GitHub (Aug 1, 2025):

Yes, I can confirm.

<!-- gh-comment-id:3143704308 --> @nicolasembleton commented on GitHub (Aug 1, 2025): Yes, I can confirm.
Author
Owner

@awaescher commented on GitHub (Aug 1, 2025):

This should be the reason why qwen3-coder can be selected in the Copilot model dropdown in Visual Studio Code, but it will not appear in the model selection afterwards.

Image Image
<!-- gh-comment-id:3143738187 --> @awaescher commented on GitHub (Aug 1, 2025): This should be the reason why qwen3-coder can be selected in the Copilot model dropdown in Visual Studio Code, but it will not appear in the model selection afterwards. <img width="617" height="160" alt="Image" src="https://github.com/user-attachments/assets/1b28965a-d6ad-42eb-8dc7-693be400eed3" /> <img width="292" height="345" alt="Image" src="https://github.com/user-attachments/assets/532093a7-d5e1-4ff9-b5ca-f63000727cfa" />
Author
Owner

@Ramzee-S commented on GitHub (Aug 1, 2025):

Same/similar problem here.

In goose (code name goose) its not working with the ollama tool error:
request failed: registry.ollama.ai/library/qwen3-coder:latest does not support tools (type: api_error) (status 400)

In Anon Kode (an open source claude code derivative that was DMCA taken down (still downloadable using npm i -g anon-kode)) not working with error:
Failed to configure provider: init chat completion request with tool did not succeed. API Error: API request failed:
registry.ollama.ai/library/qwen3-coder:latest does not support tools

However, when i use ollama trough the void editor, qwen3-code shows up, and is working (although not great).

Maybe this this related to:
https://github.com/langflow-ai/langflow/issues/8805
https://github.com/langflow-ai/langflow/issues/8805#issuecomment-3024294926
If so then this is all because qwen3-code it is not in the Langflow list, and therefore 'officially' does not support tools.
How to update that list? Do we really need that list? Is there some other temporary work around like disabling the official tool requirements but still using them any way?

<!-- gh-comment-id:3143788291 --> @Ramzee-S commented on GitHub (Aug 1, 2025): Same/similar problem here. In goose (code name goose) its not working with the ollama tool error: request failed: registry.ollama.ai/library/qwen3-coder:latest does not support tools (type: api_error) (status 400) In Anon Kode (an open source claude code derivative that was DMCA taken down (still downloadable using npm i -g anon-kode)) not working with error: Failed to configure provider: init chat completion request with tool did not succeed. API Error: API request failed: registry.ollama.ai/library/qwen3-coder:latest does not support tools However, when i use ollama trough the void editor, qwen3-code shows up, and is working (although not great). Maybe this this related to: https://github.com/langflow-ai/langflow/issues/8805 https://github.com/langflow-ai/langflow/issues/8805#issuecomment-3024294926 If so then this is all because qwen3-code it is not in the Langflow list, and therefore 'officially' does not support tools. How to update that list? Do we really need that list? Is there some other temporary work around like disabling the official tool requirements but still using them any way?
Author
Owner

@pminervini commented on GitHub (Aug 1, 2025):

Why there's no tool use support in the ollama version? https://huggingface.co/Qwen/Qwen3-Coder-30B-A3B-Instruct

<!-- gh-comment-id:3144361614 --> @pminervini commented on GitHub (Aug 1, 2025): Why there's no tool use support in the ollama version? https://huggingface.co/Qwen/Qwen3-Coder-30B-A3B-Instruct
Author
Owner

@0xn3bs commented on GitHub (Aug 1, 2025):

Having same issue in Goose using Ollama version
Request failed: registry.ollama.ai/library/qwen3-coder:latest does not support tools (type: api_error) (status 400)

<!-- gh-comment-id:3145178151 --> @0xn3bs commented on GitHub (Aug 1, 2025): Having same issue in Goose using Ollama version `Request failed: registry.ollama.ai/library/qwen3-coder:latest does not support tools (type: api_error) (status 400)`
Author
Owner

@d1g1t commented on GitHub (Aug 1, 2025):

As a temporary workaround, for tools, using the template from one of the non-thinking qwen3 models works fine.
Such as https://ollama.com/library/qwen3:30b-a3b-instruct-2507-fp16/blobs/636353bf6b2f

<!-- gh-comment-id:3145197721 --> @d1g1t commented on GitHub (Aug 1, 2025): As a temporary workaround, for tools, using the template from one of the non-thinking qwen3 models works fine. Such as https://ollama.com/library/qwen3:30b-a3b-instruct-2507-fp16/blobs/636353bf6b2f
Author
Owner

@Wangyiquan95 commented on GitHub (Aug 1, 2025):

same issue for VS code continue: "registry.ollama.ai/library/qwen3-coder:latest does not support tools"

<!-- gh-comment-id:3145659157 --> @Wangyiquan95 commented on GitHub (Aug 1, 2025): same issue for VS code continue: "registry.ollama.ai/library/qwen3-coder:latest does not support tools"
Author
Owner

@hoborobott commented on GitHub (Aug 1, 2025):

same error

<!-- gh-comment-id:3145932114 --> @hoborobott commented on GitHub (Aug 1, 2025): same error
Author
Owner

@0xn3bs commented on GitHub (Aug 2, 2025):

As a temporary workaround, for tools, using the template from one of the non-thinking qwen3 models works fine. Such as https://ollama.com/library/qwen3:30b-a3b-instruct-2507-fp16/blobs/636353bf6b2f

I tried this. It sort of works, but likely missed something. Would you be able to provide a gist with your modelfile?

<!-- gh-comment-id:3146257722 --> @0xn3bs commented on GitHub (Aug 2, 2025): > As a temporary workaround, for tools, using the template from one of the non-thinking qwen3 models works fine. Such as https://ollama.com/library/qwen3:30b-a3b-instruct-2507-fp16/blobs/636353bf6b2f I tried this. It _sort of_ works, but likely missed something. Would you be able to provide a gist with your modelfile?
Author
Owner

@d1g1t commented on GitHub (Aug 2, 2025):

As a temporary workaround, for tools, using the template from one of the non-thinking qwen3 models works fine. Such as https://ollama.com/library/qwen3:30b-a3b-instruct-2507-fp16/blobs/636353bf6b2f

I tried this. It sort of works, but likely missed something. Would you be able to provide a gist with your modelfile?

I used the template I linked as is. I only tested if it actually called the tools with that template and not much more. I pulled the qwen3-coder model from ollama and replaced the contents of the template file in the blob directory sha256-c6a614465b370a1b4eb95e964f907a24396a5bb842eab6cc730f2cc4c309dc48

I tried copying over the FIM stuff from qwen2.5-coder with trial and error. It kind of worked, but code autocomplete seemed much worse than the smaller 2.5 coder base models and it had issues with indentation (I'm not familiar with go templates, so there could easily have been mistakes there).

I was hoping the default template would be updated or someone who knew what they were doing would share the right template here

<!-- gh-comment-id:3146302387 --> @d1g1t commented on GitHub (Aug 2, 2025): > > As a temporary workaround, for tools, using the template from one of the non-thinking qwen3 models works fine. Such as https://ollama.com/library/qwen3:30b-a3b-instruct-2507-fp16/blobs/636353bf6b2f > > I tried this. It _sort of_ works, but likely missed something. Would you be able to provide a gist with your modelfile? I used the template I linked as is. I only tested if it actually called the tools with that template and not much more. I pulled the qwen3-coder model from ollama and replaced the contents of the template file in the blob directory `sha256-c6a614465b370a1b4eb95e964f907a24396a5bb842eab6cc730f2cc4c309dc48` I tried copying over the FIM stuff from qwen2.5-coder with trial and error. It kind of worked, but code autocomplete seemed much worse than the smaller 2.5 coder base models and it had issues with indentation (I'm not familiar with go templates, so there could easily have been mistakes there). I was hoping the default template would be updated or someone who knew what they were doing would share the right template here
Author
Owner

@Ramzee-S commented on GitHub (Aug 2, 2025):

I have tried (with llm) help to modify the template. I can get it to work to the point that it does not give the tool error. So it runs. But agents then sort of crash in the middle of using the tools. There is no normal continuous flow like usual.
I have tried with hybrid templates from normal Qwen3 and Qwen2.5 coder. But without very usefull success. I hope some one really know something more about these templates can help. How are these templates generated, do they come from Alibaba/Qwen? or are they generated by ollama team? or llama team?

<!-- gh-comment-id:3146395558 --> @Ramzee-S commented on GitHub (Aug 2, 2025): I have tried (with llm) help to modify the template. I can get it to work to the point that it does not give the tool error. So it runs. But agents then sort of crash in the middle of using the tools. There is no normal continuous flow like usual. I have tried with hybrid templates from normal Qwen3 and Qwen2.5 coder. But without very usefull success. I hope some one really know something more about these templates can help. How are these templates generated, do they come from Alibaba/Qwen? or are they generated by ollama team? or llama team?
Author
Owner

@moll commented on GitHub (Aug 2, 2025):

But agents then sort of crash in the middle of using the tools. There is no normal continuous flow like usual.

I've seen this with multiple models and my current understanding is that it's because Ollama insists on parsing tool calls and filtering out non-existent ones. What probably happened is that the model hallucinated a tool and, Ollama having filtered it out, the conversation stopped abruptly. It'd probably be better if Ollama didn't filter out non-existent calls and instead let us API users inform the model it should retry.

<!-- gh-comment-id:3146398497 --> @moll commented on GitHub (Aug 2, 2025): > But agents then sort of crash in the middle of using the tools. There is no normal continuous flow like usual. I've seen this with multiple models and my current understanding is that it's because Ollama insists on parsing tool calls and filtering out non-existent ones. What probably happened is that the model hallucinated a tool and, Ollama having filtered it out, the conversation stopped abruptly. It'd probably be better if Ollama didn't filter out non-existent calls and instead let us API users inform the model it should retry.
Author
Owner

@javier-lasheras commented on GitHub (Aug 2, 2025):

My Modelfile (use ollama create to derive a working model):

FROM qwen3-coder:latest

TEMPLATE """{{- if .Suffix }}<|fim_prefix|>{{ .Prompt }}<|fim_suffix|>{{ .Suffix }}<|fim_middle|>
{{- else -}}
{{- $lastUserIdx := -1 -}}
{{- range $idx, $msg := .Messages -}}
{{- if eq $msg.Role "user" }}{{ $lastUserIdx = $idx }}{{ end -}}
{{- end }}
{{- if or .System .Tools }}<|im_start|>system
{{ if .System }}
{{ .System }}
{{- end }}
{{- if .Tools }}

# Tools

You may call one or more functions to assist with the user query.

You are provided with function signatures within <tools></tools> XML tags:
<tools>
{{- range .Tools }}
{"type": "function", "function": {{ .Function }}}
{{- end }}
</tools>

For each function call, return a json object with function name and arguments within <tool_call></tool_call> XML tags:
<tool_call>
{"name": <function-name>, "arguments": <args-json-object>}
</tool_call>
{{- end -}}
<|im_end|>
{{ end }}
{{- range $i, $_ := .Messages }}
{{- $last := eq (len (slice $.Messages $i)) 1 -}}
{{- if eq .Role "user" }}<|im_start|>user
{{ .Content }}
{{ else if eq .Role "assistant" }}<|im_start|>assistant
{{- if .Content }}
{{ .Content }}
{{- else if .ToolCalls }}
{{- range .ToolCalls }}
<tool_call>
{"name": "{{ .Function.Name }}", "arguments": {{ .Function.Arguments }}}
</tool_call>
{{- end }}
{{- end }}{{ if not $last }}<|im_end|>
{{ end }}
{{- else if eq .Role "tool" }}<|im_start|>user
<tool_response>
{{ .Content }}
</tool_response><|im_end|>
{{ end }}
{{- if and (ne .Role "assistant") $last }}<|im_start|>assistant
{{ end }}
{{- end }}
{{- end }}
"""

I suppose it's similar to @d1g1t 's one.

To test it I have modified fill-in-middle.py and multi-tool.py examples from ollama-python repo and looks good for me. Can anyone test it. I'm not an expert either.

<!-- gh-comment-id:3146416873 --> @javier-lasheras commented on GitHub (Aug 2, 2025): My Modelfile (use `ollama create` to derive a working model): ``` FROM qwen3-coder:latest TEMPLATE """{{- if .Suffix }}<|fim_prefix|>{{ .Prompt }}<|fim_suffix|>{{ .Suffix }}<|fim_middle|> {{- else -}} {{- $lastUserIdx := -1 -}} {{- range $idx, $msg := .Messages -}} {{- if eq $msg.Role "user" }}{{ $lastUserIdx = $idx }}{{ end -}} {{- end }} {{- if or .System .Tools }}<|im_start|>system {{ if .System }} {{ .System }} {{- end }} {{- if .Tools }} # Tools You may call one or more functions to assist with the user query. You are provided with function signatures within <tools></tools> XML tags: <tools> {{- range .Tools }} {"type": "function", "function": {{ .Function }}} {{- end }} </tools> For each function call, return a json object with function name and arguments within <tool_call></tool_call> XML tags: <tool_call> {"name": <function-name>, "arguments": <args-json-object>} </tool_call> {{- end -}} <|im_end|> {{ end }} {{- range $i, $_ := .Messages }} {{- $last := eq (len (slice $.Messages $i)) 1 -}} {{- if eq .Role "user" }}<|im_start|>user {{ .Content }} {{ else if eq .Role "assistant" }}<|im_start|>assistant {{- if .Content }} {{ .Content }} {{- else if .ToolCalls }} {{- range .ToolCalls }} <tool_call> {"name": "{{ .Function.Name }}", "arguments": {{ .Function.Arguments }}} </tool_call> {{- end }} {{- end }}{{ if not $last }}<|im_end|> {{ end }} {{- else if eq .Role "tool" }}<|im_start|>user <tool_response> {{ .Content }} </tool_response><|im_end|> {{ end }} {{- if and (ne .Role "assistant") $last }}<|im_start|>assistant {{ end }} {{- end }} {{- end }} """ ``` I suppose it's similar to @d1g1t 's one. To test it I have modified `fill-in-middle.py` and `multi-tool.py` examples from ollama-python repo and looks good for me. Can anyone test it. I'm not an expert either.
Author
Owner

@minzanupam commented on GitHub (Aug 3, 2025):

The above provided template did work for me, so I create my own. I hope that this is helpful.

FROM qwen3-coder:latest

TEMPLATE """
{{- if .Messages }}
{{- if or .System .Tools }}<|im_start|>system
{{- if .System }}
{{ .System }}
{{- end }}
{{- if .Tools }}

# Tools

You may call one or more functions to assist with the user query.

You are provided with function signatures within <tools></tools> XML tags:
<tools>
{{- range .Tools }}
{"type": "function", "function": {{ .Function }}}
{{- end }}
</tools>

For each function call, return a json object with function name and arguments within <tool_call></tool_call> XML tags:
<tool_call>
{"name": <function-name>, "arguments": <args-json-object>}
</tool_call>
{{- end }}<|im_end|>
{{ end }}
{{- range $i, $_ := .Messages }}
{{- $last := eq (len (slice $.Messages $i)) 1 -}}
{{- if eq .Role "user" }}<|im_start|>user
{{ .Content }}<|im_end|>
{{ else if eq .Role "assistant" }}<|im_start|>assistant
{{ if .Content }}{{ .Content }}
{{- else if .ToolCalls }}<tool_call>
{{ range .ToolCalls }}{"name": "{{ .Function.Name }}", "arguments": {{ .Function.Arguments }}}
{{ end }}</tool_call>
{{- end }}{{ if not $last }}<|im_end|>
{{ end }}
{{- else if eq .Role "tool" }}<|im_start|>user
<tool_response>
{{ .Content }}
</tool_response><|im_end|>
{{ end }}
{{- if and (ne .Role "assistant") $last }}<|im_start|>assistant
{{ end }}
{{- end }}
{{- else }}
{{- if .System }}<|im_start|>system
{{ .System }}<|im_end|>
{{ end }}{{ if .Prompt }}<|im_start|>user
{{ .Prompt }}<|im_end|>
{{ end }}<|im_start|>assistant
{{ end }}{{ .Response }}{{ if .Response }}<|im_end|>{{ end }}
"""

PARAMETER temperature 0.7
PARAMETER top_p 0.8
PARAMETER top_k 20
PARAMETER repeat_penalty 1.05

<!-- gh-comment-id:3146969862 --> @minzanupam commented on GitHub (Aug 3, 2025): The above provided template did work for me, so I create my own. I hope that this is helpful. ``` FROM qwen3-coder:latest TEMPLATE """ {{- if .Messages }} {{- if or .System .Tools }}<|im_start|>system {{- if .System }} {{ .System }} {{- end }} {{- if .Tools }} # Tools You may call one or more functions to assist with the user query. You are provided with function signatures within <tools></tools> XML tags: <tools> {{- range .Tools }} {"type": "function", "function": {{ .Function }}} {{- end }} </tools> For each function call, return a json object with function name and arguments within <tool_call></tool_call> XML tags: <tool_call> {"name": <function-name>, "arguments": <args-json-object>} </tool_call> {{- end }}<|im_end|> {{ end }} {{- range $i, $_ := .Messages }} {{- $last := eq (len (slice $.Messages $i)) 1 -}} {{- if eq .Role "user" }}<|im_start|>user {{ .Content }}<|im_end|> {{ else if eq .Role "assistant" }}<|im_start|>assistant {{ if .Content }}{{ .Content }} {{- else if .ToolCalls }}<tool_call> {{ range .ToolCalls }}{"name": "{{ .Function.Name }}", "arguments": {{ .Function.Arguments }}} {{ end }}</tool_call> {{- end }}{{ if not $last }}<|im_end|> {{ end }} {{- else if eq .Role "tool" }}<|im_start|>user <tool_response> {{ .Content }} </tool_response><|im_end|> {{ end }} {{- if and (ne .Role "assistant") $last }}<|im_start|>assistant {{ end }} {{- end }} {{- else }} {{- if .System }}<|im_start|>system {{ .System }}<|im_end|> {{ end }}{{ if .Prompt }}<|im_start|>user {{ .Prompt }}<|im_end|> {{ end }}<|im_start|>assistant {{ end }}{{ .Response }}{{ if .Response }}<|im_end|>{{ end }} """ PARAMETER temperature 0.7 PARAMETER top_p 0.8 PARAMETER top_k 20 PARAMETER repeat_penalty 1.05 ```
Author
Owner

@d1g1t commented on GitHub (Aug 3, 2025):

If tool calls still feel off, it may be due to Qwen3-Coder expecting tool definition and calling to be in an xml format rather than json (https://github.com/ggml-org/llama.cpp/issues/15012).

Template on the Qwen3-Coder model page https://huggingface.co/Qwen/Qwen3-Coder-30B-A3B-Instruct?chat_template=default
The regular Qwen3 does not have this (https://huggingface.co/Qwen/Qwen3-30B-A3B-Instruct-2507?chat_template=default)

<!-- gh-comment-id:3146989210 --> @d1g1t commented on GitHub (Aug 3, 2025): If tool calls still feel off, it may be due to Qwen3-Coder expecting tool definition and calling to be in an xml format rather than json (https://github.com/ggml-org/llama.cpp/issues/15012). Template on the Qwen3-Coder model page https://huggingface.co/Qwen/Qwen3-Coder-30B-A3B-Instruct?chat_template=default The regular Qwen3 does not have this (https://huggingface.co/Qwen/Qwen3-30B-A3B-Instruct-2507?chat_template=default)
Author
Owner

@junzhang-bjtu commented on GitHub (Aug 3, 2025):

https://ollama.com/SimonPu/Qwen3-Coder:30B-Instruct_Q4_K_XL/blobs/84f542b6545d
You can try this template.

<!-- gh-comment-id:3147838518 --> @junzhang-bjtu commented on GitHub (Aug 3, 2025): [https://ollama.com/SimonPu/Qwen3-Coder:30B-Instruct_Q4_K_XL/blobs/84f542b6545d](https://ollama.com/SimonPu/Qwen3-Coder:30B-Instruct_Q4_K_XL/blobs/84f542b6545d) You can try this template.
Author
Owner

@javier-lasheras commented on GitHub (Aug 3, 2025):

I've asked Qwen coder chat for a solution and give me some complaints on golang templates limitations to migrate jinja templates https://chat.qwen.ai/s/eee02f5c-757c-455f-913f-c6b46a174fef?fev=0.0.170

Anyway is needed add a big if/else/end block for FIM support:

{{- if .Suffix }}<|fim_prefix|>{{ .Prompt }}<|fim_suffix|>{{ .Suffix }}<|fim_middle|>
{{- else -}}
[Given template (the good one with tool support)]
{{- end }}

I've not checked it and I've not time for now to prepare a good test cases. I'll hope be useful for someone.

<!-- gh-comment-id:3148305388 --> @javier-lasheras commented on GitHub (Aug 3, 2025): I've asked Qwen coder chat for a solution and give me some complaints on golang templates limitations to migrate jinja templates https://chat.qwen.ai/s/eee02f5c-757c-455f-913f-c6b46a174fef?fev=0.0.170 Anyway is needed add a big if/else/end block for FIM support: ``` {{- if .Suffix }}<|fim_prefix|>{{ .Prompt }}<|fim_suffix|>{{ .Suffix }}<|fim_middle|> {{- else -}} [Given template (the good one with tool support)] {{- end }} ``` I've not checked it and I've not time for now to prepare a good test cases. I'll hope be useful for someone.
Author
Owner

@minzanupam commented on GitHub (Aug 3, 2025):

If tool calls still feel off, it may be due to Qwen3-Coder expecting tool definition and calling to be in an xml format rather than json (ggml-org/llama.cpp#15012).

So all we can do is wait until the llama.cpp team add a custom parser for qwen3-coder-30b-a3b then this issue be fixed in ollama?

<!-- gh-comment-id:3148396250 --> @minzanupam commented on GitHub (Aug 3, 2025): > If tool calls still feel off, it may be due to Qwen3-Coder expecting tool definition and calling to be in an xml format rather than json ([ggml-org/llama.cpp#15012](https://github.com/ggml-org/llama.cpp/issues/15012)). So all we can do is wait until the llama.cpp team add a custom parser for qwen3-coder-30b-a3b then this issue be fixed in ollama?
Author
Owner

@fenris commented on GitHub (Aug 3, 2025):

$ curl -s localhost:11434/api/show -d '{"model":"qwen3-coder:30b-a3b-q8_0"}' | jq .capabilities
[
"completion"
]

$ ollama create qwen3-coder-fix:30b-a3b-q8_0 -f Modelfile
gathering model components
using existing layer sha256:1a8a72d99ed2b27bcc69ca3c0c858487a52202e94cf924a92ba99e0816b9c014
using existing layer sha256:d18a5cc71b84bc4af394a31116bd3932b42241de70c77d2b76d69a314ec8aa12
using existing layer sha256:1d68e259ca720b7d3b2256e2890861064652662b87705713ddcba09e42deee79
using existing layer sha256:84ffc241f2d42ea4ecfe4d552a250babfbca958aabc7cf5d16ec6fef0b7fcaae
writing manifest
success

$ curl -s localhost:11434/api/show -d '{"model":"qwen3-coder-fix:30b-a3b-q8_0"}' | jq .capabilities
[
"completion",
"tools"
]

thanks !

<!-- gh-comment-id:3148399040 --> @fenris commented on GitHub (Aug 3, 2025): $ curl -s localhost:11434/api/show -d '{"model":"qwen3-coder:30b-a3b-q8_0"}' | jq .capabilities [ "completion" ] $ ollama create qwen3-coder-fix:30b-a3b-q8_0 -f Modelfile gathering model components using existing layer sha256:1a8a72d99ed2b27bcc69ca3c0c858487a52202e94cf924a92ba99e0816b9c014 using existing layer sha256:d18a5cc71b84bc4af394a31116bd3932b42241de70c77d2b76d69a314ec8aa12 using existing layer sha256:1d68e259ca720b7d3b2256e2890861064652662b87705713ddcba09e42deee79 using existing layer sha256:84ffc241f2d42ea4ecfe4d552a250babfbca958aabc7cf5d16ec6fef0b7fcaae writing manifest success $ curl -s localhost:11434/api/show -d '{"model":"qwen3-coder-fix:30b-a3b-q8_0"}' | jq .capabilities [ "completion", "tools" ] thanks !
Author
Owner

@bradleyandrew commented on GitHub (Aug 4, 2025):

I was able to partially get this working by using the attached modelfile which is similar to @javier-lasheras and @minzanupam modelfiles detailed above. For reference this was created as follows:
ollama create qwen3-coder-with-tools-32k -f path/to/modelfile/qwen3-coder.modelfile

This allows Qwen3 Coder to run in Qwen Code.

However when you give it a task, it seems to not be able to actually execute the tools. Below is an image of the Qwen Output in Terminal:
Image

I assume that this is the LLM returning tool output:
{"name": "write_file", "arguments": {"file_path": "/qwen-test/index.html", "content":

However Qwen Code does not execute it or prompt the user to create the file and commit it to disk. I have read that qwen3-coder returns tool output in XML not JSON so I suspect this is what the issue is here. It seems there is some work on converting XML to JSON via llama.cpp happening but not sure when/if this will come to Ollama. From what I have read there is currently no solution and it seems that Ollama + qwen3-coder:30b + Qwen Code CLI is not usable at this stage.

Modelfile:
qwen3-coder-modelfile.zip

<!-- gh-comment-id:3149154991 --> @bradleyandrew commented on GitHub (Aug 4, 2025): I was able to partially get this working by using the attached modelfile which is similar to @javier-lasheras and @minzanupam modelfiles detailed above. For reference this was created as follows: `ollama create qwen3-coder-with-tools-32k -f path/to/modelfile/qwen3-coder.modelfile` This allows Qwen3 Coder to run in [Qwen Code](https://github.com/QwenLM/qwen-code). However when you give it a task, it seems to not be able to actually execute the tools. Below is an image of the Qwen Output in Terminal: <img width="1649" height="1211" alt="Image" src="https://github.com/user-attachments/assets/c336c23c-465a-4ca9-acfa-9d67ff384595" /> I assume that this is the LLM returning tool output: `{"name": "write_file", "arguments": {"file_path": "/qwen-test/index.html", "content": ` However Qwen Code does not execute it or prompt the user to create the file and commit it to disk. I have read that qwen3-coder returns tool output in XML not JSON so I suspect this is what the issue is here. It seems there is some work on converting XML to JSON via llama.cpp happening but not sure when/if this will come to Ollama. From what I have read there is currently no solution and it seems that Ollama + qwen3-coder:30b + Qwen Code CLI is not usable at this stage. Modelfile: [qwen3-coder-modelfile.zip](https://github.com/user-attachments/files/21570760/qwen3-coder-modelfile.zip)
Author
Owner

@pminervini commented on GitHub (Aug 4, 2025):

I got Qwen Code to work with qwen3-coder by just using LM Studio (Beta channel), with OPENAI_MODEL=qwen/qwen3-coder-30b qwen -y --openai-api-key apikey --openai-base-url http://localhost:1234/v1 -- so I guess it boils down to how tool calls are parsed and returned by the endpoint

Image
<!-- gh-comment-id:3152655274 --> @pminervini commented on GitHub (Aug 4, 2025): I got Qwen Code to work with qwen3-coder by just using LM Studio (Beta channel), with `OPENAI_MODEL=qwen/qwen3-coder-30b qwen -y --openai-api-key apikey --openai-base-url http://localhost:1234/v1` -- so I guess it boils down to how tool calls are parsed and returned by the endpoint <img width="1865" height="434" alt="Image" src="https://github.com/user-attachments/assets/123d7bf9-0cdc-4877-824a-e54e7c8c1ee2" />
Author
Owner

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

I have managed to get it to work partially in vscode with Copilot using this model: https://ollama.com/library/qwen3-coder:30b 19GB in Agent and Edit mode.

The template:

TEMPLATE """
{{- if .Messages }}
{{- if or .System .Tools }}<|im_start|>system
{{- if .System }}
{{ .System }}
{{- end }}
{{- if .Tools }}

# Tools

You have access to the following tools:
<tools>
{{- range .Tools }}
{{ .Function }}
{{- end }}
</tools>

To use a tool, respond with a JSON object in this format:
<tool_call>
{"name": "function_name", "arguments": {"arg1": "value1", "arg2": "value2"}}
</tool_call>

{{- end }}<|im_end|>
{{ end }}
{{- range $i, $_ := .Messages }}
{{- $last := eq (len (slice $.Messages $i)) 1 -}}
{{- if eq .Role "user" }}<|im_start|>user
{{ .Content }}<|im_end|>
{{ else if eq .Role "assistant" }}<|im_start|>assistant
{{ if .Content }}{{ .Content }}
{{- else if .ToolCalls }}<tool_call>
{{ range .ToolCalls }}{"name": "{{ .Function.Name }}", "arguments": {{ .Function.Arguments }}}
{{ end }}</tool_call>
{{- end }}{{ if not $last }}<|im_end|>
{{ end }}
{{- else if eq .Role "tool" }}<|im_start|>tool
<tool_response>
{{ .Content }}
</tool_response><|im_end|>
{{ end }}
{{- if and (ne .Role "assistant") $last }}<|im_start|>assistant
{{ end }}
{{- end }}
{{- else }}
{{- if .System }}<|im_start|>system
{{ .System }}<|im_end|>
{{ end }}{{ if .Prompt }}<|im_start|>user
{{ .Prompt }}<|im_end|>
{{ end }}<|im_start|>assistant
{{ end }}{{ .Response }}{{ if .Response }}<|im_end|>{{ end }}
"""

Spaces seem to be important:

...
{"name": "function_name", "arguments": {"arg1": "value1", "arg2": "value2"}}
</tool_call>

{{- end }}<|im_end|>
{{ end }}
...

Context size:
OLLAMA_CONTEXT_LENGTH=8192

Optional:
/set parameter num_ctx 32768

But it's terribly slow.

<!-- gh-comment-id:3152871204 --> @FranBarInstance commented on GitHub (Aug 5, 2025): I have managed to get it to work partially in vscode with Copilot using this model: https://ollama.com/library/qwen3-coder:30b 19GB in Agent and Edit mode. The template: ``` TEMPLATE """ {{- if .Messages }} {{- if or .System .Tools }}<|im_start|>system {{- if .System }} {{ .System }} {{- end }} {{- if .Tools }} # Tools You have access to the following tools: <tools> {{- range .Tools }} {{ .Function }} {{- end }} </tools> To use a tool, respond with a JSON object in this format: <tool_call> {"name": "function_name", "arguments": {"arg1": "value1", "arg2": "value2"}} </tool_call> {{- end }}<|im_end|> {{ end }} {{- range $i, $_ := .Messages }} {{- $last := eq (len (slice $.Messages $i)) 1 -}} {{- if eq .Role "user" }}<|im_start|>user {{ .Content }}<|im_end|> {{ else if eq .Role "assistant" }}<|im_start|>assistant {{ if .Content }}{{ .Content }} {{- else if .ToolCalls }}<tool_call> {{ range .ToolCalls }}{"name": "{{ .Function.Name }}", "arguments": {{ .Function.Arguments }}} {{ end }}</tool_call> {{- end }}{{ if not $last }}<|im_end|> {{ end }} {{- else if eq .Role "tool" }}<|im_start|>tool <tool_response> {{ .Content }} </tool_response><|im_end|> {{ end }} {{- if and (ne .Role "assistant") $last }}<|im_start|>assistant {{ end }} {{- end }} {{- else }} {{- if .System }}<|im_start|>system {{ .System }}<|im_end|> {{ end }}{{ if .Prompt }}<|im_start|>user {{ .Prompt }}<|im_end|> {{ end }}<|im_start|>assistant {{ end }}{{ .Response }}{{ if .Response }}<|im_end|>{{ end }} """ ``` Spaces seem to be important: ``` ... {"name": "function_name", "arguments": {"arg1": "value1", "arg2": "value2"}} </tool_call> {{- end }}<|im_end|> {{ end }} ... ``` Context size: `OLLAMA_CONTEXT_LENGTH=8192` Optional: `/set parameter num_ctx 32768` But it's terribly slow.
Author
Owner

@Marabii commented on GitHub (Aug 6, 2025):

I have managed to get it to work partially in vscode with Copilot using this model: https://ollama.com/library/qwen3-coder:30b 19GB in Agent and Edit mode.

The template:

TEMPLATE """
{{- if .Messages }}
{{- if or .System .Tools }}<|im_start|>system
{{- if .System }}
{{ .System }}
{{- end }}
{{- if .Tools }}

# Tools

You have access to the following tools:
<tools>
{{- range .Tools }}
{{ .Function }}
{{- end }}
</tools>

To use a tool, respond with a JSON object in this format:
<tool_call>
{"name": "function_name", "arguments": {"arg1": "value1", "arg2": "value2"}}
</tool_call>

{{- end }}<|im_end|>
{{ end }}
{{- range $i, $_ := .Messages }}
{{- $last := eq (len (slice $.Messages $i)) 1 -}}
{{- if eq .Role "user" }}<|im_start|>user
{{ .Content }}<|im_end|>
{{ else if eq .Role "assistant" }}<|im_start|>assistant
{{ if .Content }}{{ .Content }}
{{- else if .ToolCalls }}<tool_call>
{{ range .ToolCalls }}{"name": "{{ .Function.Name }}", "arguments": {{ .Function.Arguments }}}
{{ end }}</tool_call>
{{- end }}{{ if not $last }}<|im_end|>
{{ end }}
{{- else if eq .Role "tool" }}<|im_start|>tool
<tool_response>
{{ .Content }}
</tool_response><|im_end|>
{{ end }}
{{- if and (ne .Role "assistant") $last }}<|im_start|>assistant
{{ end }}
{{- end }}
{{- else }}
{{- if .System }}<|im_start|>system
{{ .System }}<|im_end|>
{{ end }}{{ if .Prompt }}<|im_start|>user
{{ .Prompt }}<|im_end|>
{{ end }}<|im_start|>assistant
{{ end }}{{ .Response }}{{ if .Response }}<|im_end|>{{ end }}
"""

Spaces seem to be important:

...
{"name": "function_name", "arguments": {"arg1": "value1", "arg2": "value2"}}
</tool_call>

{{- end }}<|im_end|>
{{ end }}
...

Context size: OLLAMA_CONTEXT_LENGTH=8192

Optional: /set parameter num_ctx 32768

But it's terribly slow.

I also managed to make it work, but it's unbelievably slow, i have a good computer (RTX 5080 and 32 gb of ram) I can chat with it without issues and it's as fast as it should be.

<!-- gh-comment-id:3157031929 --> @Marabii commented on GitHub (Aug 6, 2025): > I have managed to get it to work partially in vscode with Copilot using this model: https://ollama.com/library/qwen3-coder:30b 19GB in Agent and Edit mode. > > The template: > > ``` > TEMPLATE """ > {{- if .Messages }} > {{- if or .System .Tools }}<|im_start|>system > {{- if .System }} > {{ .System }} > {{- end }} > {{- if .Tools }} > > # Tools > > You have access to the following tools: > <tools> > {{- range .Tools }} > {{ .Function }} > {{- end }} > </tools> > > To use a tool, respond with a JSON object in this format: > <tool_call> > {"name": "function_name", "arguments": {"arg1": "value1", "arg2": "value2"}} > </tool_call> > > {{- end }}<|im_end|> > {{ end }} > {{- range $i, $_ := .Messages }} > {{- $last := eq (len (slice $.Messages $i)) 1 -}} > {{- if eq .Role "user" }}<|im_start|>user > {{ .Content }}<|im_end|> > {{ else if eq .Role "assistant" }}<|im_start|>assistant > {{ if .Content }}{{ .Content }} > {{- else if .ToolCalls }}<tool_call> > {{ range .ToolCalls }}{"name": "{{ .Function.Name }}", "arguments": {{ .Function.Arguments }}} > {{ end }}</tool_call> > {{- end }}{{ if not $last }}<|im_end|> > {{ end }} > {{- else if eq .Role "tool" }}<|im_start|>tool > <tool_response> > {{ .Content }} > </tool_response><|im_end|> > {{ end }} > {{- if and (ne .Role "assistant") $last }}<|im_start|>assistant > {{ end }} > {{- end }} > {{- else }} > {{- if .System }}<|im_start|>system > {{ .System }}<|im_end|> > {{ end }}{{ if .Prompt }}<|im_start|>user > {{ .Prompt }}<|im_end|> > {{ end }}<|im_start|>assistant > {{ end }}{{ .Response }}{{ if .Response }}<|im_end|>{{ end }} > """ > ``` > > Spaces seem to be important: > > ``` > ... > {"name": "function_name", "arguments": {"arg1": "value1", "arg2": "value2"}} > </tool_call> > > {{- end }}<|im_end|> > {{ end }} > ... > ``` > > Context size: `OLLAMA_CONTEXT_LENGTH=8192` > > Optional: `/set parameter num_ctx 32768` > > But it's terribly slow. I also managed to make it work, but it's unbelievably slow, i have a good computer (RTX 5080 and 32 gb of ram) I can chat with it without issues and it's as fast as it should be.
Author
Owner

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

I got this jinja template from the unsloth GGUF file for the Qwen3-Coder-30B-A3B-Instruct model. It seems to have interesting instructions, such as suggesting the model to reason in natural language before tool calls, which will probably improve effectiveness in agentic coding tasks. Does anybody know how to port this to Ollama modelfile? I couldn't make it work yet...

{# Copyright 2025-present Unsloth. Apache 2.0 License. Unsloth Chat template fixes #} {% macro render_item_list(item_list, tag_name='required') %} {%- if item_list is defined and item_list is iterable and item_list | length > 0 %} {%- if tag_name %}{{- '\n<' ~ tag_name ~ '>' -}}{% endif %} {{- '[' }} {%- for item in item_list -%} {%- if loop.index > 1 %}{{- ", "}}{% endif -%} {%- if item is string -%} {{ "`" ~ item ~ "`" }} {%- else -%} {{ item }} {%- endif -%} {%- endfor -%} {{- ']' }} {%- if tag_name %}{{- '</' ~ tag_name ~ '>' -}}{% endif %} {%- endif %} {% endmacro %} {%- if messages[0]["role"] == "system" %} {%- set system_message = messages[0]["content"] %} {%- set loop_messages = messages[1:] %} {%- else %} {%- set loop_messages = messages %} {%- endif %} {%- if not tools is defined %} {%- set tools = [] %} {%- endif %} {%- if system_message is defined %} {{- "<|im_start|>system\n" + system_message }} {%- else %} {%- if tools is iterable and tools | length > 0 %} {{- "<|im_start|>system\nYou are Qwen, a helpful AI assistant that can interact with a computer to solve tasks." }} {%- endif %} {%- endif %} {%- if tools is iterable and tools | length > 0 %} {{- "\n\nYou have access to the following functions:\n\n" }} {{- "<tools>" }} {%- for tool in tools %} {%- if tool.function is defined %} {%- set tool = tool.function %} {%- endif %} {{- "\n<function>\n<name>" ~ tool.name ~ "</name>" }} {{- '\n<description>' ~ (tool.description | trim) ~ '</description>' }} {{- '\n<parameters>' }} {%- for param_name, param_fields in tool.parameters.properties|items %} {{- '\n<parameter>' }} {{- '\n<name>' ~ param_name ~ '</name>' }} {%- if param_fields.type is defined %} {{- '\n<type>' ~ (param_fields.type | string) ~ '</type>' }} {%- endif %} {%- if param_fields.description is defined %} {{- '\n<description>' ~ (param_fields.description | trim) ~ '</description>' }} {%- endif %} {{- render_item_list(param_fields.enum, 'enum') }} {%- set handled_keys = ['type', 'description', 'enum', 'required'] %} {%- for json_key, json_value in param_fields|items %} {%- if json_key not in handled_keys %} {%- set normed_json_key = json_key|string %} {%- if json_value is mapping %} {{- '\n<' ~ normed_json_key ~ '>' ~ (json_value | tojson | safe) ~ '</' ~ normed_json_key ~ '>' }} {%- else %} {{- '\n<' ~ normed_json_key ~ '>' ~ (json_value | string) ~ '</' ~ normed_json_key ~ '>' }} {%- endif %} {%- endif %} {%- endfor %} {{- render_item_list(param_fields.required, 'required') }} {{- '\n</parameter>' }} {%- endfor %} {{- render_item_list(tool.parameters.required, 'required') }} {{- '\n</parameters>' }} {%- if tool.return is defined %} {%- if tool.return is mapping %} {{- '\n<return>' ~ (tool.return | tojson | safe) ~ '</return>' }} {%- else %} {{- '\n<return>' ~ (tool.return | string) ~ '</return>' }} {%- endif %} {%- endif %} {{- '\n</function>' }} {%- endfor %} {{- "\n</tools>" }} {{- '\n\nIf you choose to call a function ONLY reply in the following format with NO suffix:\n\n<tool_call>\n<function=example_function_name>\n<parameter=example_parameter_1>\nvalue_1\n</parameter>\n<parameter=example_parameter_2>\nThis is the value for the second parameter\nthat can span\nmultiple lines\n</parameter>\n</function>\n</tool_call>\n\n<IMPORTANT>\nReminder:\n- Function calls MUST follow the specified format: an inner <function=...></function> block must be nested within <tool_call></tool_call> XML tags\n- Required parameters MUST be specified\n- You may provide optional reasoning for your function call in natural language BEFORE the function call, but NOT after\n- If there is no function call available, answer the question like normal with your current knowledge and do not tell the user about function calls\n</IMPORTANT>' }} {%- endif %} {%- if system_message is defined %} {{- '<|im_end|>\n' }} {%- else %} {%- if tools is iterable and tools | length > 0 %} {{- '<|im_end|>\n' }} {%- endif %} {%- endif %} {%- for message in loop_messages %} {%- if message.role == "assistant" and message.tool_calls is defined and message.tool_calls is iterable and message.tool_calls | length > 0 %} {{- '<|im_start|>' + message.role }} {%- if message.content is defined and message.content is string and message.content | trim | length > 0 %} {{- '\n' + message.content | trim + '\n' }} {%- endif %} {%- for tool_call in message.tool_calls %} {%- if tool_call.function is defined %} {%- set tool_call = tool_call.function %} {%- endif %} {{- '\n<tool_call>\n<function=' + tool_call.name + '>\n' }} {%- if tool_call.arguments is defined %} {%- for args_name, args_value in tool_call.arguments|items %} {{- '<parameter=' + args_name + '>\n' }} {%- set args_value = args_value if args_value is string else args_value | string %} {{- args_value }} {{- '\n</parameter>\n' }} {%- endfor %} {%- endif %} {{- '</function>\n</tool_call>' }} {%- endfor %} {{- '<|im_end|>\n' }} {%- elif message.role == "user" or message.role == "system" or message.role == "assistant" %} {{- '<|im_start|>' + message.role + '\n' + message.content + '<|im_end|>' + '\n' }} {%- elif message.role == "tool" %} {%- if loop.previtem and loop.previtem.role != "tool" %} {{- '<|im_start|>user\n' }} {%- endif %} {{- '<tool_response>\n' }} {{- message.content }} {{- '\n</tool_response>\n' }} {%- if not loop.last and loop.nextitem.role != "tool" %} {{- '<|im_end|>\n' }} {%- elif loop.last %} {{- '<|im_end|>\n' }} {%- endif %} {%- else %} {{- '<|im_start|>' + message.role + '\n' + message.content + '<|im_end|>\n' }} {%- endif %} {%- endfor %} {%- if add_generation_prompt %} {{- '<|im_start|>assistant\n' }} {%- endif %} {# Copyright 2025-present Unsloth. Apache 2.0 License. Unsloth Chat template fixes #}
<!-- gh-comment-id:3168108647 --> @johnnysn commented on GitHub (Aug 8, 2025): I got this jinja template from the unsloth GGUF file for the Qwen3-Coder-30B-A3B-Instruct model. It seems to have interesting instructions, such as suggesting the model to reason in natural language before tool calls, which will probably improve effectiveness in agentic coding tasks. Does anybody know how to port this to Ollama modelfile? I couldn't make it work yet... ``` {# Copyright 2025-present Unsloth. Apache 2.0 License. Unsloth Chat template fixes #} {% macro render_item_list(item_list, tag_name='required') %} {%- if item_list is defined and item_list is iterable and item_list | length > 0 %} {%- if tag_name %}{{- '\n<' ~ tag_name ~ '>' -}}{% endif %} {{- '[' }} {%- for item in item_list -%} {%- if loop.index > 1 %}{{- ", "}}{% endif -%} {%- if item is string -%} {{ "`" ~ item ~ "`" }} {%- else -%} {{ item }} {%- endif -%} {%- endfor -%} {{- ']' }} {%- if tag_name %}{{- '</' ~ tag_name ~ '>' -}}{% endif %} {%- endif %} {% endmacro %} {%- if messages[0]["role"] == "system" %} {%- set system_message = messages[0]["content"] %} {%- set loop_messages = messages[1:] %} {%- else %} {%- set loop_messages = messages %} {%- endif %} {%- if not tools is defined %} {%- set tools = [] %} {%- endif %} {%- if system_message is defined %} {{- "<|im_start|>system\n" + system_message }} {%- else %} {%- if tools is iterable and tools | length > 0 %} {{- "<|im_start|>system\nYou are Qwen, a helpful AI assistant that can interact with a computer to solve tasks." }} {%- endif %} {%- endif %} {%- if tools is iterable and tools | length > 0 %} {{- "\n\nYou have access to the following functions:\n\n" }} {{- "<tools>" }} {%- for tool in tools %} {%- if tool.function is defined %} {%- set tool = tool.function %} {%- endif %} {{- "\n<function>\n<name>" ~ tool.name ~ "</name>" }} {{- '\n<description>' ~ (tool.description | trim) ~ '</description>' }} {{- '\n<parameters>' }} {%- for param_name, param_fields in tool.parameters.properties|items %} {{- '\n<parameter>' }} {{- '\n<name>' ~ param_name ~ '</name>' }} {%- if param_fields.type is defined %} {{- '\n<type>' ~ (param_fields.type | string) ~ '</type>' }} {%- endif %} {%- if param_fields.description is defined %} {{- '\n<description>' ~ (param_fields.description | trim) ~ '</description>' }} {%- endif %} {{- render_item_list(param_fields.enum, 'enum') }} {%- set handled_keys = ['type', 'description', 'enum', 'required'] %} {%- for json_key, json_value in param_fields|items %} {%- if json_key not in handled_keys %} {%- set normed_json_key = json_key|string %} {%- if json_value is mapping %} {{- '\n<' ~ normed_json_key ~ '>' ~ (json_value | tojson | safe) ~ '</' ~ normed_json_key ~ '>' }} {%- else %} {{- '\n<' ~ normed_json_key ~ '>' ~ (json_value | string) ~ '</' ~ normed_json_key ~ '>' }} {%- endif %} {%- endif %} {%- endfor %} {{- render_item_list(param_fields.required, 'required') }} {{- '\n</parameter>' }} {%- endfor %} {{- render_item_list(tool.parameters.required, 'required') }} {{- '\n</parameters>' }} {%- if tool.return is defined %} {%- if tool.return is mapping %} {{- '\n<return>' ~ (tool.return | tojson | safe) ~ '</return>' }} {%- else %} {{- '\n<return>' ~ (tool.return | string) ~ '</return>' }} {%- endif %} {%- endif %} {{- '\n</function>' }} {%- endfor %} {{- "\n</tools>" }} {{- '\n\nIf you choose to call a function ONLY reply in the following format with NO suffix:\n\n<tool_call>\n<function=example_function_name>\n<parameter=example_parameter_1>\nvalue_1\n</parameter>\n<parameter=example_parameter_2>\nThis is the value for the second parameter\nthat can span\nmultiple lines\n</parameter>\n</function>\n</tool_call>\n\n<IMPORTANT>\nReminder:\n- Function calls MUST follow the specified format: an inner <function=...></function> block must be nested within <tool_call></tool_call> XML tags\n- Required parameters MUST be specified\n- You may provide optional reasoning for your function call in natural language BEFORE the function call, but NOT after\n- If there is no function call available, answer the question like normal with your current knowledge and do not tell the user about function calls\n</IMPORTANT>' }} {%- endif %} {%- if system_message is defined %} {{- '<|im_end|>\n' }} {%- else %} {%- if tools is iterable and tools | length > 0 %} {{- '<|im_end|>\n' }} {%- endif %} {%- endif %} {%- for message in loop_messages %} {%- if message.role == "assistant" and message.tool_calls is defined and message.tool_calls is iterable and message.tool_calls | length > 0 %} {{- '<|im_start|>' + message.role }} {%- if message.content is defined and message.content is string and message.content | trim | length > 0 %} {{- '\n' + message.content | trim + '\n' }} {%- endif %} {%- for tool_call in message.tool_calls %} {%- if tool_call.function is defined %} {%- set tool_call = tool_call.function %} {%- endif %} {{- '\n<tool_call>\n<function=' + tool_call.name + '>\n' }} {%- if tool_call.arguments is defined %} {%- for args_name, args_value in tool_call.arguments|items %} {{- '<parameter=' + args_name + '>\n' }} {%- set args_value = args_value if args_value is string else args_value | string %} {{- args_value }} {{- '\n</parameter>\n' }} {%- endfor %} {%- endif %} {{- '</function>\n</tool_call>' }} {%- endfor %} {{- '<|im_end|>\n' }} {%- elif message.role == "user" or message.role == "system" or message.role == "assistant" %} {{- '<|im_start|>' + message.role + '\n' + message.content + '<|im_end|>' + '\n' }} {%- elif message.role == "tool" %} {%- if loop.previtem and loop.previtem.role != "tool" %} {{- '<|im_start|>user\n' }} {%- endif %} {{- '<tool_response>\n' }} {{- message.content }} {{- '\n</tool_response>\n' }} {%- if not loop.last and loop.nextitem.role != "tool" %} {{- '<|im_end|>\n' }} {%- elif loop.last %} {{- '<|im_end|>\n' }} {%- endif %} {%- else %} {{- '<|im_start|>' + message.role + '\n' + message.content + '<|im_end|>\n' }} {%- endif %} {%- endfor %} {%- if add_generation_prompt %} {{- '<|im_start|>assistant\n' }} {%- endif %} {# Copyright 2025-present Unsloth. Apache 2.0 License. Unsloth Chat template fixes #} ```
Author
Owner

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

@jcx

any news about fixing the links on ollama site to lead to correct models?

@johnnysn

I got this jinja template from the unsloth GGUF file for the Qwen3-Coder-30B-A3B-Instruct model. It seems to have interesting instructions, such as suggesting the model to reason in natural language before tool calls, which will probably improve effectiveness in agentic coding tasks. Does anybody know how to port this to Ollama modelfile? I couldn't make it work yet...

Qwen3-coder has a problem that the tool calling syntax has changed json to a custom xml type. The problem is that llama.cpp doesn't support it yet.
ggml-org/llama.cpp#15012

You can still get it work somehow with json by altering the templates but it is very unreliable.

I think this is reason why currently tools are not added to qwen3-coder default template.

But people working on llama.cpp are working on it and they have a draft pr ready. So it should not be too long before this issue also get's fixed.
ggml-org/llama.cpp/pull/15162

<!-- gh-comment-id:3168208382 --> @minzanupam commented on GitHub (Aug 8, 2025): @jcx > any news about fixing the links on ollama site to lead to correct models? @johnnysn > I got this jinja template from the unsloth GGUF file for the Qwen3-Coder-30B-A3B-Instruct model. It seems to have interesting instructions, such as suggesting the model to reason in natural language before tool calls, which will probably improve effectiveness in agentic coding tasks. Does anybody know how to port this to Ollama modelfile? I couldn't make it work yet... Qwen3-coder has a problem that the tool calling syntax has changed json to a custom xml type. The problem is that llama.cpp doesn't support it yet. ggml-org/llama.cpp#15012 You can still get it work somehow with json by altering the templates but it is very unreliable. I think this is reason why currently tools are not added to qwen3-coder default template. But people working on llama.cpp are working on it and they have a draft pr ready. So it should not be too long before this issue also get's fixed. ggml-org/llama.cpp/pull/15162
Author
Owner

@gordo1337 commented on GitHub (Aug 11, 2025):

Same/similar problem here.

In goose (code name goose) its not working with the ollama tool error: request failed: registry.ollama.ai/library/qwen3-coder:latest does not support tools (type: api_error) (status 400)

In Anon Kode (an open source claude code derivative that was DMCA taken down (still downloadable using npm i -g anon-kode)) not working with error: Failed to configure provider: init chat completion request with tool did not succeed. API Error: API request failed: registry.ollama.ai/library/qwen3-coder:latest does not support tools

However, when i use ollama trough the void editor, qwen3-code shows up, and is working (although not great).

Maybe this this related to: langflow-ai/langflow#8805 langflow-ai/langflow#8805 (comment) If so then this is all because qwen3-code it is not in the Langflow list, and therefore 'officially' does not support tools. How to update that list? Do we really need that list? Is there some other temporary work around like disabling the official tool requirements but still using them any way?

Getting the same problem in Goose : Request failed: registry.ollama.ai/library/qwen3-coder:latest does not support tools (type: api_error) (status 400)

<!-- gh-comment-id:3175919967 --> @gordo1337 commented on GitHub (Aug 11, 2025): > Same/similar problem here. > > In goose (code name goose) its not working with the ollama tool error: request failed: registry.ollama.ai/library/qwen3-coder:latest does not support tools (type: api_error) (status 400) > > In Anon Kode (an open source claude code derivative that was DMCA taken down (still downloadable using npm i -g anon-kode)) not working with error: Failed to configure provider: init chat completion request with tool did not succeed. API Error: API request failed: registry.ollama.ai/library/qwen3-coder:latest does not support tools > > However, when i use ollama trough the void editor, qwen3-code shows up, and is working (although not great). > > Maybe this this related to: [langflow-ai/langflow#8805](https://github.com/langflow-ai/langflow/issues/8805) [langflow-ai/langflow#8805 (comment)](https://github.com/langflow-ai/langflow/issues/8805#issuecomment-3024294926) If so then this is all because qwen3-code it is not in the Langflow list, and therefore 'officially' does not support tools. How to update that list? Do we really need that list? Is there some other temporary work around like disabling the official tool requirements but still using them any way? Getting the same problem in Goose : Request failed: registry.ollama.ai/library/qwen3-coder:latest does not support tools (type: api_error) (status 400)
Author
Owner

@nicolasembleton commented on GitHub (Aug 13, 2025):

You can simply use the Unsloth versions from Huggingface, for example:

ollama pull hf.co/unsloth/Qwen3-Coder-30B-A3B-Instruct-GGUF:Q5_K_XL

More options in UnSloth collection on HuggingFace, filter by the model size you look for, just use the "Use model with" on the top-right to get the ollama command.

<!-- gh-comment-id:3183555705 --> @nicolasembleton commented on GitHub (Aug 13, 2025): You can simply use the Unsloth versions from Huggingface, for example: ```bash ollama pull hf.co/unsloth/Qwen3-Coder-30B-A3B-Instruct-GGUF:Q5_K_XL ``` More options in [UnSloth collection on HuggingFace](https://huggingface.co/collections/unsloth/qwen3-coder-687ff47700270447e02c987d), filter by the model size you look for, just use the "Use model with" on the top-right to get the ollama command.
Author
Owner

@Codelica commented on GitHub (Aug 13, 2025):

@nicolasembleton I assume they are actually working for you in Agent/tool mode? I had downloaded one to try a couple days ago and it did appear as an option to choose in the Agent model list but output from prompts was returned and displayed as json like the following:

Image
<!-- gh-comment-id:3184584803 --> @Codelica commented on GitHub (Aug 13, 2025): @nicolasembleton I assume they are actually working for you in Agent/tool mode? I had downloaded one to try a couple days ago and it did appear as an option to choose in the Agent model list but output from prompts was returned and displayed as json like the following: <img width="1016" height="364" alt="Image" src="https://github.com/user-attachments/assets/0712a5a5-f5f4-4169-9c62-6f580f76442c" />
Author
Owner

@nicolasembleton commented on GitHub (Aug 16, 2025):

@nicolasembleton I assume they are actually working for you in Agent/tool mode? I had downloaded one to try a couple days ago and it did appear as an option to choose in the Agent model list but output from prompts was returned and displayed as json like the following:

Image

I think these depend on the tools you use. Some agentic coding will work better than others depending on the models. Also, temperature, system prompt, etc... The way models return tool use is not the same from one model to another so the tools need to support them.

<!-- gh-comment-id:3193465513 --> @nicolasembleton commented on GitHub (Aug 16, 2025): > [@nicolasembleton](https://github.com/nicolasembleton) I assume they are actually working for you in Agent/tool mode? I had downloaded one to try a couple days ago and it did appear as an option to choose in the Agent model list but output from prompts was returned and displayed as json like the following: > > <img alt="Image" width="1016" height="364" src="https://private-user-images.githubusercontent.com/386101/477645690-0712a5a5-f5f4-4169-9c62-6f580f76442c.png?jwt=eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3NTUzMjkyMzYsIm5iZiI6MTc1NTMyODkzNiwicGF0aCI6Ii8zODYxMDEvNDc3NjQ1NjkwLTA3MTJhNWE1LWY1ZjQtNDE2OS05YzYyLTZmNTgwZjc2NDQyYy5wbmc_WC1BbXotQWxnb3JpdGhtPUFXUzQtSE1BQy1TSEEyNTYmWC1BbXotQ3JlZGVudGlhbD1BS0lBVkNPRFlMU0E1M1BRSzRaQSUyRjIwMjUwODE2JTJGdXMtZWFzdC0xJTJGczMlMkZhd3M0X3JlcXVlc3QmWC1BbXotRGF0ZT0yMDI1MDgxNlQwNzIyMTZaJlgtQW16LUV4cGlyZXM9MzAwJlgtQW16LVNpZ25hdHVyZT1hZGI0N2VjNjc0YzYxZjFlOTY4MzU3ZTM2ZmNiZTVmYTkxZWM5MGVmNTljOTU4ZGQ0OTY4ODM3NDNjZDRhNWJiJlgtQW16LVNpZ25lZEhlYWRlcnM9aG9zdCJ9.ioBAcye4gP2ue_hO9__97aFLBPS4dd8FzGGJOpakI6k"> I think these depend on the tools you use. Some agentic coding will work better than others depending on the models. Also, temperature, system prompt, etc... The way models return tool use is not the same from one model to another so the tools need to support them.
Author
Owner

@SMFloris commented on GitHub (Aug 18, 2025):

@nicolasembleton I assume they are actually working for you in Agent/tool mode? I had downloaded one to try a couple days ago and it did appear as an option to choose in the Agent model list but output from prompts was returned and displayed as json like the following:
Image

I made a little tool that fixes tool use. It mostly works - sometimes I cannot get the LLM to call the tools at all. Sometimes it reverts to the json format for no apparent reason.

https://github.com/SMFloris/ollama-qwen3-coder-proxy

I also tried the Modelfile approach.

Both approaches are kinda the same in terms of quality of output and tool use. The proxy approach seems just a tad bit more stable and triggers tools much more reliably.

<!-- gh-comment-id:3194743360 --> @SMFloris commented on GitHub (Aug 18, 2025): > [@nicolasembleton](https://github.com/nicolasembleton) I assume they are actually working for you in Agent/tool mode? I had downloaded one to try a couple days ago and it did appear as an option to choose in the Agent model list but output from prompts was returned and displayed as json like the following: > <img alt="Image" width="1016" height="364" src="https://private-user-images.githubusercontent.com/386101/477645690-0712a5a5-f5f4-4169-9c62-6f580f76442c.png?jwt=eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3NTU0NzUyODQsIm5iZiI6MTc1NTQ3NDk4NCwicGF0aCI6Ii8zODYxMDEvNDc3NjQ1NjkwLTA3MTJhNWE1LWY1ZjQtNDE2OS05YzYyLTZmNTgwZjc2NDQyYy5wbmc_WC1BbXotQWxnb3JpdGhtPUFXUzQtSE1BQy1TSEEyNTYmWC1BbXotQ3JlZGVudGlhbD1BS0lBVkNPRFlMU0E1M1BRSzRaQSUyRjIwMjUwODE3JTJGdXMtZWFzdC0xJTJGczMlMkZhd3M0X3JlcXVlc3QmWC1BbXotRGF0ZT0yMDI1MDgxN1QyMzU2MjRaJlgtQW16LUV4cGlyZXM9MzAwJlgtQW16LVNpZ25hdHVyZT04YmExYjBlNGE2N2E5ZDczNWZjMTU0NmQ2Nzg4ODAwZTYwNjE3OGUwOWZkYjkzOTk4MDkyMTNiYWI0OWYxYTY5JlgtQW16LVNpZ25lZEhlYWRlcnM9aG9zdCJ9.pBukzsovcUDHUduMTneA-abPDcnkLyjWVRTA0QIoNyQ"> I made a little tool that fixes tool use. It mostly works - sometimes I cannot get the LLM to call the tools at all. Sometimes it reverts to the json format for no apparent reason. https://github.com/SMFloris/ollama-qwen3-coder-proxy I also tried the Modelfile approach. Both approaches are kinda the same in terms of quality of output and tool use. The proxy approach seems just a tad bit more stable and triggers tools much more reliably.
Author
Owner

@DXXS commented on GitHub (Aug 19, 2025):

Just got this myself, attempting to use the creator's "qwen-code" w/local v1 endpoint:

[API Error: 400 registry.ollama.ai/library/qwen3-coder:30b does not support tools]

Apparently model no longer ~recognizable to model's own creator!?

<!-- gh-comment-id:3202089104 --> @DXXS commented on GitHub (Aug 19, 2025): Just got this myself, attempting to use the creator's "qwen-code" w/local v1 endpoint: [API Error: 400 registry.ollama.ai/library/qwen3-coder:30b does not support tools] Apparently model no longer ~recognizable to model's own creator!?
Author
Owner

@alperakgun commented on GitHub (Aug 21, 2025):

EDIT3: I have added the strict prompting instructions in Modelfile - and got better results.

EDIT2: It's not really running any better :( . SEE MY LATEST COMMENT https://github.com/QwenLM/Qwen3-Coder/issues/475#issuecomment-3210807876

EDIT1: Linking to the main comment https://github.com/QwenLM/Qwen3-Coder/issues/475#issuecomment-3210746025

Here's how I re-edited the unsloth's UD-Q4_K_XL gguf, to be able to run tools more reliably

<!-- gh-comment-id:3210757510 --> @alperakgun commented on GitHub (Aug 21, 2025): EDIT3: I have added the strict prompting instructions in Modelfile - and got better results. EDIT2: It's not really running any better :( . SEE MY LATEST COMMENT https://github.com/QwenLM/Qwen3-Coder/issues/475#issuecomment-3210807876 EDIT1: Linking to the main comment https://github.com/QwenLM/Qwen3-Coder/issues/475#issuecomment-3210746025 Here's how I re-edited the unsloth's UD-Q4_K_XL gguf, to be able to run tools more reliably
Author
Owner

@neurostream commented on GitHub (Aug 22, 2025):

Also seeing this with qwen3-coder:480b (there's no "instruct" -named model : https://ollama.com/library/qwen3-coder:480b) and "tools" are not listed in the capabilities.

<!-- gh-comment-id:3212978830 --> @neurostream commented on GitHub (Aug 22, 2025): Also seeing this with qwen3-coder:480b (there's no "instruct" -named model : https://ollama.com/library/qwen3-coder:480b) and "tools" are not listed in the capabilities.
Author
Owner

@pminervini commented on GitHub (Aug 22, 2025):

with llama.cpp and lm studio, everything works like a charm

<!-- gh-comment-id:3213699629 --> @pminervini commented on GitHub (Aug 22, 2025): with llama.cpp and lm studio, everything works like a charm
Author
Owner

@robbiemu commented on GitHub (Aug 30, 2025):

don't know if it would interest anyone but I think I have tool calling working well in ollama with my own template (I am using unsloth's version based on discussions in llama.cpp): https://ollama.com/robbiemu/qwen3-coder:30b-a3b-i-q4_K_XL

<!-- gh-comment-id:3239609133 --> @robbiemu commented on GitHub (Aug 30, 2025): don't know if it would interest anyone but I think I have tool calling working well in ollama with my own template (I am using unsloth's version based on discussions in llama.cpp): https://ollama.com/robbiemu/qwen3-coder:30b-a3b-i-q4_K_XL
Author
Owner

@djholt commented on GitHub (Aug 31, 2025):

with llama.cpp and lm studio, everything works like a charm

Needing to put Ollama aside for now over this issue. llama.cpp and lm studio are both handling tool use with qwen3-coder flawlessly.

<!-- gh-comment-id:3239709522 --> @djholt commented on GitHub (Aug 31, 2025): > with llama.cpp and lm studio, everything works like a charm Needing to put Ollama aside for now over this issue. llama.cpp and lm studio are both handling tool use with qwen3-coder flawlessly.
Author
Owner
<!-- gh-comment-id:3240673599 --> @fuwh617 commented on GitHub (Sep 1, 2025): https://docs.unsloth.ai/basics/qwen3-coder-how-to-run-locally#tool-calling-fixes
Author
Owner

@djholt commented on GitHub (Sep 1, 2025):

https://docs.unsloth.ai/basics/qwen3-coder-how-to-run-locally#tool-calling-fixes

Unsloth's template fixes work great in llama.cpp.

<!-- gh-comment-id:3240680899 --> @djholt commented on GitHub (Sep 1, 2025): > https://docs.unsloth.ai/basics/qwen3-coder-how-to-run-locally#tool-calling-fixes Unsloth's template fixes work great in llama.cpp.
Author
Owner

@robbiemu commented on GitHub (Sep 1, 2025):

https://docs.unsloth.ai/basics/qwen3-coder-how-to-run-locally#tool-calling-fixes

Unsloth's template fixes work great in llama.cpp.

IMO, the issue largely boils down to:

  • range, if, eq, ne, gt, len - Available
  • sub, add, kindIs, toJson, replace - Not available

If you want something more faithful to unsloth's than the one in the model I published, I think this might be close to best-effort without changing the ollama template syntax.

{{- /* Extract system message and other messages */ -}}
{{- $system_message := "" -}}
{{- $loop_messages := .Messages -}}
{{- if and .Messages (gt (len .Messages) 0) (eq (index .Messages 0).Role "system") -}}
{{- $system_message = (index .Messages 0).Content -}}
{{- $loop_messages = slice .Messages 1 -}}
{{- end -}}

{{- /* Handle tools if they exist */ -}}
{{- $has_tools := and .Tools (gt (len .Tools) 0) -}}

{{- /* System message */ -}}
{{- if $system_message -}}
<|im_start|>system
{{ $system_message }}
{{- else if $has_tools -}}
<|im_start|>system
You are Qwen, a helpful AI assistant that can interact with a computer to solve tasks.
{{- end -}}

{{- /* Add XML-style tools section if tools exist */ -}}
{{- if $has_tools -}}

You have access to the following functions:

<tools>
{{- range .Tools -}}
{{- $tool := . -}}
{{- if .Function -}}
{{- $tool = .Function -}}
{{- end }}
<function>
<name>{{ $tool.Name }}</name>
<description>{{ $tool.Description }}</description>
<parameters>
{{- if $tool.Parameters -}}
{{- if $tool.Parameters.properties -}}
{{- range $param_name, $param_fields := $tool.Parameters.properties }}
<parameter>
<name>{{ $param_name }}</name>
{{- if $param_fields.type }}
<type>{{ $param_fields.type }}</type>
{{- end }}
{{- if $param_fields.description }}
<description>{{ $param_fields.description }}</description>
{{- end }}
{{- if $param_fields.enum }}
<enum>[{{ range $i, $val := $param_fields.enum }}{{ if gt $i 0 }}, {{ end }}`{{ $val }}`{{ end }}]</enum>
{{- end }}
{{- if $param_fields.required }}
<required>[{{ range $i, $req := $param_fields.required }}{{ if gt $i 0 }}, {{ end }}`{{ $req }}`{{ end }}]</required>
{{- end }}
</parameter>
{{- end -}}
{{- end -}}
{{- if $tool.Parameters.required }}
<required>[{{ range $i, $req := $tool.Parameters.required }}{{ if gt $i 0 }}, {{ end }}`{{ $req }}`{{ end }}]</required>
{{- end -}}
{{- end }}
</parameters>
{{- if $tool.Return }}
<return>{{ $tool.Return }}</return>
{{- end }}
</function>
{{- end }}
</tools>

If you choose to call a function ONLY reply in the following format with NO suffix:

<tool_call>
<function=example_function_name>
<parameter=example_parameter_1>
value_1
</parameter>
<parameter=example_parameter_2>
This is the value for the second parameter
that can span
multiple lines
</parameter>
</function>
</tool_call>

<IMPORTANT>
Reminder:
- Function calls MUST follow the specified format: an inner <function=...></function> block must be nested within <tool_call></tool_call> XML tags
- Required parameters MUST be specified
- You may provide optional reasoning for your function call in natural language BEFORE the function call, but NOT after
- If there is no function call available, answer the question like normal with your current knowledge and do not tell the user about function calls
</IMPORTANT>
{{- end -}}

{{- /* Close system message if it was opened */ -}}
{{- if or $system_message $has_tools -}}
<|im_end|>
{{- end -}}

{{- /* Process conversation messages with enhanced tool response handling */ -}}
{{- $in_tool_block := false -}}
{{- range $i, $message := $loop_messages -}}
{{- if eq $message.Role "tool" -}}
{{- if not $in_tool_block -}}
<|im_start|>user
{{- $in_tool_block = true -}}
{{- end }}
<tool_response>
{{ $message.Content }}
</tool_response>
{{- else if eq $message.Role "assistant" -}}
{{- if $in_tool_block -}}
<|im_end|>
{{- $in_tool_block = false -}}
{{- end }}
<|im_start|>assistant
{{- if $message.Content }}
{{ $message.Content }}
{{- end }}
{{- range $message.ToolCalls -}}
{{- $tool_call := . -}}
{{- if .Function -}}
{{- $tool_call = .Function -}}
{{- end }}

<tool_call>
<function={{ $tool_call.Name }}>
{{- if $tool_call.Arguments -}}
{{- range $args_name, $args_value := $tool_call.Arguments }}
<parameter={{ $args_name }}>
{{ $args_value }}
</parameter>
{{- end -}}
{{- end }}
</function>
</tool_call>
{{- end }}
<|im_end|>
{{- else -}}
{{- if $in_tool_block -}}
<|im_end|>
{{- $in_tool_block = false -}}
{{- end }}
<|im_start|>{{ $message.Role }}
{{ $message.Content }}<|im_end|>
{{- end -}}
{{- end -}}

{{- /* Always add generation prompt */ -}}
<|im_start|>assistant

@fuwh617 thank you... I think I will go update my model tomorrow (its late now)

<!-- gh-comment-id:3240750819 --> @robbiemu commented on GitHub (Sep 1, 2025): > > https://docs.unsloth.ai/basics/qwen3-coder-how-to-run-locally#tool-calling-fixes > > Unsloth's template fixes work great in llama.cpp. IMO, the issue largely boils down to: - range, if, eq, ne, gt, len - ✅ Available - sub, add, kindIs, toJson, replace - ❌ Not available If you want something more faithful to unsloth's than the one in the model I published, I think this might be close to best-effort without changing the ollama template syntax. ```go {{- /* Extract system message and other messages */ -}} {{- $system_message := "" -}} {{- $loop_messages := .Messages -}} {{- if and .Messages (gt (len .Messages) 0) (eq (index .Messages 0).Role "system") -}} {{- $system_message = (index .Messages 0).Content -}} {{- $loop_messages = slice .Messages 1 -}} {{- end -}} {{- /* Handle tools if they exist */ -}} {{- $has_tools := and .Tools (gt (len .Tools) 0) -}} {{- /* System message */ -}} {{- if $system_message -}} <|im_start|>system {{ $system_message }} {{- else if $has_tools -}} <|im_start|>system You are Qwen, a helpful AI assistant that can interact with a computer to solve tasks. {{- end -}} {{- /* Add XML-style tools section if tools exist */ -}} {{- if $has_tools -}} You have access to the following functions: <tools> {{- range .Tools -}} {{- $tool := . -}} {{- if .Function -}} {{- $tool = .Function -}} {{- end }} <function> <name>{{ $tool.Name }}</name> <description>{{ $tool.Description }}</description> <parameters> {{- if $tool.Parameters -}} {{- if $tool.Parameters.properties -}} {{- range $param_name, $param_fields := $tool.Parameters.properties }} <parameter> <name>{{ $param_name }}</name> {{- if $param_fields.type }} <type>{{ $param_fields.type }}</type> {{- end }} {{- if $param_fields.description }} <description>{{ $param_fields.description }}</description> {{- end }} {{- if $param_fields.enum }} <enum>[{{ range $i, $val := $param_fields.enum }}{{ if gt $i 0 }}, {{ end }}`{{ $val }}`{{ end }}]</enum> {{- end }} {{- if $param_fields.required }} <required>[{{ range $i, $req := $param_fields.required }}{{ if gt $i 0 }}, {{ end }}`{{ $req }}`{{ end }}]</required> {{- end }} </parameter> {{- end -}} {{- end -}} {{- if $tool.Parameters.required }} <required>[{{ range $i, $req := $tool.Parameters.required }}{{ if gt $i 0 }}, {{ end }}`{{ $req }}`{{ end }}]</required> {{- end -}} {{- end }} </parameters> {{- if $tool.Return }} <return>{{ $tool.Return }}</return> {{- end }} </function> {{- end }} </tools> If you choose to call a function ONLY reply in the following format with NO suffix: <tool_call> <function=example_function_name> <parameter=example_parameter_1> value_1 </parameter> <parameter=example_parameter_2> This is the value for the second parameter that can span multiple lines </parameter> </function> </tool_call> <IMPORTANT> Reminder: - Function calls MUST follow the specified format: an inner <function=...></function> block must be nested within <tool_call></tool_call> XML tags - Required parameters MUST be specified - You may provide optional reasoning for your function call in natural language BEFORE the function call, but NOT after - If there is no function call available, answer the question like normal with your current knowledge and do not tell the user about function calls </IMPORTANT> {{- end -}} {{- /* Close system message if it was opened */ -}} {{- if or $system_message $has_tools -}} <|im_end|> {{- end -}} {{- /* Process conversation messages with enhanced tool response handling */ -}} {{- $in_tool_block := false -}} {{- range $i, $message := $loop_messages -}} {{- if eq $message.Role "tool" -}} {{- if not $in_tool_block -}} <|im_start|>user {{- $in_tool_block = true -}} {{- end }} <tool_response> {{ $message.Content }} </tool_response> {{- else if eq $message.Role "assistant" -}} {{- if $in_tool_block -}} <|im_end|> {{- $in_tool_block = false -}} {{- end }} <|im_start|>assistant {{- if $message.Content }} {{ $message.Content }} {{- end }} {{- range $message.ToolCalls -}} {{- $tool_call := . -}} {{- if .Function -}} {{- $tool_call = .Function -}} {{- end }} <tool_call> <function={{ $tool_call.Name }}> {{- if $tool_call.Arguments -}} {{- range $args_name, $args_value := $tool_call.Arguments }} <parameter={{ $args_name }}> {{ $args_value }} </parameter> {{- end -}} {{- end }} </function> </tool_call> {{- end }} <|im_end|> {{- else -}} {{- if $in_tool_block -}} <|im_end|> {{- $in_tool_block = false -}} {{- end }} <|im_start|>{{ $message.Role }} {{ $message.Content }}<|im_end|> {{- end -}} {{- end -}} {{- /* Always add generation prompt */ -}} <|im_start|>assistant ``` @fuwh617 thank you... I think I will go update my model tomorrow (its late now)
Author
Owner

@neurostream commented on GitHub (Sep 4, 2025):

How does a model get from its origin with the Qwen org on Hugging Face to the ollama.com registry? I'd love to see an official qwen3-coder model with full tool use capability on ollama.com.

Who published https://ollama.com/library/qwen3-coder ? Is this the right place to file this issue?

<!-- gh-comment-id:3251971493 --> @neurostream commented on GitHub (Sep 4, 2025): How does a model get from its origin with the Qwen org on Hugging Face to the ollama.com registry? I'd love to see an official qwen3-coder model with full tool use capability on ollama.com. Who published https://ollama.com/library/qwen3-coder ? Is this the right place to file this issue?
Author
Owner

@awaescher commented on GitHub (Sep 23, 2025):

It has been nearly 8 weeks and still noone updated the manifest to reflect tool capabilities?

<!-- gh-comment-id:3324573966 --> @awaescher commented on GitHub (Sep 23, 2025): It has been nearly 8 weeks and still noone updated the manifest to reflect tool capabilities?
Author
Owner

@drifkin commented on GitHub (Sep 23, 2025):

We recently added first class tool support for both qwen3-coder models in v0.12.0 (with some improvements coming in v0.12.1 very soon). This was implemented in https://github.com/ollama/ollama/pull/12248 via a custom renderer and parser specifically for qwen3-coder (the format is a bit specialized).

Be sure to upgrade Ollama, and pull the model (e.g., ollama pull qwen3-coder:30b). Once you do that, it should have tool support (which you can verify via ollama show qwen3-coder and look under "Capabilities")

Here's a quick example call you can run:

qwen3-coder-tool-call.sh
#!/bin/bash

TOOLS='[
  {
    "type": "function",
    "function": {
      "name": "get_weather",
      "description": "Get the current weather for a location",
      "parameters": {
        "type": "object",
        "properties": {
          "location": {
            "type": "string",
            "description": "The city and state, e.g. San Francisco, CA"
          },
          "unit": {
            "type": "string",
            "enum": ["celsius", "fahrenheit"],
            "description": "The temperature unit"
          }
        },
        "required": ["location"]
      }
    }
  }
]'

REQUEST_PAYLOAD=$(cat <<EOF
{
  "model": "qwen3-coder",
  "messages": [
    {
      "role": "user",
      "content": "What's the weather like in New York?"
    }
  ],
  "tools": $TOOLS,
  "stream": false
}
EOF
)

RESPONSE=$(curl -s -X POST http://localhost:11434/api/chat \
  -H "Content-Type: application/json" \
  -d "$REQUEST_PAYLOAD")

echo "Response:"
echo "$RESPONSE" | jq '.'

Response:

{
  "model": "qwen3-coder",
  "created_at": "2025-09-23T21:06:31.876214Z",
  "message": {
    "role": "assistant",
    "content": "",
    "tool_calls": [
      {
        "function": {
          "name": "get_weather",
          "arguments": {
            "location": "New York"
          }
        }
      }
    ]
  },
  "done": true,
  "done_reason": "stop",
  "total_duration": 752262750,
  "load_duration": 41648584,
  "prompt_eval_count": 345,
  "prompt_eval_duration": 436761250,
  "eval_count": 23,
  "eval_duration": 273469000
}

We had a bug with the site that we just fixed that didn't show that these models support tools now, but it's fixed now. We were planning to put the announcement in the 0.12.1 release notes, but this message is a sneak peak.

I'll close out this issue now, but open a separate one for FIM to investigate (EDIT: opened at #12387). It might just be doable in "user-space" since the qwen3-coder examples show it being just a message that happens to have special tokens in it, but I want to test it end-to-end in a few different ways.

<!-- gh-comment-id:3325581081 --> @drifkin commented on GitHub (Sep 23, 2025): We recently added first class tool support for both qwen3-coder models in v0.12.0 (with some improvements coming in v0.12.1 very soon). This was implemented in https://github.com/ollama/ollama/pull/12248 via a custom renderer and parser specifically for qwen3-coder (the format is a bit specialized). Be sure to upgrade Ollama, and pull the model (e.g., `ollama pull qwen3-coder:30b`). Once you do that, it should have tool support (which you can verify via `ollama show qwen3-coder` and look under "Capabilities") Here's a quick example call you can run: <details> <summary>qwen3-coder-tool-call.sh</summary> ```bash #!/bin/bash TOOLS='[ { "type": "function", "function": { "name": "get_weather", "description": "Get the current weather for a location", "parameters": { "type": "object", "properties": { "location": { "type": "string", "description": "The city and state, e.g. San Francisco, CA" }, "unit": { "type": "string", "enum": ["celsius", "fahrenheit"], "description": "The temperature unit" } }, "required": ["location"] } } } ]' REQUEST_PAYLOAD=$(cat <<EOF { "model": "qwen3-coder", "messages": [ { "role": "user", "content": "What's the weather like in New York?" } ], "tools": $TOOLS, "stream": false } EOF ) RESPONSE=$(curl -s -X POST http://localhost:11434/api/chat \ -H "Content-Type: application/json" \ -d "$REQUEST_PAYLOAD") echo "Response:" echo "$RESPONSE" | jq '.' ``` </details> Response: ```json { "model": "qwen3-coder", "created_at": "2025-09-23T21:06:31.876214Z", "message": { "role": "assistant", "content": "", "tool_calls": [ { "function": { "name": "get_weather", "arguments": { "location": "New York" } } } ] }, "done": true, "done_reason": "stop", "total_duration": 752262750, "load_duration": 41648584, "prompt_eval_count": 345, "prompt_eval_duration": 436761250, "eval_count": 23, "eval_duration": 273469000 } ``` We had a bug with the site that we just fixed that didn't show that these models support tools now, but it's fixed now. We were planning to put the announcement in the 0.12.1 release notes, but this message is a sneak peak. I'll close out this issue now, but open a separate one for FIM to investigate (EDIT: opened at #12387). It might just be doable in "user-space" since the qwen3-coder examples show it being just a message that happens to have special tokens in it, but I want to test it end-to-end in a few different ways.
Author
Owner

@Fhrozen commented on GitHub (Sep 24, 2025):

Just to report (Not sure if someone else already tried).
Using a Docker image updated 10 hours ago, the model was deleted and downloaded again.
show qwen3-coder shows:

"capabilities":["completion","tools"],"modified_at":"2025-09-24T02:44:55.503933272Z"

Now, VSCode lists it:

Image

But, it cannot be used as agent:

Image

Did VSCode need any additional setup?

<!-- gh-comment-id:3326566196 --> @Fhrozen commented on GitHub (Sep 24, 2025): Just to report (Not sure if someone else already tried). Using a Docker image updated 10 hours ago, the model was deleted and downloaded again. ` show qwen3-coder` shows: ``` "capabilities":["completion","tools"],"modified_at":"2025-09-24T02:44:55.503933272Z" ``` Now, VSCode lists it: <img width="931" height="222" alt="Image" src="https://github.com/user-attachments/assets/c68f418a-41ec-4f93-bc39-955dc727544d" /> But, it cannot be used as agent: <img width="439" height="535" alt="Image" src="https://github.com/user-attachments/assets/d3fad402-4839-4d3f-b408-42e07f35399a" /> Did VSCode need any additional setup?
Author
Owner

@ozdang commented on GitHub (Sep 24, 2025):

For those who want to convert a GGUF file and register it in Ollama, please refer to the following when writing your Modelfile:

PS ***> ollama show qwen3-coder:30b --modelfile
# Modelfile generated by "ollama show"
# To build a new Modelfile based on this, replace FROM with:
# FROM qwen3-coder:30b

FROM C:\Users\***\.ollama\models\blobs\sha256-1194192cf2a187eb02722edcc3f77b11d21f537048ce04b67ccf8ba78863006a
TEMPLATE {{ .Prompt }}
RENDERER qwen3-coder
PARSER qwen3-coder
PARAMETER repeat_penalty 1.05
PARAMETER stop <|im_start|>
PARAMETER stop <|im_end|>
PARAMETER stop <|endoftext|>
PARAMETER temperature 0.7
PARAMETER top_k 20
PARAMETER top_p 0.8

Starting from version 0.12.0, it seems that Ollama handles TEMPLATE with RENDENDER, PARSER automatically. From what I found in the issues, it’s still unstable for now, so we’ll need to wait and see a bit longer. I briefly tried to convert from GGUF on version 0.12.1.

<!-- gh-comment-id:3326737016 --> @ozdang commented on GitHub (Sep 24, 2025): For those who want to convert a GGUF file and register it in Ollama, please refer to the following when writing your Modelfile: ``` PS ***> ollama show qwen3-coder:30b --modelfile # Modelfile generated by "ollama show" # To build a new Modelfile based on this, replace FROM with: # FROM qwen3-coder:30b FROM C:\Users\***\.ollama\models\blobs\sha256-1194192cf2a187eb02722edcc3f77b11d21f537048ce04b67ccf8ba78863006a TEMPLATE {{ .Prompt }} RENDERER qwen3-coder PARSER qwen3-coder PARAMETER repeat_penalty 1.05 PARAMETER stop <|im_start|> PARAMETER stop <|im_end|> PARAMETER stop <|endoftext|> PARAMETER temperature 0.7 PARAMETER top_k 20 PARAMETER top_p 0.8 ``` Starting from version 0.12.0, it seems that Ollama handles **TEMPLATE** with **RENDENDER**, **PARSER** automatically. From what I found in the issues, it’s still unstable for now, so we’ll need to wait and see a bit longer. I briefly tried to convert from GGUF on version 0.12.1.
Author
Owner

@drifkin commented on GitHub (Sep 24, 2025):

thanks @ozdang, yeah the intention is for you to be able to use RENDERER qwen3-coder and PARSER qwen3-coder with whatever weights you want to.

I'd expect the parser to be relatively stable, should be generally useful. Quite possible we'll need to tune some escaping ambiguities. So curious which issues you ran into, definitely want to run them down asap

<!-- gh-comment-id:3326796888 --> @drifkin commented on GitHub (Sep 24, 2025): thanks @ozdang, yeah the intention is for you to be able to use `RENDERER qwen3-coder` and `PARSER qwen3-coder` with whatever weights you want to. I'd expect the parser to be relatively stable, should be generally useful. Quite possible we'll need to tune some escaping ambiguities. So curious which issues you ran into, definitely want to run them down asap
Author
Owner

@awaescher commented on GitHub (Sep 24, 2025):

That's way more than I expected, thanks a lot @drifkin and team

<!-- gh-comment-id:3329991792 --> @awaescher commented on GitHub (Sep 24, 2025): That's way more than I expected, thanks a lot @drifkin and team
Author
Owner

@neurostream commented on GitHub (Sep 24, 2025):

image

<!-- gh-comment-id:3330299146 --> @neurostream commented on GitHub (Sep 24, 2025): ![image](https://github.com/user-attachments/assets/43ba21e3-6a85-454f-a2a0-94cd92c588ed)
Author
Owner

@neurostream commented on GitHub (Sep 24, 2025):

qwen3-coder-tool-call.sh

@drifkin thank you!!!

https://ollama.com/library/qwen3-coder now shows TOOLS!

also, thanks for the bash shell script instead of needing an extra python/golang setup step for this type of quick test! :))

<!-- gh-comment-id:3330320078 --> @neurostream commented on GitHub (Sep 24, 2025): > > <summary>qwen3-coder-tool-call.sh</summary> > @drifkin thank you!!! https://ollama.com/library/qwen3-coder now shows TOOLS! also, thanks for the bash shell script instead of needing an extra python/golang setup step for this type of quick test! :))
Author
Owner

@maks commented on GitHub (Oct 20, 2025):

@drifkin This doesn't seem to have been fixed.

I deleted and pulled qwen3-coder today.

ollama ls  |grep qwen3-coder
qwen3-coder:latest                          06c1097efce0    18 GB     11 minutes ago

and then:

ollama show qwen3-coder:latest --template
{{ .Prompt }}%

yet:

% ollama show qwen3:30b-a3b --template |head -n 20

{{- $lastUserIdx := -1 -}}
{{- range $idx, $msg := .Messages -}}
{{- if eq $msg.Role "user" }}{{ $lastUserIdx = $idx }}{{ end -}}
{{- end }}
{{- if or .System .Tools }}<|im_start|>system
{{ if .System }}
{{ .System }}
{{- end }}
{{- if .Tools }}

# Tools

You may call one or more functions to assist with the user query.

You are provided with function signatures within <tools></tools> XML tags:
<tools>
{{- range .Tools }}
{"type": "function", "function": {{ .Function }}}
{{- end }}

And sure enough when I try to use qwen3-coder with opencode it reports the model doesn't support tool calling. If I try it with qwen3 the tool calling works as expected (note I set both models to 16k context when testing with oepncode because it requires bigger ctxs)

<!-- gh-comment-id:3420718641 --> @maks commented on GitHub (Oct 20, 2025): @drifkin This doesn't seem to have been fixed. I deleted and pulled qwen3-coder today. ``` ollama ls |grep qwen3-coder qwen3-coder:latest 06c1097efce0 18 GB 11 minutes ago ``` and then: ``` ollama show qwen3-coder:latest --template {{ .Prompt }}% ``` yet: ``` % ollama show qwen3:30b-a3b --template |head -n 20 {{- $lastUserIdx := -1 -}} {{- range $idx, $msg := .Messages -}} {{- if eq $msg.Role "user" }}{{ $lastUserIdx = $idx }}{{ end -}} {{- end }} {{- if or .System .Tools }}<|im_start|>system {{ if .System }} {{ .System }} {{- end }} {{- if .Tools }} # Tools You may call one or more functions to assist with the user query. You are provided with function signatures within <tools></tools> XML tags: <tools> {{- range .Tools }} {"type": "function", "function": {{ .Function }}} {{- end }} ``` And sure enough when I try to use qwen3-coder with opencode it reports the model doesn't support tool calling. If I try it with qwen3 the tool calling works as expected (note I set both models to 16k context when testing with oepncode because it requires bigger ctxs)
Author
Owner

@BradKML commented on GitHub (Oct 24, 2025):

Can someone help out here? https://github.com/charmbracelet/crush/issues/447#issuecomment-3443074261

<!-- gh-comment-id:3443465243 --> @BradKML commented on GitHub (Oct 24, 2025): Can someone help out here? https://github.com/charmbracelet/crush/issues/447#issuecomment-3443074261
Author
Owner

@drifkin commented on GitHub (Oct 24, 2025):

And sure enough when I try to use qwen3-coder with opencode it reports the model doesn't support tool calling. If I try it with qwen3 the tool calling works as expected (note I set both models to 16k context when testing with oepncode because it requires bigger ctxs)

can you show me the output of ollama show qwen3-coder:latest and also ollama show qwen3-coder --modelfile | grep -C2 RENDERER? qwen3-coder isn't actually using that dummy template, it should be using our newer built-in renderer and parser for it. When it uses that parser it should have the tools capability

<!-- gh-comment-id:3444135014 --> @drifkin commented on GitHub (Oct 24, 2025): > And sure enough when I try to use qwen3-coder with opencode it reports the model doesn't support tool calling. If I try it with qwen3 the tool calling works as expected (note I set both models to 16k context when testing with oepncode because it requires bigger ctxs) can you show me the output of `ollama show qwen3-coder:latest` and also `ollama show qwen3-coder --modelfile | grep -C2 RENDERER`? qwen3-coder isn't actually using that dummy template, it should be using our newer built-in renderer and parser for it. When it uses that parser it should have the tools capability
Author
Owner

@maks commented on GitHub (Oct 27, 2025):

And sure enough when I try to use qwen3-coder with opencode it reports the model doesn't support tool calling. If I try it with qwen3 the tool calling works as expected (note I set both models to 16k context when testing with oepncode because it requires bigger ctxs)

can you show me the output of ollama show qwen3-coder:latest and also ollama show qwen3-coder --modelfile | grep -C2 RENDERER? qwen3-coder isn't actually using that dummy template, it should be using our newer built-in renderer and parser for it. When it uses that parser it should have the tools capability

Sorry for the slow reply @drifkin .
Here is the output I get, is this what is expected?

ollama ls|grep qwen3-coder
qwen3-coder-16k:latest                      95f47179da5c    18 GB     6 days ago
qwen3-coder:latest                          06c1097efce0    18 GB     6 days ago
ollama show qwen3-coder --modelfile | grep -C2 RENDERER
FROM /Users/maks/.ollama/models/blobs/sha256-1194192cf2a187eb02722edcc3f77b11d21f537048ce04b67ccf8ba78863006a
TEMPLATE {{ .Prompt }}
RENDERER qwen3-coder
PARSER qwen3-coder
PARAMETER repeat_penalty 1.05
<!-- gh-comment-id:3449448140 --> @maks commented on GitHub (Oct 27, 2025): > > And sure enough when I try to use qwen3-coder with opencode it reports the model doesn't support tool calling. If I try it with qwen3 the tool calling works as expected (note I set both models to 16k context when testing with oepncode because it requires bigger ctxs) > > can you show me the output of `ollama show qwen3-coder:latest` and also `ollama show qwen3-coder --modelfile | grep -C2 RENDERER`? qwen3-coder isn't actually using that dummy template, it should be using our newer built-in renderer and parser for it. When it uses that parser it should have the tools capability Sorry for the slow reply @drifkin . Here is the output I get, is this what is expected? ``` ollama ls|grep qwen3-coder qwen3-coder-16k:latest 95f47179da5c 18 GB 6 days ago qwen3-coder:latest 06c1097efce0 18 GB 6 days ago ``` ``` ollama show qwen3-coder --modelfile | grep -C2 RENDERER FROM /Users/maks/.ollama/models/blobs/sha256-1194192cf2a187eb02722edcc3f77b11d21f537048ce04b67ccf8ba78863006a TEMPLATE {{ .Prompt }} RENDERER qwen3-coder PARSER qwen3-coder PARAMETER repeat_penalty 1.05 ```
Author
Owner

@rcillo commented on GitHub (Oct 27, 2025):

@maks one thing I noticed is that when making changes to parameters, such as /set parameter num_ctx 16384, as many opencode users do, after saving these changes with /save qwen3-coder:opencode, the tools capability is gone. It's no longer there when ollama show qwen3-coder:opencode.

Before:
ollama show qwen3-coder:latest

  Model
    architecture        qwen3moe    
    parameters          30.5B       
    context length      262144      
    embedding length    2048        
    quantization        Q4_K_M      

  Capabilities
    completion    
    tools         

  Parameters
    stop              "<|im_start|>"     
    stop              "<|im_end|>"       
    stop              "<|endoftext|>"    
    temperature       0.7                
    top_k             20                 
    top_p             0.8                
    repeat_penalty    1.05               

After:
ollama show qwen3-coder:opencode

  Model
    architecture        qwen3moe    
    parameters          30.5B       
    context length      262144      
    embedding length    2048        
    quantization        Q4_K_M      

  Capabilities
    completion    

  Parameters
    num_ctx           16384              
    repeat_penalty    1.05               
    stop              "<|im_start|>"     
    stop              "<|im_end|>"       
    stop              "<|endoftext|>"    
    temperature       0.7                
    top_k             20                 
    top_p             0.8     

Something happens when saving the change to parameters that erases tool from the list of capabilities for this particular model. I was able to make these changes for other models, such as qwen3, for example, without issues. That might explain your frustration. It's not that @drifkin didn't fix it, it's that it's still partially broken (unable to update parameters).

<!-- gh-comment-id:3451563030 --> @rcillo commented on GitHub (Oct 27, 2025): @maks one thing I noticed is that when making changes to parameters, such as `/set parameter num_ctx 16384`, as many opencode users do, after saving these changes with `/save qwen3-coder:opencode`, the `tools` capability is gone. It's no longer there when `ollama show qwen3-coder:opencode`. Before: `ollama show qwen3-coder:latest` ``` Model architecture qwen3moe parameters 30.5B context length 262144 embedding length 2048 quantization Q4_K_M Capabilities completion tools Parameters stop "<|im_start|>" stop "<|im_end|>" stop "<|endoftext|>" temperature 0.7 top_k 20 top_p 0.8 repeat_penalty 1.05 ``` After: `ollama show qwen3-coder:opencode` ``` Model architecture qwen3moe parameters 30.5B context length 262144 embedding length 2048 quantization Q4_K_M Capabilities completion Parameters num_ctx 16384 repeat_penalty 1.05 stop "<|im_start|>" stop "<|im_end|>" stop "<|endoftext|>" temperature 0.7 top_k 20 top_p 0.8 ``` Something happens when saving the change to parameters that erases `tool` from the list of capabilities for this particular model. I was able to make these changes for other models, such as `qwen3`, for example, without issues. That might explain your frustration. It's not that @drifkin didn't fix it, it's that it's still partially broken (unable to update parameters).
Author
Owner

@drifkin commented on GitHub (Oct 27, 2025):

Something happens when saving the change to parameters that erases tool from the list of capabilities for this particular model. I was able to make these changes for other models, such as qwen3, for example, without issues. That might explain your frustration. It's not that @drifkin didn't fix it, it's that it's still partially broken (unable to update parameters).

Thanks so much @rcillo! I can repro that easily. I have a suspicion about what it is, I'll verify later today and get a fix pushed.

<!-- gh-comment-id:3452380934 --> @drifkin commented on GitHub (Oct 27, 2025): > Something happens when saving the change to parameters that erases `tool` from the list of capabilities for this particular model. I was able to make these changes for other models, such as `qwen3`, for example, without issues. That might explain your frustration. It's not that [@drifkin](https://github.com/drifkin) didn't fix it, it's that it's still partially broken (unable to update parameters). Thanks so much @rcillo! I can repro that easily. I have a suspicion about what it is, I'll verify later today and get a fix pushed.
Author
Owner

@pminervini commented on GitHub (Oct 27, 2025):

it's been ~3 months and qwen3-coder is still broken in ollama, this is awkward -- how is someone supposed to use it over llama.cpp or lm studio?

<!-- gh-comment-id:3452552232 --> @pminervini commented on GitHub (Oct 27, 2025): it's been ~3 months and qwen3-coder is still broken in ollama, this is awkward -- how is someone supposed to use it over llama.cpp or lm studio?
Author
Owner

@drifkin commented on GitHub (Oct 27, 2025):

@pminervini: are you running into trouble with this model? qwen3-coder is generally working very well, I think in the past few replies we've discovered an issue with a bug with model saving, which I'll get fixed quickly

<!-- gh-comment-id:3452841506 --> @drifkin commented on GitHub (Oct 27, 2025): @pminervini: are you running into trouble with this model? qwen3-coder is generally working very well, I think in the past few replies we've discovered an issue with a bug with model saving, which I'll get fixed quickly
Author
Owner

@drifkin commented on GitHub (Oct 27, 2025):

was able to repro and fix in https://github.com/ollama/ollama/pull/12793, will try to get that in shortly. Thanks again for reporting @rcillo and @maks (I suspect it's the same root cause for you too, since you said you increased the context size for the model?)

<!-- gh-comment-id:3453536736 --> @drifkin commented on GitHub (Oct 27, 2025): was able to repro and fix in <https://github.com/ollama/ollama/pull/12793>, will try to get that in shortly. Thanks again for reporting @rcillo and @maks (I suspect it's the same root cause for you too, since you said you increased the context size for the model?)
Author
Owner

@maks commented on GitHub (Oct 27, 2025):

awesome thanks @drifkin ! 🎉 Yes I did increase the context size for the model, but I think I was also seeing this when trying to use the "original" model that I downloaded and looking at your PR it seems this fix is only for the bug where modified models are created using /save. But I'll double check and test with original model here to be sure I'm remembering correctly.

<!-- gh-comment-id:3453552270 --> @maks commented on GitHub (Oct 27, 2025): awesome thanks @drifkin ! 🎉 Yes I did increase the context size for the model, but I think I was also seeing this when trying to use the "original" model that I downloaded and looking at your PR it seems this fix is only for the bug where modified models are created using /save. But I'll double check and test with original model here to be sure I'm remembering correctly.
Author
Owner

@rcillo commented on GitHub (Oct 28, 2025):

hi @maks, just updating here on this thread, the problem is solved on main https://github.com/ollama/ollama/pull/12793#issuecomment-3456316404 kudos to @drifkin for the fast fix.

<!-- gh-comment-id:3456321999 --> @rcillo commented on GitHub (Oct 28, 2025): hi @maks, just updating here on this thread, the problem is solved on `main` https://github.com/ollama/ollama/pull/12793#issuecomment-3456316404 kudos to @drifkin for the fast fix.
Author
Owner

@ramarivera commented on GitHub (Nov 15, 2025):

Hey @drifkin 👋🏻
Just trying to understand what is the fix for this issue, and how to check whether we have the fix or not. Should I just update to latest ollama and it should work?

<!-- gh-comment-id:3535186627 --> @ramarivera commented on GitHub (Nov 15, 2025): Hey @drifkin 👋🏻 Just trying to understand what is the fix for this issue, and how to check whether we have the fix or not. Should I just update to latest ollama and it should work?
Author
Owner

@drifkin commented on GitHub (Nov 15, 2025):

Hey @drifkin 👋🏻 Just trying to understand what is the fix for this issue, and how to check whether we have the fix or not. Should I just update to latest ollama and it should work?

yes and re-pull the model as well (some metadata may have changed since you originally pulled it). ollama pull qwen3-coder

<!-- gh-comment-id:3535195341 --> @drifkin commented on GitHub (Nov 15, 2025): > Hey [@drifkin](https://github.com/drifkin) 👋🏻 Just trying to understand what is the fix for this issue, and how to check whether we have the fix or not. Should I just update to latest ollama and it should work? yes and re-pull the model as well (some metadata may have changed since you originally pulled it). `ollama pull qwen3-coder`
Author
Owner

@ramarivera commented on GitHub (Nov 15, 2025):

Same thing unfortunately after updating ollama and the model :(

Output in case its useful

┌─ @ramiros-macbook-pro   …/-automations    master [✘!?⇡]
└─✗ ollama pull qwen3-coder
pulling manifest
pulling 1194192cf2a1: 100% ▕██████████████████████████████▏  18 GB
pulling d18a5cc71b84: 100% ▕██████████████████████████████▏  11 KB
pulling 69aa441ea44f: 100% ▕██████████████████████████████▏  148 B
pulling 24a94682582c: 100% ▕██████████████████████████████▏  542 B
verifying sha256 digest
writing manifest
success

┌─ @ramiros-macbook-pro   …/-automations    master [✘!?⇡]
└─➜ ollama show qwen3-coder:latest --modelfile | grep -C2 RENDERER
FROM /Users/ramarivera/.ollama/models/blobs/sha256-1194192cf2a187eb02722edcc3f77b11d21f537048ce04b67ccf8ba78863006a
TEMPLATE {{ .Prompt }}
RENDERER qwen3-coder
PARSER qwen3-coder
PARAMETER top_k 20

┌─ @ramiros-macbook-pro   …/-automations    master [✘!?⇡]
└─➜ ollama show qwen3-coder:latest --template

{{ .Prompt }}
<!-- gh-comment-id:3535252185 --> @ramarivera commented on GitHub (Nov 15, 2025): Same thing unfortunately after updating ollama and the model :( Output in case its useful ``` ┌─ @ramiros-macbook-pro …/-automations master [✘!?⇡] └─✗ ollama pull qwen3-coder pulling manifest pulling 1194192cf2a1: 100% ▕██████████████████████████████▏ 18 GB pulling d18a5cc71b84: 100% ▕██████████████████████████████▏ 11 KB pulling 69aa441ea44f: 100% ▕██████████████████████████████▏ 148 B pulling 24a94682582c: 100% ▕██████████████████████████████▏ 542 B verifying sha256 digest writing manifest success ┌─ @ramiros-macbook-pro …/-automations master [✘!?⇡] └─➜ ollama show qwen3-coder:latest --modelfile | grep -C2 RENDERER FROM /Users/ramarivera/.ollama/models/blobs/sha256-1194192cf2a187eb02722edcc3f77b11d21f537048ce04b67ccf8ba78863006a TEMPLATE {{ .Prompt }} RENDERER qwen3-coder PARSER qwen3-coder PARAMETER top_k 20 ┌─ @ramiros-macbook-pro …/-automations master [✘!?⇡] └─➜ ollama show qwen3-coder:latest --template {{ .Prompt }} ```
Author
Owner

@drifkin commented on GitHub (Nov 15, 2025):

Same thing unfortunately after updating ollama and the model :(

that all looks correct, could you open a new issue with some details on how you're trying to use it and what's happening?

<!-- gh-comment-id:3535273174 --> @drifkin commented on GitHub (Nov 15, 2025): > Same thing unfortunately after updating ollama and the model :( > that all looks correct, could you open a new issue with some details on how you're trying to use it and what's happening?
Author
Owner

@ramarivera commented on GitHub (Nov 15, 2025):

Done @drifkin https://github.com/ollama/ollama/issues/13093

<!-- gh-comment-id:3535280856 --> @ramarivera commented on GitHub (Nov 15, 2025): Done @drifkin https://github.com/ollama/ollama/issues/13093
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/ollama#33435