[GH-ISSUE #12158] Response message after a tool_call with OpenAI chat completions and gpt-oss missing "reasoning" #8083

Open
opened 2026-04-12 20:22:46 -05:00 by GiteaMirror · 1 comment
Owner

Originally created by @pamelafox on GitHub (Sep 2, 2025).
Original GitHub issue: https://github.com/ollama/ollama/issues/12158

Originally assigned to: @ParthSareen on GitHub.

What is the issue?

When we call gpt-oss with the OpenAI chat completions API (/v1/ endpoint), the response contains a choices list, and the first choice has a message, and that message has a reasoning field.

However, when I then execute a tool call and send that longer thread to the model, the response has no reasoning field.

Code to replicate:

import json
import os

import azure.identity
import openai
from dotenv import load_dotenv

load_dotenv(override=True)

client = openai.OpenAI(base_url=os.environ["OLLAMA_ENDPOINT"], api_key="nokeyneeded")
MODEL_NAME = "gpt-oss:20b"


def lookup_weather(city_name=None, zip_code=None):
    """Lookup the weather for a given city name or zip code."""
    return {
        "city_name": city_name,
        "zip_code": zip_code,
        "weather": "sunny",
        "temperature": 75,
    }


tools = [
    {
        "type": "function",
        "function": {
            "name": "lookup_weather",
            "description": "Lookup the weather for a given city name or zip code.",
            "parameters": {
                "type": "object",
                "properties": {
                    "city_name": {
                        "type": "string",
                        "description": "The city name",
                    },
                    "zip_code": {
                        "type": "string",
                        "description": "The zip code",
                    },
                },
                "strict": True,
                "additionalProperties": False,
            },
        },
    }
]

messages = [
    {"role": "system", "content": "You are a weather chatbot."},
    {"role": "user", "content": "is it sunny in berkeley CA?"},
]
response = client.chat.completions.create(
    model=MODEL_NAME,
    messages=messages,
    tools=tools,
    tool_choice="auto",
    reasoning_effort="medium"
)

print(f"Response from {MODEL_NAME} on {API_HOST}: \n")

# Now actually call the function as indicated

print("Thinking...")
print (response.choices[0].message.reasoning)
print("Done thinking.")
if response.choices[0].message.tool_calls:
    tool_call = response.choices[0].message.tool_calls[0]
    function_name = tool_call.function.name
    arguments = json.loads(tool_call.function.arguments)

    if function_name == "lookup_weather":
        messages.append(response.choices[0].message)
        result = lookup_weather(**arguments)
        messages.append({"role": "tool", "tool_call_id": tool_call.id, "content": str(result)})
        print(messages)
        response = client.chat.completions.create(model=MODEL_NAME, messages=messages, tools=tools, reasoning_effort="medium")
        # Potential bug: The follow-up message has NO reasoning field
        #print("Thinking...")
        #print (response.choices[0].message.reasoning)
        #print("Done thinking.")
        print(response.choices[0].message.content)

Relevant log output


OS

Docker, Linux

GPU

Nvidia

CPU

Intel

Ollama version

0.11.8

Originally created by @pamelafox on GitHub (Sep 2, 2025). Original GitHub issue: https://github.com/ollama/ollama/issues/12158 Originally assigned to: @ParthSareen on GitHub. ### What is the issue? When we call gpt-oss with the OpenAI chat completions API (/v1/ endpoint), the response contains a choices list, and the first choice has a message, and that message has a reasoning field. However, when I then execute a tool call and send that longer thread to the model, the response has *no* reasoning field. Code to replicate: ``` import json import os import azure.identity import openai from dotenv import load_dotenv load_dotenv(override=True) client = openai.OpenAI(base_url=os.environ["OLLAMA_ENDPOINT"], api_key="nokeyneeded") MODEL_NAME = "gpt-oss:20b" def lookup_weather(city_name=None, zip_code=None): """Lookup the weather for a given city name or zip code.""" return { "city_name": city_name, "zip_code": zip_code, "weather": "sunny", "temperature": 75, } tools = [ { "type": "function", "function": { "name": "lookup_weather", "description": "Lookup the weather for a given city name or zip code.", "parameters": { "type": "object", "properties": { "city_name": { "type": "string", "description": "The city name", }, "zip_code": { "type": "string", "description": "The zip code", }, }, "strict": True, "additionalProperties": False, }, }, } ] messages = [ {"role": "system", "content": "You are a weather chatbot."}, {"role": "user", "content": "is it sunny in berkeley CA?"}, ] response = client.chat.completions.create( model=MODEL_NAME, messages=messages, tools=tools, tool_choice="auto", reasoning_effort="medium" ) print(f"Response from {MODEL_NAME} on {API_HOST}: \n") # Now actually call the function as indicated print("Thinking...") print (response.choices[0].message.reasoning) print("Done thinking.") if response.choices[0].message.tool_calls: tool_call = response.choices[0].message.tool_calls[0] function_name = tool_call.function.name arguments = json.loads(tool_call.function.arguments) if function_name == "lookup_weather": messages.append(response.choices[0].message) result = lookup_weather(**arguments) messages.append({"role": "tool", "tool_call_id": tool_call.id, "content": str(result)}) print(messages) response = client.chat.completions.create(model=MODEL_NAME, messages=messages, tools=tools, reasoning_effort="medium") # Potential bug: The follow-up message has NO reasoning field #print("Thinking...") #print (response.choices[0].message.reasoning) #print("Done thinking.") print(response.choices[0].message.content) ``` ### Relevant log output ```shell ``` ### OS Docker, Linux ### GPU Nvidia ### CPU Intel ### Ollama version 0.11.8
GiteaMirror added the bug label 2026-04-12 20:22:46 -05:00
Author
Owner

@lefoulkrod commented on GitHub (Sep 6, 2025):

Possibly related to https://github.com/ollama/ollama/issues/12203

<!-- gh-comment-id:3262164683 --> @lefoulkrod commented on GitHub (Sep 6, 2025): Possibly related to https://github.com/ollama/ollama/issues/12203
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/ollama#8083