Skip to content

Conversation

@JM-Lab
Copy link
Contributor

@JM-Lab JM-Lab commented Dec 8, 2025

When using Ollama's OpenAI-compatible /api/chat endpoint with think: true and stream: true, some models (e.g., qwen3, deepseek-r1) emit reasoning tokens in the thinking field instead of the standard OpenAI reasoning_content field.

This causes the reasoning trace to be lost in the current implementation, as ChatCompletionMessage.reasoningContent only deserializes the standard field name.

Example (Ollama 0.13.1, 0.12.11)

curl http://localhost:11434/api/chat -d '{
  "model": "qwen3",
  "messages": [{"role": "user", "content": "Summarize why HTTP/2 is faster."}],
  "think": true,
  "stream": true
}'

Streamed chunks contain:

{"model":"qwen3","created_at":"2025-12-08T06:23:02.518809Z","message":{"role":"assistant","content":"","thinking":"Okay"},"done":false}
{"model":"qwen3","created_at":"2025-12-08T06:23:02.562574Z","message":{"role":"assistant","content":"","thinking":","},"done":false}
{"model":"qwen3","created_at":"2025-12-08T06:23:02.606487Z","message":{"role":"assistant","content":"","thinking":" so"},"done":false}
{"model":"qwen3","created_at":"2025-12-08T06:23:02.650708Z","message":{"role":"assistant","content":"","thinking":" I"},"done":false}

In this format, the reasoning trace is emitted in the thinking field, not reasoning_content, so ChatCompletionMessage currently does not capture it.

This PR adds @JsonAlias("reasoning") to the reasoningContent field in ChatCompletionMessage to ensure compatibility with both field names.

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.

1 participant