fix(openai): add reasoning_content to StreamingDelta for OpenAI-compatible providers#1441
Merged
joshua-mo-143 merged 3 commits into0xPlaygrounds:mainfrom Mar 4, 2026
Conversation
…tible providers The OpenAI Chat Completions streaming parser (StreamingDelta) does not parse the easoning_content field from SSE chunks, causing reasoning/ thinking content from OpenAI-compatible providers to be silently dropped. This affects all models that send easoning_content via the standard Chat Completions streaming format, including: - GLM-4.7 (Zhipu AI) - DeepSeek models via OpenAI-compatible endpoints - Qwen with thinking mode - vLLM / Ollama OpenAI-compatible endpoints The fix adds easoning_content: Option<String> to StreamingDelta and yields RawStreamingChoice::ReasoningDelta events when present, matching the existing pattern in the DeepSeek-specific provider. Note: RawStreamingChoice::ReasoningDelta was already defined in streaming.rs (added in PR 0xPlaygrounds#1395), but the generic OpenAI streaming parser never utilized it.
joshua-mo-143
suggested changes
Feb 26, 2026
Contributor
joshua-mo-143
left a comment
There was a problem hiding this comment.
Seems OK to me. See my comment
Comment on lines
+38
to
+39
| #[serde(default)] | ||
| reasoning_content: Option<String>, |
Contributor
There was a problem hiding this comment.
please add docstring to state that this is not part of the official OpenAI API, it's for compliant providers
Contributor
Author
There was a problem hiding this comment.
He should look like this; I've already changed it.
Because the change has already been marked in another location.
Thanks for the review.
#[serde(default)]
reasoning_content: Option<String>, // This is not part of the official OpenAI APIAdded a comment to clarify that reasoning_content is not part of the official OpenAI API.
joshua-mo-143
approved these changes
Mar 4, 2026
Contributor
joshua-mo-143
left a comment
There was a problem hiding this comment.
Seems OK to me I think. Thanks for contributing this change!
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #1440
Summary
The generic OpenAI Chat Completions streaming parser (
StreamingDelta) does not parse thereasoning_contentfield from SSE chunks, causing reasoning/thinking content to be silently dropped for all OpenAI-compatible providers.This is a 2-line fix that adds
reasoning_contentsupport tosend_compatible_streaming_request, matching the existing pattern in the DeepSeek-specific provider.Changes
File:
rig-core/src/providers/openai/completion/streaming.rsreasoning_contentfield toStreamingDeltastruct (line 38-39)RawStreamingChoice::ReasoningDeltawhen reasoning content is present in the stream (lines 250-256)Context
RawStreamingChoice::ReasoningDeltawas added in PR refactor: typed reasoning content model #1395 and is used by specialized providers (Anthropic, Gemini, xAI, OpenRouter) via PR feat: cross-provider reasoning trace roundtrip #1396StreamingDeltawithreasoning_content(deepseek.rs:722), so it works independentlyAffected Providers
All models using
reasoning_contentvia the standard Chat Completions streaming format:Testing
Verified end-to-end with GLM-4.7:
ReasoningDeltaevents (reasoning silently dropped)ReasoningDeltaevents captured, full thinking chain preservedExisting tests pass — the new
reasoning_contentfield uses#[serde(default)]so it's backward-compatible (absent field →None).