Skip to content

armgit / codex

Public Imported from GitHub
0

Lightweight coding agent that runs in your terminal

Rust

nit: state machine desc (#16569)

jif-oaiea27d861b21c
diff --git a/codex-rs/core/src/state/turn.rs b/codex-rs/core/src/state/turn.rs
index 8cfd8555e6..a8e3e167b5 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.