Skip to content

Commit 73e215d

Browse files
authored
Always request encrypted cot (openai#3539)
Otherwise future requests will fail with 500
1 parent 8ed9594 commit 73e215d

2 files changed

Lines changed: 12 additions & 16 deletions

File tree

codex-rs/core/src/client_common.rs

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -84,8 +84,10 @@ pub enum ResponseEvent {
8484

8585
#[derive(Debug, Serialize)]
8686
pub(crate) struct Reasoning {
87-
pub(crate) effort: ReasoningEffortConfig,
88-
pub(crate) summary: ReasoningSummaryConfig,
87+
#[serde(skip_serializing_if = "Option::is_none")]
88+
pub(crate) effort: Option<ReasoningEffortConfig>,
89+
#[serde(skip_serializing_if = "Option::is_none")]
90+
pub(crate) summary: Option<ReasoningSummaryConfig>,
8991
}
9092

9193
/// Controls under the `text` field in the Responses API for GPT-5.
@@ -146,7 +148,10 @@ pub(crate) fn create_reasoning_param_for_request(
146148
return None;
147149
}
148150

149-
effort.map(|effort| Reasoning { effort, summary })
151+
Some(Reasoning {
152+
effort,
153+
summary: Some(summary),
154+
})
150155
}
151156

152157
pub(crate) fn create_text_param_for_request(

codex-rs/core/tests/suite/client.rs

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -450,7 +450,6 @@ async fn chatgpt_auth_sends_correct_request() {
450450
// Init session
451451
let codex_home = TempDir::new().unwrap();
452452
let mut config = load_default_config_for_test(&codex_home);
453-
let include_reasoning = config.model_reasoning_effort.is_some();
454453
config.model_provider = model_provider;
455454
let conversation_manager = ConversationManager::with_auth(create_dummy_codex_auth());
456455
let NewConversation {
@@ -492,18 +491,10 @@ async fn chatgpt_auth_sends_correct_request() {
492491
);
493492
assert_eq!(request_chatgpt_account_id.to_str().unwrap(), "account_id");
494493
assert!(request_body["stream"].as_bool().unwrap());
495-
if include_reasoning {
496-
assert_eq!(
497-
request_body["include"][0].as_str().unwrap(),
498-
"reasoning.encrypted_content"
499-
);
500-
} else {
501-
assert!(
502-
request_body["include"]
503-
.as_array()
504-
.is_none_or(|items| items.is_empty())
505-
);
506-
}
494+
assert_eq!(
495+
request_body["include"][0].as_str().unwrap(),
496+
"reasoning.encrypted_content"
497+
);
507498
}
508499

509500
#[tokio::test(flavor = "multi_thread", worker_threads = 2)]

0 commit comments

Comments
 (0)