GPT-OSS with ChatOllama thinking process seems to be misconfigured

I’m trying to view the thinking process of Gpt-oss. I’m running the model through the ChatOllama LLM and using agent_exeuctor() with some custom tools.

The code I’m using to run the model:

memory = InMemoryChatMessageHistory(session_id="test-session")
messages = ChatPromptTemplate.from_messages(
    [
        ("system", system),
        ("placeholder", "{chat_history}"),
        ("human", "{input}"),
        ("placeholder", "{agent_scratchpad}"),
    ]
)

llm = ChatOllama(
    model="gpt-oss:120b",
    validate_model_on_init=True,
    temperature=0,
    model_kwargs={"think": "high"}
)

agent_executor = AgentExecutor(
    agent=agent,
    tools=tools,
    verbose=True,
)

with_message_history = RunnableWithMessageHistory(
    agent_executor,
    lambda session_id: memory,
    input_messages_key="input",
    history_messages_key="chat_history",
)

response = await with_message_history.ainvoke(
    {"input": prompt},
    {"configurable": {"session_id": "test-session"}}
)
print(f"Agent response: {response['output']}")

The verbose output shows the tool calls, but does not show the thinking process of the LLM. Also, when changing the “think” parameter from “low” to “medium”, or “high”, the outputs and tool calls remain the same, which leads me to believe the parameter is not being applied correctly.

I’ve also tried with langchain.debug = True, and this also does not show the thinking, or the intermediate steps.

I changed model_kwargs={"think": "high"} to reasoning="high” and turned langchain.debug = True which seems to show the thinking tokens, but I think that there might be an issue with the chat history and how it’s being presented to the model during the agent chain.

Has anyone else investigated the GPT-OSS thinking process?

HI @esbh25, what version of langchain-ollama are you running?