From db7516f41bec71d26ddefc6af29e68cac9ba580c Mon Sep 17 00:00:00 2001 From: jif Date: Mon, 26 Oct 2026 12:32:19 +0000 Subject: [PATCH] Reduce the default thread unload delay to one minute (#57242) ## What changed Change the default `thread_unload_delay_secs` from 1800 to 60 seconds. App-server threads become eligible for unloading after one minute with no subscribers and no activity. Update the configuration documentation, schema, and thread manager sample to match. ## Testing Update the configuration test to cover the 60-second default, zero for immediate unloading, and an explicit 1800-second override. GitOrigin-RevId: 0da8454eb25a6ef4b7e3665601982d2e0c183f7c --- codex-rs/config/src/config_toml.rs | 2 +- codex-rs/core/config.schema.json | 2 +- codex-rs/core/src/config/config_tests.rs | 4 ++-- codex-rs/core/src/config/mod.rs | 2 +- codex-rs/thread-manager-sample/src/main.rs | 2 +- 5 files changed, 6 insertions(+), 6 deletions(-) diff --git a/codex-rs/config/src/config_toml.rs b/codex-rs/config/src/config_toml.rs index 98c02e6e5c..dedf0aea6d 100644 --- a/codex-rs/config/src/config_toml.rs +++ b/codex-rs/config/src/config_toml.rs @@ -349,7 +349,7 @@ pub struct ConfigToml { pub background_terminal_max_timeout: Option, /// Seconds a thread must have no subscribers and no activity before app-server - /// unloads it. Defaults to 1800 (30 minutes); zero unloads immediately. + /// unloads it. Defaults to 60 (1 minute); zero unloads immediately. /// Resolved when each thread is loaded; request config overrides apply per thread. pub thread_unload_delay_secs: Option, diff --git a/codex-rs/core/config.schema.json b/codex-rs/core/config.schema.json index 3dd9740369..d15af0114b 100644 --- a/codex-rs/core/config.schema.json +++ b/codex-rs/core/config.schema.json @@ -8495,7 +8495,7 @@ "type": "boolean" }, "thread_unload_delay_secs": { - "description": "Seconds a thread must have no subscribers and no activity before app-server unloads it. Defaults to 1800 (30 minutes); zero unloads immediately. Resolved when each thread is loaded; request config overrides apply per thread.", + "description": "Seconds a thread must have no subscribers and no activity before app-server unloads it. Defaults to 60 (1 minute); zero unloads immediately. Resolved when each thread is loaded; request config overrides apply per thread.", "format": "uint64", "minimum": 0.0, "type": "integer" diff --git a/codex-rs/core/src/config/config_tests.rs b/codex-rs/core/src/config/config_tests.rs index 97217c5ce6..52d68896c2 100644 --- a/codex-rs/core/src/config/config_tests.rs +++ b/codex-rs/core/src/config/config_tests.rs @@ -258,9 +258,9 @@ async fn load_config_applies_optional_mcp_startup_grace() -> std::io::Result<()> async fn load_config_resolves_thread_unload_delay() -> anyhow::Result<()> { let codex_home = tempdir()?; for (toml, seconds) in [ - ("", 1800), + ("", 60), ("thread_unload_delay_secs = 0", 0), - ("thread_unload_delay_secs = 60", 60), + ("thread_unload_delay_secs = 1800", 1800), ] { let config = Config::load_from_base_config_with_overrides( toml::from_str(toml)?, diff --git a/codex-rs/core/src/config/mod.rs b/codex-rs/core/src/config/mod.rs index feb68b2523..c2f12e60e5 100644 --- a/codex-rs/core/src/config/mod.rs +++ b/codex-rs/core/src/config/mod.rs @@ -4122,7 +4122,7 @@ impl Config { .unwrap_or(DEFAULT_MAX_BACKGROUND_TERMINAL_TIMEOUT_MS) .max(MIN_EMPTY_YIELD_TIME_MS); let thread_unload_delay = - Duration::from_secs(cfg.thread_unload_delay_secs.unwrap_or(/*default*/ 1800)); + Duration::from_secs(cfg.thread_unload_delay_secs.unwrap_or(/*default*/ 60)); if std::time::Instant::now() .checked_add(thread_unload_delay) .is_none() diff --git a/codex-rs/thread-manager-sample/src/main.rs b/codex-rs/thread-manager-sample/src/main.rs index 47792f00ac..56deb71fbc 100644 --- a/codex-rs/thread-manager-sample/src/main.rs +++ b/codex-rs/thread-manager-sample/src/main.rs @@ -383,7 +383,7 @@ async fn new_config( tool_registry: Default::default(), code_mode: Default::default(), background_terminal_max_timeout: 300_000, - thread_unload_delay: std::time::Duration::from_secs(/*secs*/ 1800), + thread_unload_delay: std::time::Duration::from_secs(/*secs*/ 60), ghost_snapshot: GhostSnapshotConfig::default(), multi_agent_v2: MultiAgentV2Config::default(), max_goal_token_budget: None,