From 114c086d6decacf00f11bca606d20c57391d69e2 Mon Sep 17 00:00:00 2001 From: Charlie Marsh Date: Mon, 23 Nov 2026 12:34:41 +0000 Subject: [PATCH] Box the runtime registration future (#63329) ## What changed Return a boxed, `Send` future from `RuntimeRegistrationClient::register` so callers use a shared, type-erased interface for the registration request. Allocate the future only when registration is requested, leaving cached runtime lookups free of that allocation. GitOrigin-RevId: 721e36c3fbeb9d37a512ac4795d45bc9aead8031 --- .../runtime-agent-instance/src/registration.rs | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/codex-rs/runtime-agent-instance/src/registration.rs b/codex-rs/runtime-agent-instance/src/registration.rs index e52cbef38e..33f4945c18 100644 --- a/codex-rs/runtime-agent-instance/src/registration.rs +++ b/codex-rs/runtime-agent-instance/src/registration.rs @@ -10,6 +10,7 @@ use codex_http_client::RouteAwareClientPool; use codex_http_client::RouteAwareRequestError; use http::StatusCode; use serde::Deserialize; +use std::pin::Pin; use std::time::Duration; use url::Url; @@ -49,7 +50,19 @@ impl RuntimeRegistrationClient { }) } - pub async fn register( + /// Share the registration request across callers. A cached runtime skips this allocation. + pub fn register<'a>( + &'a self, + registration: &'a RuntimeRegistration, + ) -> Pin< + Box< + dyn Future> + Send + 'a, + >, + > { + Box::pin(self.register_inner(registration)) + } + + async fn register_inner( &self, registration: &RuntimeRegistration, ) -> Result {