[GH-ISSUE #12763] Gpt-Oss Template does not handle enum arrays correctly In Tools #8464

Open
opened 2026-04-12 21:09:29 -05:00 by GiteaMirror · 0 comments
Owner

Originally created by @sharan245 on GitHub (Oct 24, 2025).
Original GitHub issue: https://github.com/ollama/ollama/issues/12763

Originally assigned to: @drifkin on GitHub.

Issue:
The current Ollama TypeScript template does not handle enum provided in Tools,

from ollama offical Document tools field has enum format allowed

 "tools": [
    {
      "type": "function",
      "function": {
        "name": "get_current_weather",
        "description": "Get the current weather for a location",
        "parameters": {
          "type": "object",
          "properties": {
            "location": {
              "type": "string",
              "description": "The location to get the weather for, e.g. San Francisco, CA"
            },
            "format": {
              "type": "string",
              "description": "The format to return the weather in, e.g. 'celsius' or 'fahrenheit'",
              "enum": ["celsius", "fahrenheit"] // <-----enum allowed ----->
            }
          },
          "required": ["location", "format"]
        }
      }
    }
  ]

while in gpt oss template this is skipped and not handled

{{- if $prop.Description }}
  // {{ $prop.Description }}
{{- end }}
  **{{ $name }}: {{ $prop | toTypeScriptType }},  // not checking enum types**

so even after passing enum in tool call output is name: any[]

I did some quick fix my self and changed template.


{{- if $prop.Description }}
  // {{ $prop.Description }}
{{- end }}

{{- $propType := printf "%v" $prop.Type }}
{{- if eq $propType "array" }}
  {{- if $prop.Items }}
    {{- $items := $prop.Items }}
    {{- if (index $items "enum") }}
      {{ $name }}: ({{ range $i, $v := (index $items "enum") }}{{ if $i }} | {{ end }}'{{ $v }}'{{ end }})[],
    {{- else if (index $items "type") }}
      {{ $name }}: {{ printf "%v" (index $items "type") | toTypeScriptType }}[],
    {{- else }}
      {{ $name }}: any[],
    {{- end }}
  {{- else }}
    {{ $name }}: any[],
  {{- end }}
{{- else }}
  {{ $name }}: {{ $prop | toTypeScriptType }},
{{- end }}

now the ouput is name: ('EnumFiled1' | 'EnumFiled2' | 'EnumFiledN' )[]

while i am not good with Go template
I think there is better way to fix this.

Relevant log output


OS

No response

GPU

No response

CPU

No response

Ollama version

No response

Originally created by @sharan245 on GitHub (Oct 24, 2025). Original GitHub issue: https://github.com/ollama/ollama/issues/12763 Originally assigned to: @drifkin on GitHub. Issue: **The current Ollama TypeScript template does not handle enum provided in Tools,** from ollama offical Document tools field has enum format allowed ``` "tools": [ { "type": "function", "function": { "name": "get_current_weather", "description": "Get the current weather for a location", "parameters": { "type": "object", "properties": { "location": { "type": "string", "description": "The location to get the weather for, e.g. San Francisco, CA" }, "format": { "type": "string", "description": "The format to return the weather in, e.g. 'celsius' or 'fahrenheit'", "enum": ["celsius", "fahrenheit"] // <-----enum allowed -----> } }, "required": ["location", "format"] } } } ] ``` while in gpt oss template this is skipped and not handled ``` {{- if $prop.Description }} // {{ $prop.Description }} {{- end }} **{{ $name }}: {{ $prop | toTypeScriptType }}, // not checking enum types** ``` so even after passing enum in tool call output is **`name: any[]`** I did some quick fix my self and changed template. ``` {{- if $prop.Description }} // {{ $prop.Description }} {{- end }} {{- $propType := printf "%v" $prop.Type }} {{- if eq $propType "array" }} {{- if $prop.Items }} {{- $items := $prop.Items }} {{- if (index $items "enum") }} {{ $name }}: ({{ range $i, $v := (index $items "enum") }}{{ if $i }} | {{ end }}'{{ $v }}'{{ end }})[], {{- else if (index $items "type") }} {{ $name }}: {{ printf "%v" (index $items "type") | toTypeScriptType }}[], {{- else }} {{ $name }}: any[], {{- end }} {{- else }} {{ $name }}: any[], {{- end }} {{- else }} {{ $name }}: {{ $prop | toTypeScriptType }}, {{- end }} ``` now the ouput is **`name: ('EnumFiled1' | 'EnumFiled2' | 'EnumFiledN' )[]`** while i am not good with Go template I think there is better way to fix this. ### Relevant log output ```shell ``` ### OS _No response_ ### GPU _No response_ ### CPU _No response_ ### Ollama version _No response_
GiteaMirror added the toolsbug labels 2026-04-12 21:09:29 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/ollama#8464