mirror of
https://github.com/openai/codex.git
synced 2026-11-23 23:10:47 +00:00
Use automatic reasoning summaries by default in the TUI (#62904)
## Why The TUI left the reasoning summary unset on turn submission, so OpenAI requests could use `concise` even when the user had chosen no summary setting. Embedded WebSocket prewarming and the first turn need to use the same summary setting to reuse the warmup response. ## What changed - Send the configured `model_reasoning_summary` with TUI turns, defaulting to `auto` for OpenAI providers. Use the same fallback when prewarming through the in-process app server. - Read reasoning summary settings and custom provider definitions from the app server's effective config while honoring explicit launch settings. When resuming a remote session, use its working directory for the config lookup unless a remote directory override is set. ## Testing Cover summary defaults and explicit settings in Responses requests, and verify that the first embedded WebSocket turn uses `auto` and reuses the warmup response. GitOrigin-RevId: 1a2edfa44abdd031691a0d421eba077b0796ebe1
This commit is contained in:
@@ -3,46 +3,40 @@
|
||||
use super::*;
|
||||
use crate::legacy_core::config::ConfigBuilder;
|
||||
use codex_app_server_client::AppServerEvent;
|
||||
use codex_app_server_protocol::JSONRPCMessage;
|
||||
use codex_app_server_protocol::ServerNotification;
|
||||
use codex_protocol::config_types::ReasoningSummary;
|
||||
use core_test_support::responses;
|
||||
use futures::SinkExt;
|
||||
use futures::StreamExt;
|
||||
use pretty_assertions::assert_eq;
|
||||
use serde_json::json;
|
||||
use tokio_tungstenite::tungstenite::Message;
|
||||
|
||||
#[tokio::test]
|
||||
async fn reasoning_defaults_reach_responses() -> Result<()> {
|
||||
let concurrent = json!({"reasoning_summary_delivery": "sequential_cutoff"});
|
||||
for (settings, summary, stream_options, mode) in [
|
||||
(
|
||||
"",
|
||||
json!("concise"),
|
||||
json!({"reasoning_summary_delivery": "sequential_cutoff"}),
|
||||
json!("auto"),
|
||||
concurrent.clone(),
|
||||
ThreadParamsMode::Embedded,
|
||||
),
|
||||
(
|
||||
"[features]\nconcurrent_reasoning_summaries = false",
|
||||
json!("concise"),
|
||||
json!("auto"),
|
||||
json!(null),
|
||||
ThreadParamsMode::Embedded,
|
||||
),
|
||||
(
|
||||
"[features]\nconcurrent_reasoning_summaries = true",
|
||||
json!("concise"),
|
||||
json!({"reasoning_summary_delivery": "sequential_cutoff"}),
|
||||
ThreadParamsMode::Embedded,
|
||||
),
|
||||
(
|
||||
"model_reasoning_summary = 'detailed'",
|
||||
json!("detailed"),
|
||||
json!({"reasoning_summary_delivery": "sequential_cutoff"}),
|
||||
concurrent.clone(),
|
||||
ThreadParamsMode::Embedded,
|
||||
),
|
||||
(
|
||||
"model_reasoning_summary = 'detailed'\n[features]\nconcurrent_reasoning_summaries = true",
|
||||
json!("detailed"),
|
||||
json!({"reasoning_summary_delivery": "sequential_cutoff"}),
|
||||
ThreadParamsMode::Embedded,
|
||||
),
|
||||
(
|
||||
"model_reasoning_summary = 'none'\n[features]\nconcurrent_reasoning_summaries = true",
|
||||
"model_reasoning_summary = 'none'",
|
||||
json!(null),
|
||||
json!(null),
|
||||
ThreadParamsMode::Embedded,
|
||||
@@ -50,7 +44,7 @@ async fn reasoning_defaults_reach_responses() -> Result<()> {
|
||||
(
|
||||
"model_reasoning_summary = 'detailed'\nmodel_verbosity = 'high'\nweb_search = 'live'",
|
||||
json!("detailed"),
|
||||
json!({"reasoning_summary_delivery": "sequential_cutoff"}),
|
||||
concurrent,
|
||||
ThreadParamsMode::Remote,
|
||||
),
|
||||
] {
|
||||
@@ -148,7 +142,11 @@ stream_max_retries = 0
|
||||
&config.workspace_roots,
|
||||
started.session.model.clone(),
|
||||
/*effort*/ None,
|
||||
/*summary*/ None,
|
||||
Some(
|
||||
server_config
|
||||
.model_reasoning_summary
|
||||
.unwrap_or(ReasoningSummary::Auto),
|
||||
),
|
||||
/*service_tier*/ None,
|
||||
/*collaboration_mode*/ None,
|
||||
/*output_schema*/ None,
|
||||
@@ -209,3 +207,133 @@ stream_max_retries = 0
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn reasoning_summary_default_preserves_websocket_prewarm() -> Result<()> {
|
||||
let websocket = responses::start_websocket_server(vec![vec![
|
||||
vec![
|
||||
responses::ev_response_created("warmup"),
|
||||
responses::ev_completed("warmup"),
|
||||
],
|
||||
vec![
|
||||
responses::ev_response_created("first"),
|
||||
responses::ev_completed("first"),
|
||||
],
|
||||
]])
|
||||
.await;
|
||||
let home = tempfile::tempdir()?;
|
||||
let base_url = websocket.uri();
|
||||
std::fs::write(
|
||||
home.path().join("config.toml"),
|
||||
format!(
|
||||
r#"
|
||||
model = "gpt-5.5"
|
||||
model_provider = "reasoning-test"
|
||||
[model_providers.reasoning-test]
|
||||
name = "OpenAI"
|
||||
base_url = "{base_url}/v1"
|
||||
wire_api = "responses"
|
||||
supports_websockets = true
|
||||
"#
|
||||
),
|
||||
)?;
|
||||
let config = ConfigBuilder::default()
|
||||
.codex_home(home.path().to_path_buf())
|
||||
.build()
|
||||
.await?;
|
||||
let template = thread_start_params_from_config(
|
||||
&config,
|
||||
ThreadParamsMode::Embedded,
|
||||
/*remote_cwd_override*/ None,
|
||||
/*session_start_source*/ None,
|
||||
);
|
||||
assert_eq!(
|
||||
template
|
||||
.config
|
||||
.as_ref()
|
||||
.and_then(|config| config.get("model_reasoning_summary")),
|
||||
None,
|
||||
);
|
||||
let listener = tokio::net::TcpListener::bind("127.0.0.1:0").await?;
|
||||
let endpoint = crate::resolve_remote_addr(&format!("ws://{}", listener.local_addr()?))?;
|
||||
let daemon = tokio::spawn(async move {
|
||||
let (stream, _) = listener.accept().await?;
|
||||
let mut socket = tokio_tungstenite::accept_async(stream).await?;
|
||||
while let Some(Ok(Message::Text(text))) = socket.next().await {
|
||||
let JSONRPCMessage::Request(request) = serde_json::from_str(&text)? else {
|
||||
continue;
|
||||
};
|
||||
let mut reply = match request.method.as_str() {
|
||||
"initialize" => json!({"result": {"userAgent": "daemon-test/1.0"}}),
|
||||
"thread/start" => json!({"error": {"code": -32603, "message": "recorded"}}),
|
||||
method => panic!("unexpected request: {method}"),
|
||||
};
|
||||
reply["id"] = json!(request.id);
|
||||
socket.send(Message::Text(reply.to_string().into())).await?;
|
||||
if request.method == "thread/start" {
|
||||
return Ok::<_, color_eyre::Report>(request.params);
|
||||
}
|
||||
}
|
||||
color_eyre::eyre::bail!("missing thread/start");
|
||||
});
|
||||
let mut daemon_session = AppServerSession::new(
|
||||
crate::backend_id::BackendId::new(),
|
||||
crate::connect_remote_app_server(endpoint).await?,
|
||||
ThreadParamsMode::Embedded,
|
||||
);
|
||||
assert!(daemon_session.start_thread(&config).await.is_err());
|
||||
let daemon_params = daemon.await??.expect("thread/start params");
|
||||
assert_eq!(
|
||||
daemon_params["config"]["model_reasoning_summary"],
|
||||
json!(null)
|
||||
);
|
||||
daemon_session.shutdown().await?;
|
||||
let mut app_server = crate::start_embedded_app_server_for_picker(&config).await?;
|
||||
let started = app_server.start_thread(&config).await?;
|
||||
let warmup = tokio::time::timeout(
|
||||
std::time::Duration::from_secs(/*secs*/ 30),
|
||||
websocket.wait_for_request(/*connection_index*/ 0, /*request_index*/ 0),
|
||||
)
|
||||
.await?;
|
||||
assert_eq!(warmup.body_json()["reasoning"]["summary"], "auto");
|
||||
app_server
|
||||
.turn_start(
|
||||
started.session.thread_id,
|
||||
"user",
|
||||
"tui-user-message".to_string(),
|
||||
vec![UserInput::Text {
|
||||
text: "hello".to_string(),
|
||||
text_elements: Vec::new(),
|
||||
}],
|
||||
config.cwd.to_path_buf(),
|
||||
/*approval_policy*/ None,
|
||||
/*approvals_reviewer*/ None,
|
||||
TurnPermissionsOverride::Preserve,
|
||||
&config.workspace_roots,
|
||||
started.session.model,
|
||||
/*effort*/ None,
|
||||
reasoning_summary_from_config(&config),
|
||||
/*service_tier*/ None,
|
||||
/*collaboration_mode*/ None,
|
||||
/*output_schema*/ None,
|
||||
/*cyber_access_program*/ None,
|
||||
/*cloud_selection*/ None,
|
||||
)
|
||||
.await?;
|
||||
let first = tokio::time::timeout(
|
||||
std::time::Duration::from_secs(/*secs*/ 30),
|
||||
websocket.wait_for_request(/*connection_index*/ 0, /*request_index*/ 1),
|
||||
)
|
||||
.await?;
|
||||
let first = first.body_json();
|
||||
assert_eq!(
|
||||
(
|
||||
first["reasoning"]["summary"].clone(),
|
||||
first["previous_response_id"].clone()
|
||||
),
|
||||
(json!("auto"), json!("warmup")),
|
||||
);
|
||||
app_server.shutdown().await?;
|
||||
websocket.shutdown().await;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user