refactor: typed reasoning content model#1395
Merged
joshua-mo-143 merged 4 commits into0xPlaygrounds:mainfrom Feb 16, 2026
Merged
refactor: typed reasoning content model#1395joshua-mo-143 merged 4 commits into0xPlaygrounds:mainfrom
joshua-mo-143 merged 4 commits into0xPlaygrounds:mainfrom
Conversation
Replace panic!() with graceful handling when providers encounter reasoning content they don't support (OpenAI Chat Completions, Mistral, HuggingFace, Together). Previously these would crash the process; now they skip unsupported reasoning blocks. Part of 0xPlaygrounds#1147, 0xPlaygrounds#684
Replace the flat Reasoning struct with a discriminated content model:
- ReasoningContent::Text { text, signature } — signed thinking blocks
- ReasoningContent::Encrypted — opaque state for stateless replay
- ReasoningContent::Redacted — safety-flagged content (Anthropic)
- ReasoningContent::Summary — sanitized summaries (OpenAI, xAI)
Add message_id to CompletionResponse and streaming infrastructure
so providers can thread response IDs through multi-turn history.
Implements 0xPlaygrounds#1147, 0xPlaygrounds#684
This was referenced Feb 13, 2026
Contributor
|
Ah crap I think I broke something while merging main back in. I'll fix this up then we can get it merged |
Contributor
|
Looks like the LLM hallucinated, Otherwise, lgtm so I'll be merging this |
Merged
This was referenced Feb 16, 2026
Fromsko
added a commit
to Fromsko/rig
that referenced
this pull request
Feb 25, 2026
…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.
github-merge-queue Bot
pushed a commit
that referenced
this pull request
Mar 4, 2026
…tible providers (#1441) * fix(openai): add reasoning_content to StreamingDelta for OpenAI-compatible 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 #1395), but the generic OpenAI streaming parser never utilized it. * fix(openai): clarify purpose of reasoning_content in StreamingDelta Added a comment to clarify that reasoning_content is not part of the official OpenAI API.
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.
Summary
ReasoningContentenum (Text,Encrypted,Redacted,Summary) replacing unstructured string-based reasoning representationReasoningstruct withid,content: Vec<ReasoningContent>and builder methods (new,with_id,new_with_signature, etc.)ReasoningDeltavariant andMessageIdvariant toRawStreamingChoicefor streaming infrastructuremessage_id: Option<String>toCompletionResponseandStreamingCompletionResponsefor provider-assigned IDs (needed by OpenAI Responses API)Reasoning/ReasoningDeltaeventsCloses #684
Breaking API Changes
AssistantContent::Reasoningnow wrapsReasoningstruct instead of raw fieldsReasoning::new("text"),Reasoning::new_with_signature("text", "sig"), or match onreasoning.contentStreamedAssistantContent::ReasoningcarriesReasoninginstead of old shapeReasoningstructStreamedAssistantContent::ReasoningDeltafields changed{ reasoning: String, id: Option<String> }CompletionResponse<T>has newmessage_id: Option<String>fieldmessage_id: Nonewhen constructingRawStreamingChoicehas newReasoning,ReasoningDelta,MessageIdvariantsTest plan
cargo fmtcleancargo clippy --all-targets --all-featurescleancargo test -p rig-core --lib— 271 tests passopenai_responses_input_itemtests updated and passing