diff --git a/src-tauri/src/proxy/providers/streaming_codex_chat.rs b/src-tauri/src/proxy/providers/streaming_codex_chat.rs index 1146d095d..318fe36a9 100644 --- a/src-tauri/src/proxy/providers/streaming_codex_chat.rs +++ b/src-tauri/src/proxy/providers/streaming_codex_chat.rs @@ -801,7 +801,8 @@ impl ChatToResponsesState { json!({ "input_tokens": 0, "output_tokens": 0, - "total_tokens": 0 + "total_tokens": 0, + "output_tokens_details": { "reasoning_tokens": 0 } }) }) }) diff --git a/src-tauri/src/proxy/providers/transform_codex_chat.rs b/src-tauri/src/proxy/providers/transform_codex_chat.rs index a3568dce5..8720753c6 100644 --- a/src-tauri/src/proxy/providers/transform_codex_chat.rs +++ b/src-tauri/src/proxy/providers/transform_codex_chat.rs @@ -1507,7 +1507,8 @@ pub(crate) fn chat_usage_to_responses_usage(usage: Option<&Value>) -> Value { return json!({ "input_tokens": 0, "output_tokens": 0, - "total_tokens": 0 + "total_tokens": 0, + "output_tokens_details": { "reasoning_tokens": 0 } }); }; @@ -1540,8 +1541,17 @@ pub(crate) fn chat_usage_to_responses_usage(usage: Option<&Value>) -> Value { result["input_tokens_details"] = json!({ "cached_tokens": cached }); } - if let Some(details) = usage.get("completion_tokens_details") { - result["output_tokens_details"] = details.clone(); + if let Some(details) = usage + .get("completion_tokens_details") + .filter(|v| v.is_object()) + { + let mut details = details.clone(); + if details.get("reasoning_tokens").is_none() { + details["reasoning_tokens"] = json!(0); + } + result["output_tokens_details"] = details; + } else { + result["output_tokens_details"] = json!({ "reasoning_tokens": 0 }); } if let Some(cache_read) = usage.get("cache_read_input_tokens") {