From ea27d861b21c0540b323bf925feba634eafdd6ef Mon Sep 17 00:00:00 2001 From: jif-oai Date: Thu, 2 Apr 2026 16:18:53 +0200 Subject: [PATCH] nit: state machine desc (#16569) --- codex-rs/core/src/state/turn.rs | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/codex-rs/core/src/state/turn.rs b/codex-rs/core/src/state/turn.rs index 8cfd8555e..a8e3e167b 100644 --- a/codex-rs/core/src/state/turn.rs +++ b/codex-rs/core/src/state/turn.rs @@ -30,6 +30,16 @@ pub(crate) struct ActiveTurn { } /// Whether mailbox deliveries should still be folded into the current turn. +/// +/// State machine: +/// - A turn starts in `CurrentTurn`, so queued child mail can join the next +/// model request for that turn. +/// - After user-visible terminal output is recorded, we switch to `NextTurn` +/// to leave late child mail queued instead of extending an already shown +/// answer. +/// - If the same task later gets explicit same-turn work again (a steered user +/// prompt or a tool call after an untagged preamble), we reopen `CurrentTurn` +/// so that pending child mail is drained into that follow-up request. #[derive(Clone, Copy, Debug, Default, Eq, PartialEq)] pub(crate) enum MailboxDeliveryPhase { /// Incoming mailbox messages can still be consumed by the current turn.