From 94cbf56ad096a229884a51f7bde7063a8f167c91 Mon Sep 17 00:00:00 2001 From: Abhinav Vedmala Date: Fri, 15 May 2026 16:33:06 -0700 Subject: [PATCH] Clarify stop hook target resolution --- codex-rs/core/src/hook_runtime.rs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/codex-rs/core/src/hook_runtime.rs b/codex-rs/core/src/hook_runtime.rs index 7be05d060d..926dc94213 100644 --- a/codex-rs/core/src/hook_runtime.rs +++ b/codex-rs/core/src/hook_runtime.rs @@ -308,6 +308,8 @@ pub(crate) async fn run_turn_stop_hooks( stop_hook_active: bool, last_assistant_message: Option, ) -> StopOutcome { + // Resolve the stop hook kind from the session source before building the + // request. Root turns run Stop; thread-spawned child turns run SubagentStop. let (target, transcript_path) = match &turn_context.session_source { SessionSource::SubAgent(SubAgentSource::ThreadSpawn { agent_role, @@ -347,6 +349,8 @@ pub(crate) async fn run_turn_stop_hooks( parent_transcript_path, ) } + // Internal/synthetic subagents do not expose user-configured lifecycle + // hooks, so there is no Stop or SubagentStop request to dispatch. SessionSource::SubAgent(_) => return StopOutcome::default(), _ => (StopHookTarget::Stop, sess.hook_transcript_path().await), };