Skip to content

armgit / codex

Public Imported from GitHub
0

Lightweight coding agent that runs in your terminal

Rust

Always request encrypted cot (#3539)

pakrym-oai414b8be8b68e
diff --git a/codex-rs/core/src/client_common.rs b/codex-rs/core/src/client_common.rs
index 5aa0d8cf28..fd894a633f 100644
--- a/codex-rs/core/src/client_common.rs
+++ b/codex-rs/core/src/client_common.rs
@@ -84,8 +84,10 @@ pub enum ResponseEvent {
#[derive(Debug, Serialize)]
pub(crate) struct Reasoning {
- pub(crate) effort: ReasoningEffortConfig,
- pub(crate) summary: ReasoningSummaryConfig,
+ #[serde(skip_serializing_if = "Option::is_none")]
+ pub(crate) effort: Option<ReasoningEffortConfig>,
+ #[serde(skip_serializing_if = "Option::is_none")]
+ pub(crate) summary: Option<ReasoningSummaryConfig>,
}
/// Controls under the `text` field in the Responses API for GPT-5.
@@ -146,7 +148,10 @@ pub(crate) fn create_reasoning_param_for_request(
return None;
}
- effort.map(|effort| Reasoning { effort, summary })
+ Some(Reasoning {
+ effort,
+ summary: Some(summary),
+ })
}
pub(crate) fn create_text_param_for_request(
diff --git a/codex-rs/core/tests/suite/client.rs b/codex-rs/core/tests/suite/client.rs
index 232788073d..8360a8366b 100644
--- a/codex-rs/core/tests/suite/client.rs
+++ b/codex-rs/core/tests/suite/client.rs
@@ -450,7 +450,6 @@ async fn chatgpt_auth_sends_correct_request() {
// Init session
let codex_home = TempDir::new().unwrap();
let mut config = load_default_config_for_test(&codex_home);
- let include_reasoning = config.model_reasoning_effort.is_some();
config.model_provider = model_provider;
let conversation_manager = ConversationManager::with_auth(create_dummy_codex_auth());
let NewConversation {
@@ -492,18 +491,10 @@ async fn chatgpt_auth_sends_correct_request() {
);
assert_eq!(request_chatgpt_account_id.to_str().unwrap(), "account_id");
assert!(request_body["stream"].as_bool().unwrap());
- if include_reasoning {
- assert_eq!(
- request_body["include"][0].as_str().unwrap(),
- "reasoning.encrypted_content"
- );
- } else {
- assert!(
- request_body["include"]
- .as_array()
- .is_none_or(|items| items.is_empty())
- );
- }
+ assert_eq!(
+ request_body["include"][0].as_str().unwrap(),
+ "reasoning.encrypted_content"
+ );
}
#[tokio::test(flavor = "multi_thread", worker_threads = 2)]