From 39c4f2b06d4abd50c85fc704145e293ad51d1bf5 Mon Sep 17 00:00:00 2001 From: Ahmed Ibrahim Date: Wed, 4 Mar 2026 20:20:48 -0800 Subject: [PATCH] Wait for legacy notify hook completion --- codex-rs/hooks/src/user_notification.rs | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/codex-rs/hooks/src/user_notification.rs b/codex-rs/hooks/src/user_notification.rs index caeca59b50..801da59aef 100644 --- a/codex-rs/hooks/src/user_notification.rs +++ b/codex-rs/hooks/src/user_notification.rs @@ -62,14 +62,19 @@ pub fn notify_hook(argv: Vec) -> Hook { command.arg(notify_payload); } - // Backwards-compat: match legacy notify behavior (argv + JSON arg, fire-and-forget). + // Preserve the legacy argv + JSON payload shape, but wait for completion so + // after-agent hooks finish their side effects before the turn is marked done. command .stdin(Stdio::null()) .stdout(Stdio::null()) .stderr(Stdio::null()); - match command.spawn() { - Ok(_) => HookResult::Success, + match command.status().await { + Ok(status) if status.success() => HookResult::Success, + Ok(status) => HookResult::FailedContinue( + std::io::Error::other(format!("legacy notify exited with status {status}")) + .into(), + ), Err(err) => HookResult::FailedContinue(err.into()), } })