mirror of
https://github.com/openai/codex.git
synced 2026-11-27 23:31:09 +00:00
Continue interrupted work after managed daemon restarts (#45820)
## Why Daemon recovery reloads threads but leaves interrupted work unfinished. Resume eligible work automatically from the saved conversation, even without a connected client. ## What changed - Attempt one new continuation turn immediately after restoration, including in Plan mode. Mark the old turn interrupted and supply recovery context without creating a user message or granting new authorization. - Require an idle thread, matching permissions, and the same single local environment configured by the thread. Skip completed, aborted, or superseded work and snapshots without environment identity. - Add `continue_turn_if_idle` with an atomic previous-turn check so newer tasks or standalone settings changes invalidate pending continuation. - Preserve the output schema, service tier, and root turn ID, and emit a “Resuming interrupted work” warning when continuation starts. ## Testing Add daemon restart coverage for continuation without a client, Plan mode, permission and environment mismatches, and legacy snapshots. Add core coverage for preserved continuation metadata, absence of user-message events, rejection of superseded continuations, and exclusion of remote execution from recovery snapshots. GitOrigin-RevId: 2b290b75d9399fc58258bcda2e85c74e9b5b3b09
This commit is contained in:
1 parent
7c709f0ffd
commit
f2b5b81f39
21 files changed
+641
-55
No files matched your search
@@ -805,11 +805,11 @@ fn spawn_approved_task_tool_call(
|
||||
#[tokio::test]
|
||||
async fn external_transport_registers_dynamic_tools_and_finds_task_mentions() -> Result<()> {
|
||||
let (app, _codex_home) = make_history_test_app().await?;
|
||||
let (mut app_server, requests, proxy) = start_recording_app_server(
|
||||
let (mut app_server, requests, proxy) = Box::pin(start_recording_app_server(
|
||||
&app.config,
|
||||
/*blocked_thread_list*/ None,
|
||||
/*failed_thread_name*/ None,
|
||||
)
|
||||
))
|
||||
.await?;
|
||||
|
||||
let started = app_server.start_thread(&app.config).await?;
|
||||
@@ -858,25 +858,27 @@ async fn external_transport_registers_dynamic_tools_and_finds_task_mentions() ->
|
||||
app_server.shutdown().await?;
|
||||
proxy.await??;
|
||||
let (mut restarted_app_server, _restarted_requests, restarted_proxy) =
|
||||
start_recording_app_server(
|
||||
Box::pin(start_recording_app_server(
|
||||
&app.config,
|
||||
/*blocked_thread_list*/ None,
|
||||
/*failed_thread_name*/ None,
|
||||
)
|
||||
.await?;
|
||||
let resumed = restarted_app_server
|
||||
.resume_thread(
|
||||
&app.local_settings,
|
||||
app.config.clone(),
|
||||
target_id,
|
||||
crate::app_server_session::ResumeModelSettings::RestoreFromThread,
|
||||
)
|
||||
))
|
||||
.await?;
|
||||
let resumed = Box::pin(restarted_app_server.resume_thread(
|
||||
&app.local_settings,
|
||||
app.config.clone(),
|
||||
target_id,
|
||||
crate::app_server_session::ResumeModelSettings::RestoreFromThread,
|
||||
))
|
||||
.await?;
|
||||
assert!(resumed.task_tools_available);
|
||||
assert!(restarted_app_server.task_tools_available(target_id));
|
||||
let forked = restarted_app_server
|
||||
.fork_thread(&app.local_settings, app.config.clone(), target_id)
|
||||
.await?;
|
||||
let forked = Box::pin(restarted_app_server.fork_thread(
|
||||
&app.local_settings,
|
||||
app.config.clone(),
|
||||
target_id,
|
||||
))
|
||||
.await?;
|
||||
assert!(forked.task_tools_available);
|
||||
assert!(restarted_app_server.task_tools_available(forked.session.thread_id));
|
||||
restarted_app_server
|
||||
|
||||
@@ -1377,7 +1377,7 @@ async fn owned_subagent_approval_before_thread_started_is_preserved() -> Result<
|
||||
let codex_home = tempdir()?;
|
||||
app.config.codex_home = codex_home.path().to_path_buf().abs();
|
||||
app.config.sqlite = codex_state::SqliteConfig::new_for_testing(codex_home.path().abs());
|
||||
let mut app_server = crate::start_embedded_app_server_for_picker(&app.config).await?;
|
||||
let mut app_server = Box::pin(crate::start_embedded_app_server_for_picker(&app.config)).await?;
|
||||
let parent = app_server.start_thread(&app.config).await?;
|
||||
let parent_thread_id = parent.session.thread_id;
|
||||
app.enqueue_primary_thread_session(parent.session, parent.turns)
|
||||
|
||||
Reference in new issue
Block a user