From fc483d4b4d743045dd0fe969844c948152231296 Mon Sep 17 00:00:00 2001 From: Charlie Marsh Date: Thu, 19 Nov 2026 03:34:48 +0000 Subject: [PATCH] Box the future returned by response item injection (#62420) ## Why Callers of `CodexThread::inject_response_items` each compile a copy of its concrete future, duplicating compilation work. ## What changed Return a `BoxFuture` from `CodexThread::inject_response_items` so the concrete future stays in the core crate. Raise the core integration test crate's recursion limit to 256. GitOrigin-RevId: 2ccb280c7887278fc8011c37df35df84c47b3e35 --- codex-rs/core/src/codex_thread.rs | 11 ++++++++++- codex-rs/core/tests/all.rs | 1 + 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/codex-rs/core/src/codex_thread.rs b/codex-rs/core/src/codex_thread.rs index 8b078b5061..de02e26e21 100644 --- a/codex-rs/core/src/codex_thread.rs +++ b/codex-rs/core/src/codex_thread.rs @@ -90,6 +90,7 @@ use codex_user_input::ResolvedUserInput; use codex_utils_absolute_path::AbsolutePathBuf; use codex_utils_path_uri::LegacyAppPathString; use codex_utils_path_uri::PathUri; +use futures::future::BoxFuture; use rmcp::model::ReadResourceRequestParams; use std::any::Any; use std::path::PathBuf; @@ -1135,7 +1136,15 @@ impl CodexThread { /// Inject raw Responses items. Plaintext agent-mail batches in a native MAv2 /// runtime use queue-only mailbox delivery and its existing wake policy. /// Other batches retain history-injection semantics. - pub async fn inject_response_items(&self, items: Vec) -> CodexResult<()> { + pub fn inject_response_items( + &self, + items: Vec, + ) -> BoxFuture<'_, CodexResult<()>> { + // Keep the concrete future in core so callers don't each compile their own copy. + Box::pin(self.inject_response_items_inner(items)) + } + + async fn inject_response_items_inner(&self, items: Vec) -> CodexResult<()> { let config = self.session.get_config().await; // Native mail can represent this shape without changing its payload. Keep // mixed history and multipart/encrypted items on the raw injection path. diff --git a/codex-rs/core/tests/all.rs b/codex-rs/core/tests/all.rs index 0ee0cd986a..e6828ba07f 100644 --- a/codex-rs/core/tests/all.rs +++ b/codex-rs/core/tests/all.rs @@ -1,3 +1,4 @@ +#![recursion_limit = "256"] #![allow(clippy::expect_used)] // Single integration test binary that aggregates all test modules.