fix(core): retry unsupported reasoning summaries

This commit is contained in:
Felipe Coury
2026-05-19 13:31:06 -03:00
parent b3ae3de405
commit 65742c56ee
3 changed files with 359 additions and 8 deletions
+80
View File
@@ -58,6 +58,7 @@ use core_test_support::responses::ev_completed_with_tokens;
use core_test_support::responses::ev_message_item_added;
use core_test_support::responses::ev_output_text_delta;
use core_test_support::responses::ev_response_created;
use core_test_support::responses::mount_response_sequence;
use core_test_support::responses::mount_sse_once;
use core_test_support::responses::mount_sse_once_match;
use core_test_support::responses::mount_sse_sequence;
@@ -1855,6 +1856,85 @@ async fn configured_reasoning_summary_is_sent() -> anyhow::Result<()> {
Ok(())
}
#[tokio::test(flavor = "multi_thread", worker_threads = 2)]
async fn unsupported_reasoning_summary_is_retried_without_summary() -> anyhow::Result<()> {
skip_if_no_network!(Ok(()));
let server = MockServer::start().await;
let responses = mount_response_sequence(
&server,
vec![
ResponseTemplate::new(400).set_body_json(json!({
"error": {
"type": "invalid_request_error",
"code": "unsupported_parameter",
"message": "Unsupported parameter: 'reasoning.summary' is not supported with the 'gpt-5.4' model.",
"param": "reasoning.summary"
}
})),
ResponseTemplate::new(200)
.insert_header("content-type", "text/event-stream")
.set_body_raw(
sse(vec![ev_response_created("resp1"), ev_completed("resp1")]),
"text/event-stream",
),
ResponseTemplate::new(200)
.insert_header("content-type", "text/event-stream")
.set_body_raw(
sse(vec![ev_response_created("resp2"), ev_completed("resp2")]),
"text/event-stream",
),
],
)
.await;
let TestCodex { codex, .. } = test_codex()
.with_config(|config| {
config.model_reasoning_summary = Some(ReasoningSummary::Concise);
})
.build(&server)
.await?;
for text in ["hello", "again"] {
codex
.submit(Op::UserInput {
environments: None,
items: vec![UserInput::Text {
text: text.into(),
text_elements: Vec::new(),
}],
final_output_json_schema: None,
responsesapi_client_metadata: None,
thread_settings: Default::default(),
})
.await
.unwrap();
wait_for_event(&codex, |ev| matches!(ev, EventMsg::TurnComplete(_))).await;
}
let requests = responses.requests();
assert_eq!(requests.len(), 3);
pretty_assertions::assert_eq!(
requests[0]
.body_json()
.get("reasoning")
.and_then(|reasoning| reasoning.get("summary"))
.and_then(|value| value.as_str()),
Some("concise")
);
for request in &requests[1..] {
pretty_assertions::assert_eq!(
request
.body_json()
.get("reasoning")
.and_then(|reasoning| reasoning.get("summary")),
None
);
}
Ok(())
}
#[tokio::test(flavor = "multi_thread", worker_threads = 2)]
async fn user_turn_explicit_reasoning_summary_overrides_model_catalog_default() -> anyhow::Result<()>
{
@@ -1318,6 +1318,83 @@ async fn responses_websocket_invalid_request_error_with_status_is_forwarded() {
server.shutdown().await;
}
#[tokio::test(flavor = "multi_thread", worker_threads = 2)]
async fn responses_websocket_retries_without_unsupported_reasoning_summary() {
skip_if_no_network!();
let unsupported_reasoning_summary_error = json!({
"type": "error",
"status": 400,
"error": {
"type": "invalid_request_error",
"code": "unsupported_parameter",
"message": "Unsupported parameter: 'reasoning.summary' is not supported with the 'gpt-5.3-codex-spark' model.",
"param": "reasoning.summary"
}
});
let server = start_websocket_server(vec![
vec![
vec![
ev_response_created("resp-prewarm"),
ev_completed("resp-prewarm"),
],
vec![unsupported_reasoning_summary_error],
],
vec![vec![ev_response_created("resp-1"), ev_completed("resp-1")]],
])
.await;
let mut builder = test_codex().with_config(|config| {
config.model_provider.request_max_retries = Some(0);
config.model_provider.stream_max_retries = Some(0);
config.model_reasoning_summary = Some(ReasoningSummary::Concise);
});
let test = builder
.build_with_websocket_server(&server)
.await
.expect("build websocket codex");
test.codex
.submit(Op::UserInput {
environments: None,
items: vec![UserInput::Text {
text: "hello".into(),
text_elements: Vec::new(),
}],
final_output_json_schema: None,
responsesapi_client_metadata: None,
thread_settings: Default::default(),
})
.await
.expect("submission should succeed");
wait_for_event(&test.codex, |msg| matches!(msg, EventMsg::TurnComplete(_))).await;
let connections = server.connections();
assert_eq!(connections.len(), 2);
let first_connection = connections.first().expect("missing first connection");
let second_connection = connections.get(1).expect("missing second connection");
assert_eq!(first_connection.len(), 2);
assert_eq!(second_connection.len(), 1);
assert_eq!(
first_connection
.get(1)
.expect("missing rejected request")
.body_json()["reasoning"]["summary"]
.as_str(),
Some("concise")
);
assert_eq!(
second_connection
.first()
.expect("missing retried request")
.body_json()["reasoning"]
.get("summary"),
None
);
server.shutdown().await;
}
#[tokio::test(flavor = "multi_thread", worker_threads = 2)]
async fn responses_websocket_connection_limit_error_reconnects_and_completes() {
skip_if_no_network!();