Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 30 additions & 20 deletions code-rs/core/src/client.rs
Original file line numberDiff line numberDiff line change
Expand Up@@ -224,6 +224,18 @@ fn should_store_responses(
!request_family.use_responses_lite && prompt.store
}

fn response_include_for_request(
store: bool,
use_responses_lite: bool,
has_reasoning: bool,
) -> Vec<String> {
if (!store || use_responses_lite) && has_reasoning {
vec!["reasoning.encrypted_content".to_string()]
} else {
Vec::new()
}
}

fn is_server_overloaded_error(error: &Error) -> bool {
matches!(
error.code.as_deref(),
Expand DownExpand Up@@ -839,16 +851,11 @@ impl ModelClient {
attempt += 1;

let reasoning = self.current_reasoning_param(&request_family, effective_effort);
let mut include: Vec<String> = if (!store || request_family.use_responses_lite)
&& reasoning.is_some()
{
vec!["reasoning.encrypted_content".to_string()]
} else {
Vec::new()
};
if request_family.use_responses_lite {
include.push("codex-lite".to_string());
}
let include = response_include_for_request(
store,
request_family.use_responses_lite,
reasoning.is_some(),
);

let service_tier = self
.config
Expand DownExpand Up@@ -1346,16 +1353,11 @@ impl ModelClient {
let reasoning = self.current_reasoning_param(&request_family, effective_effort);
// Request encrypted COT if we are not storing responses,
// otherwise reasoning items will be referenced by ID
let mut include: Vec<String> = if (!store || request_family.use_responses_lite)
&& reasoning.is_some()
{
vec!["reasoning.encrypted_content".to_string()]
} else {
Vec::new()
};
if request_family.use_responses_lite {
include.push("codex-lite".to_string());
}
let include = response_include_for_request(
store,
request_family.use_responses_lite,
reasoning.is_some(),
);

let text = text_template.clone();

Expand DownExpand Up@@ -3315,6 +3317,14 @@ mod tests {
assert!(!should_store_responses(&prompt, &provider, &family));
}

#[test]
fn responses_lite_include_uses_public_response_fields_only() {
let include = response_include_for_request(false, true, true);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Exercise the serialized Responses Lite request in an integration test

For Responses Lite requests with reasoning, this unit test only invokes response_include_for_request directly, so it does not verify that either outbound request path serializes the corrected include array; it could remain green while the HTTP or WebSocket payload still triggers the user-facing 400 response. Add a mock-server integration test that drives the request and asserts the captured JSON contains only reasoning.encrypted_content.

Useful? React with 👍 / 👎.


assert_eq!(include, vec!["reasoning.encrypted_content".to_string()]);
assert!(!include.iter().any(|field| field == "codex-lite"));
}

#[test]
fn responses_storage_is_not_forced_for_azure_provider() {
let prompt = Prompt::default();
Expand Down