Skip to content

fix: accept Ollama reasoning field in OpenAI Chat deltas#36068

Open
twhittock wants to merge 2 commits into
anomalyco:devfrom
twhittock:fix/ollama-reasoning-field
Open

fix: accept Ollama reasoning field in OpenAI Chat deltas#36068
twhittock wants to merge 2 commits into
anomalyco:devfrom
twhittock:fix/ollama-reasoning-field

Conversation

@twhittock

Copy link
Copy Markdown

Ollama's /v1/chat/completions endpoint emits reasoning output in a reasoning field (both streaming deltas and non-streaming messages), not reasoning_content which is the DeepSeek/LM Studio convention. Effect's Schema.Struct strips unknown keys, so the reasoning content was silently discarded - producing empty responses for thinking models like glm-5.2 via Ollama Cloud.

Adds reasoning as a fallback alongside reasoning_content in the delta schema, message schema, and helper function, matching how other OpenAI-compatible clients already handle this.

Refs: ollama/ollama#16853, RightNow-AI/openfang#805

Issue for this PR

Closes #34798

Type of change

  • Bug fix
  • New feature
  • Refactor / code improvement
  • Documentation

What does this PR do?

Extends "OpenAI compatible" schema shape to include Ollama's reasoning field alongside the existing reasoning_content.

How did you verify your code works?

Build & run locally, observed GLM-5.2 responses from ollama cloud are now working.

Screenshots / recordings

N/A

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

If you do not follow this template your PR will be automatically rejected.

@github-actions

github-actions Bot commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

The following comment was made by an LLM, it may be inaccurate:

I found a related PR that appears to be addressing the same issue:

PR #35284: fix(llm): accept \reasoning` field in OpenAI-compatible streams`
#35284

This PR appears to be directly related to the current PR #36068 since both are working on accepting the reasoning field in OpenAI-compatible streams. The earlier PR #35284 may already address this issue, so you should verify whether:

  1. PR fix(llm): accept reasoning field in OpenAI-compatible streams #35284 was merged and already includes this fix
  2. PR fix: accept Ollama reasoning field in OpenAI Chat deltas #36068 is updating or extending that work further
  3. These PRs are actually addressing the same problem or different aspects

Additionally, PR #34283: fix(provider): expose xhigh instead of max for GLM-5.2 on OpenAI-compatible is contextually related since it also deals with GLM-5.2 handling on OpenAI-compatible providers, which is the model mentioned in your PR description.

opencode and others added 2 commits July 14, 2026 21:37
Ollama's /v1/chat/completions endpoint emits reasoning output in a
`reasoning` field (both streaming deltas and non-streaming messages),
not `reasoning_content` which is the DeepSeek/LM Studio convention.
Effect's Schema.Struct strips unknown keys, so the reasoning content
was silently discarded - producing empty responses for thinking
models like glm-5.2 via Ollama Cloud.

Adds `reasoning` as a fallback alongside `reasoning_content`
in the delta schema, message schema, and helper function, matching
how other OpenAI-compatible clients already handle this.

Refs: ollama/ollama#16853, RightNow-AI/openfang#805
@twhittock twhittock force-pushed the fix/ollama-reasoning-field branch from aa72711 to 0bdc839 Compare July 15, 2026 04:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Conversations hang after first response when provider returns a reasoning field (using Ollama/Qwen3)

1 participant