From 5fcc380bd99b9f5e095a2b65231198f368334fef Mon Sep 17 00:00:00 2001 From: Ahmed Ibrahim Date: Thu, 30 Oct 2025 07:22:42 -0700 Subject: [PATCH] Pass initial history as an optional to codex delegate (#5950) This will give us more freedom on controlling the delegation. i.e we can fork our history and run `compact`. --- codex-rs/core/src/codex_delegate.rs | 5 ++++- codex-rs/core/src/tasks/review.rs | 1 + 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/codex-rs/core/src/codex_delegate.rs b/codex-rs/core/src/codex_delegate.rs index b123a8a3..c0fa0bf7 100644 --- a/codex-rs/core/src/codex_delegate.rs +++ b/codex-rs/core/src/codex_delegate.rs @@ -36,6 +36,7 @@ pub(crate) async fn run_codex_conversation_interactive( parent_session: Arc, parent_ctx: Arc, cancel_token: CancellationToken, + initial_history: Option, ) -> Result { let (tx_sub, rx_sub) = async_channel::bounded(SUBMISSION_CHANNEL_CAPACITY); let (tx_ops, rx_ops) = async_channel::bounded(SUBMISSION_CHANNEL_CAPACITY); @@ -43,7 +44,7 @@ pub(crate) async fn run_codex_conversation_interactive( let CodexSpawnOk { codex, .. } = Codex::spawn( config, auth_manager, - InitialHistory::New, + initial_history.unwrap_or(InitialHistory::New), SessionSource::SubAgent(SubAgentSource::Review), ) .await?; @@ -93,6 +94,7 @@ pub(crate) async fn run_codex_conversation_one_shot( parent_session: Arc, parent_ctx: Arc, cancel_token: CancellationToken, + initial_history: Option, ) -> Result { // Use a child token so we can stop the delegate after completion without // requiring the caller to cancel the parent token. @@ -103,6 +105,7 @@ pub(crate) async fn run_codex_conversation_one_shot( parent_session, parent_ctx, child_cancel.clone(), + initial_history, ) .await?; diff --git a/codex-rs/core/src/tasks/review.rs b/codex-rs/core/src/tasks/review.rs index 286eefa6..57258f4c 100644 --- a/codex-rs/core/src/tasks/review.rs +++ b/codex-rs/core/src/tasks/review.rs @@ -90,6 +90,7 @@ async fn start_review_conversation( session.clone_session(), ctx.clone(), cancellation_token, + None, ) .await) .ok()