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), };