Support for `reason_content` field in reasoning delta parsing for OSS model providers

Resolved 💬 0 comments Opened Sep 30, 2025 by tylike Closed Oct 9, 2025

What version of Codex is running?

0.43.0-alpha.5

Which model were you using?

etc

What platform is your computer?

win11 x64

What steps can reproduce the bug?

Note: This issue description was written with AI assistance as I'm not proficient in Rust programming and English.

Title: Support for reason_content field in reasoning delta parsing for OSS model providers

Description:

Problem

When using OSS model providers like Ollama, LMStudio, or llama.cpp, reasoning delta events are not correctly generated because these providers use the reason_content field instead of the standard reasoning field that OpenAI-compatible APIs use.

Root Cause

The reasoning delta parsing logic in chat_completions.rs (lines 474-498) only looks for the reasoning field and its subfields (text or content). However, OSS model providers often use different field names for reasoning content.

Current Implementation

if let Some(reasoning_val) = choice.get("delta").and_then(|d| d.get("reasoning")) {
    // Only checks for "reasoning" field
    // Supports subfields: "text" and "content"
}

Expected Behavior

The code should support multiple field names for reasoning content to ensure compatibility with different model providers:

  • OpenAI-compatible: reasoning.text or reasoning.content
  • OSS providers: reason_content

Proposed Solution

Add support for reason_content field in the reasoning delta parsing logic:

// Check for standard reasoning field
if let Some(reasoning_val) = choice.get("delta").and_then(|d| d.get("reasoning")) {
    // existing logic...
}
// Add support for OSS provider field names
else if let Some(reason_content_val) = choice.get("delta").and_then(|d| d.get("reason_content")) {
    // handle reason_content field
}

Alternative Solution

Create a provider-specific field mapping configuration that maps different field names to the standard reasoning event format.

Impact

This issue affects all users of OSS model providers who rely on reasoning/thinking capabilities. Without proper field mapping, reasoning events are silently dropped, leading to missing reasoning content in the application.

Environment

  • Affected Providers: Ollama, LMStudio, llama.cpp, and other OSS model providers
  • Code Location: codex-rs/core/src/chat_completions.rs
  • Current Field Support: reasoning.text, reasoning.content
  • Missing Field Support: reason_content

This enhancement would improve compatibility with the growing ecosystem of OSS model providers while maintaining backward compatibility with OpenAI-compatible APIs.

What is the expected behavior?

_No response_

What do you see instead?

_No response_

Additional information

_No response_

View original on GitHub ↗