mirror of
https://github.com/openai/codex.git
synced 2026-11-28 23:34:06 +00:00
Record interrupted turns in managed daemon recovery snapshots (#45807)
## Why Managed daemon recovery snapshots previously saved only loaded thread IDs, without identifying active turns or preserving their turn-specific options. ## What changed - Capture regular, uncanceled turns after their input is recorded, saving the turn ID, output schema, service tier, and cyber access program alongside persisted thread IDs. - Store interruption metadata atomically in the existing candidate array format so older servers can still read thread candidates. - Begin snapshotting once admitted operations drain, while turns may still be running. Run snapshot collection and thread listener attachment independently of the event loop to keep forced shutdown responsive. ## Testing Add coverage for running, completed, canceled, and compacting turns; recovery readiness for automatic and user turns; admitted resumes during shutdown; forced shutdown with a blocked rollout writer and child listener attachment; and legacy candidate-array compatibility. GitOrigin-RevId: ed46342c3a5c71b09c48fa9acece2f15ae748e2f
This commit is contained in:
1 parent
7f83d4922d
commit
4d2807023a
12 files changed
+407
-38
No files matched your search
@@ -2,6 +2,8 @@
|
||||
//! Only threads successfully persisted through the existing thread store become candidates.
|
||||
|
||||
use super::ThreadRequestProcessor;
|
||||
use codex_app_server_transport::daemon_recovery::InterruptedTurn;
|
||||
use codex_app_server_transport::daemon_recovery::RecoverySnapshot;
|
||||
use codex_thread_store::PersistContext;
|
||||
use tracing::warn;
|
||||
|
||||
@@ -10,8 +12,8 @@ impl ThreadRequestProcessor {
|
||||
clippy::await_holding_invalid_type,
|
||||
reason = "snapshot selection must be serialized against pending unloads"
|
||||
)]
|
||||
pub(crate) async fn daemon_recovery_candidates(&self) -> Vec<String> {
|
||||
let mut ids = Vec::new();
|
||||
pub(crate) async fn daemon_recovery_snapshot(&self) -> RecoverySnapshot {
|
||||
let mut snapshot = RecoverySnapshot::default();
|
||||
for thread_id in self.thread_manager.list_thread_ids().await {
|
||||
let pending_unloads = self.pending_thread_unloads.lock().await;
|
||||
if pending_unloads.contains(&thread_id) {
|
||||
@@ -25,6 +27,7 @@ impl ThreadRequestProcessor {
|
||||
&& config.parent_thread_id.is_none()
|
||||
&& !config.session_source.is_non_root_agent()
|
||||
{
|
||||
let interrupted = thread.interrupted_turn().await;
|
||||
if let Err(err) = self
|
||||
.thread_store
|
||||
.persist_thread(thread_id, PersistContext::Standard)
|
||||
@@ -33,9 +36,20 @@ impl ThreadRequestProcessor {
|
||||
warn!(%thread_id, %err, "skipping daemon restore for thread that could not be persisted");
|
||||
continue;
|
||||
}
|
||||
ids.push(thread_id.to_string());
|
||||
snapshot.loaded.insert(thread_id.to_string());
|
||||
if let Some((turn_id, options)) = interrupted {
|
||||
snapshot.interrupted.insert(
|
||||
thread_id.to_string(),
|
||||
InterruptedTurn {
|
||||
turn_id,
|
||||
output_schema: options.final_output_json_schema,
|
||||
service_tier: options.service_tier,
|
||||
cyber_access_program: options.cyber_access_program,
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
ids
|
||||
snapshot
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user