mirror of
https://github.com/openai/codex.git
synced 2026-11-26 23:40:43 +00:00
Restore saved threads when the managed daemon restarts (#44314)
## Why Saved threads need to resume after a managed daemon restart so active goals can continue without waiting for a client to reconnect. ## What changed - Consume the recovery snapshot at startup and restore threads in the background through the shared cold-resume path. - Trigger idle lifecycle work without attaching a client subscription, and leave already-loaded threads untouched. - Continue recovery after individual thread failures and abort background recovery during shutdown. ## Testing Extend the daemon restart integration test to verify goal continuation before client reconnection, restored conversation history and tools, idle-thread restoration, and recovery snapshot consumption. Include malformed snapshots and an invalid thread ID. GitOrigin-RevId: 90e7b8f74ddc0ae327bacde1b2108b9749c65f2a
This commit is contained in:
@@ -46,6 +46,7 @@ use crate::request_processors::SearchRequestProcessor;
|
||||
use crate::request_processors::ThreadGoalRequestProcessor;
|
||||
use crate::request_processors::ThreadQueueRequestProcessor;
|
||||
use crate::request_processors::ThreadRequestProcessor;
|
||||
use crate::request_processors::ThreadResumeTarget;
|
||||
use crate::request_processors::TurnRequestProcessor;
|
||||
use crate::request_processors::WindowsSandboxRequestProcessor;
|
||||
use crate::request_processors::read_server_diagnostics;
|
||||
@@ -763,6 +764,34 @@ impl MessageProcessor {
|
||||
self.thread_processor.daemon_recovery_candidates().await
|
||||
}
|
||||
|
||||
pub(crate) async fn restore_daemon_threads(
|
||||
&self,
|
||||
candidates: std::collections::BTreeSet<String>,
|
||||
) {
|
||||
for thread_id in candidates {
|
||||
let Ok(_permit) = self.turn_admission.admit() else {
|
||||
break;
|
||||
};
|
||||
if let Err(err) = self
|
||||
.thread_processor
|
||||
.thread_resume(
|
||||
ThreadResumeTarget::DaemonRecovery,
|
||||
codex_app_server_protocol::ThreadResumeParams {
|
||||
thread_id,
|
||||
exclude_turns: true,
|
||||
..Default::default()
|
||||
},
|
||||
/*app_server_client_name*/ None,
|
||||
/*app_server_client_version*/ None,
|
||||
ClientMcpExtensions::default(),
|
||||
)
|
||||
.await
|
||||
{
|
||||
tracing::warn!(code = err.code, "failed to restore saved daemon thread");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub(crate) async fn send_initialize_notifications_to_connection(
|
||||
&self,
|
||||
connection_id: ConnectionId,
|
||||
@@ -1265,7 +1294,7 @@ impl MessageProcessor {
|
||||
ClientRequest::ThreadResume { params, .. } => {
|
||||
self.thread_processor
|
||||
.thread_resume(
|
||||
request_id.clone(),
|
||||
ThreadResumeTarget::Client(request_id.clone()),
|
||||
params,
|
||||
app_server_client_name.clone(),
|
||||
client_version.clone(),
|
||||
|
||||
Reference in New Issue
Block a user