[GH-ISSUE #10983] Cannot use 0.9.0 Thinking API with Cogito/Granite models #7240

Open
opened 2026-04-12 19:16:12 -05:00 by GiteaMirror · 2 comments
Owner

Originally created by @laniakea64 on GitHub (Jun 5, 2025).
Original GitHub issue: https://github.com/ollama/ollama/issues/10983

The Cogito models support both reasoning and non-reasoning modes. But when trying to use the new Ollama 0.9.0 Thinking API with cogito:14b, Ollama returns a HTTP/400 response. When using Ollama as the client, it looks like this:

$ ollama run cogito:14b
>>> /set think
warning: model "cogito:14b" does not support thinking output
Set 'think' mode.
>>> Hello
error: registry.ollama.ai/library/cogito:14b does not support thinking
>>>

(This ollama binary is the same one as the server.)

If I understand correctly, support for the Thinking API requires an update to the template for the model. Could you please update the Cogito models' templates to add support for the Thinking API? Thanks!

Originally created by @laniakea64 on GitHub (Jun 5, 2025). Original GitHub issue: https://github.com/ollama/ollama/issues/10983 The [Cogito models](https://ollama.com/library/cogito) support both reasoning and non-reasoning modes. But when trying to use the new Ollama 0.9.0 Thinking API with `cogito:14b`, Ollama returns a HTTP/400 response. When using Ollama as the client, it looks like this: ``` $ ollama run cogito:14b >>> /set think warning: model "cogito:14b" does not support thinking output Set 'think' mode. >>> Hello error: registry.ollama.ai/library/cogito:14b does not support thinking >>> ``` (This `ollama` binary is the same one as the server.) If I understand correctly, support for the Thinking API requires an update to the template for the model. Could you please update the Cogito models' templates to add support for the Thinking API? Thanks!
GiteaMirror added the thinking label 2026-04-12 19:16:12 -05:00
Author
Owner

@laniakea64 commented on GitHub (Jul 6, 2025):

Hi, any update on updating the Cogito models' templates to support the Thinking API?

In case it's useful, I had a go at this myself and may have got somewhere. Here is my attempt at a Modelfile to extend cogito:14b with Thinking API support, based on how it was done in qwen3's template:

FROM cogito:14b
TEMPLATE """{{- if .Messages }}
{{- $lastUserIdx := -1 -}}
{{- range $idx, $msg := .Messages -}}
{{- if eq $msg.Role "user" }}{{ $lastUserIdx = $idx }}{{ end -}}
{{- end }}
{{- if or .System .Tools .Think }}<|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 }}
{{- if .Think }}
  {{- " "}}Enable deep thinking subroutine.
{{- 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 (and $.IsThinkSet (and .Thinking (or $last (gt $i $lastUserIdx)))) -}}
<think>{{ .Thinking }}</think>
{{ end -}}
{{ 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 or .System .Think }}<|im_start|>system
{{ if .System }}
{{ .System }}
{{- end }}
{{- if .Think }}
  {{- " "}}Enable deep thinking subroutine.
{{- end }}<|im_end|>
{{ end }}{{ if .Prompt }}<|im_start|>user
{{ .Prompt }}<|im_end|>
{{ end }}<|im_start|>assistant
{{ end }}{{ .Response }}{{ if .Response }}<|im_end|>{{ end }}"""

Testing with Ollama 0.9.5 and so far it seems to be working. I'm totally new to understanding/editing model templates and don't understand all of the changes I added, so if the changes could be improved, feedback would be appreciated 🙂

<!-- gh-comment-id:3042328506 --> @laniakea64 commented on GitHub (Jul 6, 2025): Hi, any update on updating the Cogito models' templates to support the Thinking API? In case it's useful, I had a go at this myself and may have got somewhere. Here is my attempt at a `Modelfile` to extend `cogito:14b` with Thinking API support, based on how it was done in `qwen3`'s template: ``` FROM cogito:14b TEMPLATE """{{- if .Messages }} {{- $lastUserIdx := -1 -}} {{- range $idx, $msg := .Messages -}} {{- if eq $msg.Role "user" }}{{ $lastUserIdx = $idx }}{{ end -}} {{- end }} {{- if or .System .Tools .Think }}<|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 }} {{- if .Think }} {{- " "}}Enable deep thinking subroutine. {{- 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 (and $.IsThinkSet (and .Thinking (or $last (gt $i $lastUserIdx)))) -}} <think>{{ .Thinking }}</think> {{ end -}} {{ 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 or .System .Think }}<|im_start|>system {{ if .System }} {{ .System }} {{- end }} {{- if .Think }} {{- " "}}Enable deep thinking subroutine. {{- end }}<|im_end|> {{ end }}{{ if .Prompt }}<|im_start|>user {{ .Prompt }}<|im_end|> {{ end }}<|im_start|>assistant {{ end }}{{ .Response }}{{ if .Response }}<|im_end|>{{ end }}""" ``` Testing with Ollama 0.9.5 and so far it seems to be working. I'm totally new to understanding/editing model templates and don't understand all of the changes I added, so if the changes could be improved, feedback would be appreciated 🙂
Author
Owner

@rhiza-fr commented on GitHub (Jul 8, 2025):

If it is useful for you, this project makes cogito, granite3.2 and granite3.3 seem to support thinking mode without altering distributed model files. https://github.com/rhiza-fr/ollama-think

<!-- gh-comment-id:3049035407 --> @rhiza-fr commented on GitHub (Jul 8, 2025): If it is useful for you, this project makes cogito, granite3.2 and granite3.3 seem to support thinking mode without altering distributed model files. https://github.com/rhiza-fr/ollama-think
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/ollama#7240