Support persistent reasoning effort (#40799)

## What changed

- Add `persistent` to the reasoning-effort protocol and TypeScript SDK types.
- Show model-advertised persistent reasoning in the TUI as “Persistent”.
- Preserve `persistent` in local configuration while sending the Responses API's `disabled` wire value.

## Testing

- Cover parsing and serialization, request translation, remote model requests, the TUI reasoning selector, and TypeScript CLI argument forwarding.

GitOrigin-RevId: 22fc2fba1975db345c12d555ec12803d8dc0abca
This commit is contained in:
rka-oai authored and copyberry committed 2026-08-26 05:00:23 +00:00
1 parent 37f4bb94c9
commit 3e4707b34b
9 files changed
+72 -39

No files matched your search

+2
View File
@@ -180,6 +180,8 @@ pub(crate) struct CompactConversationRequestSettings {
fn reasoning_effort_for_request(effort: ReasoningEffortConfig) -> ReasoningEffortConfig { fn reasoning_effort_for_request(effort: ReasoningEffortConfig) -> ReasoningEffortConfig {
match effort { match effort {
ReasoningEffortConfig::Ultra => ReasoningEffortConfig::Max, ReasoningEffortConfig::Ultra => ReasoningEffortConfig::Max,
// Keep "persistent" in local settings; the Responses API calls it "disabled".
ReasoningEffortConfig::Persistent => ReasoningEffortConfig::Custom("disabled".to_string()),
effort => effort, effort => effort,
} }
} }
+7 -2
View File
@@ -299,13 +299,18 @@ fn test_session_telemetry() -> SessionTelemetry {
} }
#[test] #[test]
fn ultra_reasoning_uses_max_for_requests() { fn reasoning_effort_for_requests_maps_ultra_and_persistent() {
assert_eq!( assert_eq!(
( (
super::reasoning_effort_for_request(ReasoningEffort::Ultra), super::reasoning_effort_for_request(ReasoningEffort::Ultra),
super::reasoning_effort_for_request(ReasoningEffort::High), super::reasoning_effort_for_request(ReasoningEffort::High),
super::reasoning_effort_for_request(ReasoningEffort::Persistent),
), ),
(ReasoningEffort::Max, ReasoningEffort::High,) (
ReasoningEffort::Max,
ReasoningEffort::High,
ReasoningEffort::Custom("disabled".to_string()),
)
); );
} }
+12 -7
View File
@@ -48,6 +48,7 @@ use core_test_support::wait_for_event_match;
use pretty_assertions::assert_eq; use pretty_assertions::assert_eq;
use serde_json::json; use serde_json::json;
use tempfile::TempDir; use tempfile::TempDir;
use test_case::test_case;
use tokio::time::Duration; use tokio::time::Duration;
use tokio::time::Instant; use tokio::time::Instant;
use tokio::time::sleep; use tokio::time::sleep;
@@ -365,8 +366,13 @@ async fn remote_models_use_context_window_when_config_override_is_absent() -> Re
Ok(()) Ok(())
} }
#[test_case(ReasoningEffort::Custom("future".to_string()), "future"; "custom")]
#[test_case(ReasoningEffort::Persistent, "disabled"; "persistent")]
#[tokio::test(flavor = "multi_thread", worker_threads = 2)] #[tokio::test(flavor = "multi_thread", worker_threads = 2)]
async fn remote_models_long_model_slug_is_sent_with_custom_reasoning() -> Result<()> { async fn remote_models_long_model_slug_is_sent_with_supported_reasoning(
effort: ReasoningEffort,
expected_wire_effort: &str,
) -> Result<()> {
skip_if_no_network!(Ok(())); skip_if_no_network!(Ok(()));
skip_if_sandbox!(Ok(())); skip_if_sandbox!(Ok(()));
@@ -379,16 +385,15 @@ async fn remote_models_long_model_slug_is_sent_with_custom_reasoning() -> Result
/*priority*/ 1_000, /*priority*/ 1_000,
TruncationPolicyConfig::bytes(/*limit*/ 10_000), TruncationPolicyConfig::bytes(/*limit*/ 10_000),
); );
let custom_reasoning_effort = ReasoningEffort::Custom("future".to_string()); remote_model.default_reasoning_level = Some(effort.clone());
remote_model.default_reasoning_level = Some(custom_reasoning_effort.clone());
remote_model.supported_reasoning_levels = vec![ remote_model.supported_reasoning_levels = vec![
ReasoningEffortPreset { ReasoningEffortPreset {
effort: ReasoningEffort::Medium, effort: ReasoningEffort::Medium,
description: ReasoningEffort::Medium.to_string(), description: ReasoningEffort::Medium.to_string(),
}, },
ReasoningEffortPreset { ReasoningEffortPreset {
effort: custom_reasoning_effort.clone(), effort: effort.clone(),
description: custom_reasoning_effort.to_string(), description: effort.to_string(),
}, },
]; ];
remote_model.default_reasoning_summary = ReasoningSummary::Detailed; remote_model.default_reasoning_summary = ReasoningSummary::Detailed;
@@ -411,7 +416,7 @@ async fn remote_models_long_model_slug_is_sent_with_custom_reasoning() -> Result
.with_config(|config| { .with_config(|config| {
config.model = Some(requested_model.to_string()); config.model = Some(requested_model.to_string());
}) })
.build(&server) .build_with_auto_env(&server)
.await?; .await?;
codex codex
@@ -434,7 +439,7 @@ async fn remote_models_long_model_slug_is_sent_with_custom_reasoning() -> Result
.and_then(|reasoning| reasoning.get("summary")) .and_then(|reasoning| reasoning.get("summary"))
.and_then(|value| value.as_str()); .and_then(|value| value.as_str());
assert_eq!(body["model"].as_str(), Some(requested_model)); assert_eq!(body["model"].as_str(), Some(requested_model));
assert_eq!(reasoning_effort, Some("future")); assert_eq!(reasoning_effort, Some(expected_wire_effort));
assert_eq!(reasoning_summary, Some("detailed")); assert_eq!(reasoning_summary, Some("detailed"));
Ok(()) Ok(())
+9
View File
@@ -57,6 +57,7 @@ pub enum ReasoningEffort {
XHigh, XHigh,
Max, Max,
Ultra, Ultra,
Persistent,
/// A model-defined effort value that this client does not know yet. /// A model-defined effort value that this client does not know yet.
Custom(String), Custom(String),
} }
@@ -73,6 +74,7 @@ impl ReasoningEffort {
Self::XHigh => "xhigh", Self::XHigh => "xhigh",
Self::Max => "max", Self::Max => "max",
Self::Ultra => "ultra", Self::Ultra => "ultra",
Self::Persistent => "persistent",
Self::Custom(effort) => effort, Self::Custom(effort) => effort,
} }
} }
@@ -139,6 +141,7 @@ impl FromStr for ReasoningEffort {
"xhigh" => Ok(Self::XHigh), "xhigh" => Ok(Self::XHigh),
"max" => Ok(Self::Max), "max" => Ok(Self::Max),
"ultra" => Ok(Self::Ultra), "ultra" => Ok(Self::Ultra),
"persistent" => Ok(Self::Persistent),
"" => Err("reasoning_effort must not be empty".to_string()), "" => Err("reasoning_effort must not be empty".to_string()),
effort => Ok(Self::Custom(effort.to_string())), effort => Ok(Self::Custom(effort.to_string())),
} }
@@ -1132,28 +1135,34 @@ mod tests {
let serialized = to_string(&custom).expect("custom reasoning effort should serialize"); let serialized = to_string(&custom).expect("custom reasoning effort should serialize");
let serialized_max = to_string(&ReasoningEffort::Max).expect("Max should serialize"); let serialized_max = to_string(&ReasoningEffort::Max).expect("Max should serialize");
let serialized_ultra = to_string(&ReasoningEffort::Ultra).expect("Ultra should serialize"); let serialized_ultra = to_string(&ReasoningEffort::Ultra).expect("Ultra should serialize");
let serialized_persistent =
to_string(&ReasoningEffort::Persistent).expect("Persistent should serialize");
assert_eq!( assert_eq!(
( (
"high".parse(), "high".parse(),
"max".parse(), "max".parse(),
"ultra".parse(), "ultra".parse(),
"persistent".parse(),
"future".parse(), "future".parse(),
deserialized, deserialized,
serialized, serialized,
serialized_max, serialized_max,
serialized_ultra, serialized_ultra,
serialized_persistent,
custom.to_string(), custom.to_string(),
), ),
( (
Ok(ReasoningEffort::High), Ok(ReasoningEffort::High),
Ok(ReasoningEffort::Max), Ok(ReasoningEffort::Max),
Ok(ReasoningEffort::Ultra), Ok(ReasoningEffort::Ultra),
Ok(ReasoningEffort::Persistent),
Ok(custom.clone()), Ok(custom.clone()),
custom, custom,
r#""future""#.to_string(), r#""future""#.to_string(),
r#""max""#.to_string(), r#""max""#.to_string(),
r#""ultra""#.to_string(), r#""ultra""#.to_string(),
r#""persistent""#.to_string(),
"future".to_string(), "future".to_string(),
) )
); );
@@ -646,6 +646,7 @@ impl ChatWidget {
ReasoningEffortConfig::XHigh => "Extra high".to_string(), ReasoningEffortConfig::XHigh => "Extra high".to_string(),
ReasoningEffortConfig::Max => "Max".to_string(), ReasoningEffortConfig::Max => "Max".to_string(),
ReasoningEffortConfig::Ultra => "Ultra".to_string(), ReasoningEffortConfig::Ultra => "Ultra".to_string(),
ReasoningEffortConfig::Persistent => "Persistent".to_string(),
ReasoningEffortConfig::Custom(value) => value.clone(), ReasoningEffortConfig::Custom(value) => value.clone(),
} }
} }
@@ -8,6 +8,7 @@ expression: popup
2. Medium (default) Balances speed and reasoning depth for everyday tasks 2. Medium (default) Balances speed and reasoning depth for everyday tasks
› 3. High (current) Greater reasoning depth for complex problems › 3. High (current) Greater reasoning depth for complex problems
4. Extra high Extra high reasoning depth for complex problems 4. Extra high Extra high reasoning depth for complex problems
5. More reasoning… Max and Ultra consume usage limits faster 5. Persistent Continue working until put to sleep
6. More reasoning… Max and Ultra consume usage limits faster
Press enter to confirm or esc to go back Press enter to confirm or esc to go back
@@ -3352,6 +3352,12 @@ async fn model_reasoning_selection_popup_snapshot() {
effort: ReasoningEffortConfig::Ultra, effort: ReasoningEffortConfig::Ultra,
description: "Ultra reasoning".to_string(), description: "Ultra reasoning".to_string(),
}); });
preset
.supported_reasoning_efforts
.push(ReasoningEffortPreset {
effort: ReasoningEffortConfig::Persistent,
description: "Continue working until put to sleep".to_string(),
});
chat.open_reasoning_popup(preset); chat.open_reasoning_popup(preset);
let popup = render_bottom_popup(&chat, /*width*/ 80); let popup = render_bottom_popup(&chat, /*width*/ 80);
+2 -1
View File
@@ -9,7 +9,8 @@ export type ModelReasoningEffort =
| "high" | "high"
| "xhigh" | "xhigh"
| "max" | "max"
| "ultra"; | "ultra"
| "persistent";
export type WebSearchMode = "disabled" | "cached" | "live"; export type WebSearchMode = "disabled" | "cached" | "live";
+31 -28
View File
@@ -229,36 +229,39 @@ describe("Codex", () => {
} }
}); });
it("passes modelReasoningEffort to exec", async () => { it.each(["high", "persistent"] as const)(
const { url, close } = await startResponsesTestProxy({ "passes %s modelReasoningEffort to exec",
statusCode: 200, async (effort) => {
responseBodies: [ const { url, close } = await startResponsesTestProxy({
sse( statusCode: 200,
responseStarted("response_1"), responseBodies: [
assistantMessage("Reasoning effort applied", "item_1"), sse(
responseCompleted("response_1"), responseStarted("response_1"),
), assistantMessage("Reasoning effort applied", "item_1"),
], responseCompleted("response_1"),
}); ),
],
const { args: spawnArgs, restore } = codexExecSpy();
const { client, cleanup } = createMockClient(url);
try {
const thread = client.startThread({
modelReasoningEffort: "high",
}); });
await thread.run("apply reasoning effort");
const commandArgs = spawnArgs[0]; const { args: spawnArgs, restore } = codexExecSpy();
expect(commandArgs).toBeDefined(); const { client, cleanup } = createMockClient(url);
expectPair(commandArgs, ["--config", 'model_reasoning_effort="high"']);
} finally { try {
cleanup(); const thread = client.startThread({
restore(); modelReasoningEffort: effort,
await close(); });
} await thread.run("apply reasoning effort");
});
const commandArgs = spawnArgs[0];
expect(commandArgs).toBeDefined();
expectPair(commandArgs, ["--config", `model_reasoning_effort="${effort}"`]);
} finally {
cleanup();
restore();
await close();
}
},
);
it("passes networkAccessEnabled to exec", async () => { it("passes networkAccessEnabled to exec", async () => {
const { url, close } = await startResponsesTestProxy({ const { url, close } = await startResponsesTestProxy({