From b1fd48c48e2cc227f4ea818a6030be9b86cde055 Mon Sep 17 00:00:00 2001 From: Charlie Marsh Date: Mon, 19 Oct 2026 13:19:11 +0000 Subject: [PATCH] Avoid cloning events in the app-server thread listener (#55283) Record whether an event is `ShutdownComplete` before moving it into `apply_bespoke_event_handling`, preserving shutdown drain notification without cloning the event. GitOrigin-RevId: 9e4ca8c657d4d5b98056de8c7aba1391233994c1 --- .../app-server/src/request_processors/thread_lifecycle.rs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/codex-rs/app-server/src/request_processors/thread_lifecycle.rs b/codex-rs/app-server/src/request_processors/thread_lifecycle.rs index e6864c4dca..ab13ac6b0d 100644 --- a/codex-rs/app-server/src/request_processors/thread_lifecycle.rs +++ b/codex-rs/app-server/src/request_processors/thread_lifecycle.rs @@ -375,8 +375,9 @@ pub(super) async fn ensure_listener_task_running( &outgoing_for_task, conversation_id, ).await; } + let is_shutdown_complete = matches!(event.msg, EventMsg::ShutdownComplete); apply_bespoke_event_handling( - event.clone(), + event, conversation_id, conversation.clone(), thread_manager.clone(), @@ -385,7 +386,7 @@ pub(super) async fn ensure_listener_task_running( thread_watch_manager.clone(), ) .await; - if matches!(event.msg, EventMsg::ShutdownComplete) + if is_shutdown_complete && let Some(completion_tx) = thread_state .lock() .await