From 0642d36ae4a9454f94ab33f2a861d5d3cf606fa7 Mon Sep 17 00:00:00 2001 From: starr-openai Date: Tue, 21 Apr 2026 11:13:27 -0700 Subject: [PATCH] Share remote environment exec-server client Create one lazy exec-server client per remote environment and pass clones into the remote process and filesystem backends. This keeps ExecServerClient as the connected-client type while avoiding duplicate websocket clients for one environment. Co-authored-by: Codex --- codex-rs/exec-server/src/environment.rs | 8 ++++---- codex-rs/exec-server/src/remote_file_system.rs | 6 ++---- codex-rs/exec-server/src/remote_process.rs | 6 ++---- 3 files changed, 8 insertions(+), 12 deletions(-) diff --git a/codex-rs/exec-server/src/environment.rs b/codex-rs/exec-server/src/environment.rs index d7e09d7da9..9fe2eb5300 100644 --- a/codex-rs/exec-server/src/environment.rs +++ b/codex-rs/exec-server/src/environment.rs @@ -3,6 +3,7 @@ use std::sync::Arc; use crate::ExecServerError; use crate::ExecServerRuntimePaths; +use crate::client::LazyRemoteExecServerClient; use crate::file_system::ExecutorFileSystem; use crate::local_file_system::LocalFileSystem; use crate::local_process::LocalProcess; @@ -196,10 +197,9 @@ impl Environment { exec_server_url: String, local_runtime_paths: Option, ) -> Self { - let exec_backend: Arc = - Arc::new(RemoteProcess::new(exec_server_url.clone())); - let filesystem: Arc = - Arc::new(RemoteFileSystem::new(exec_server_url.clone())); + let client = LazyRemoteExecServerClient::new(exec_server_url.clone()); + let exec_backend: Arc = Arc::new(RemoteProcess::new(client.clone())); + let filesystem: Arc = Arc::new(RemoteFileSystem::new(client)); Self { exec_server_url: Some(exec_server_url), diff --git a/codex-rs/exec-server/src/remote_file_system.rs b/codex-rs/exec-server/src/remote_file_system.rs index d06f9acdd1..dc269505a1 100644 --- a/codex-rs/exec-server/src/remote_file_system.rs +++ b/codex-rs/exec-server/src/remote_file_system.rs @@ -32,11 +32,9 @@ pub(crate) struct RemoteFileSystem { } impl RemoteFileSystem { - pub(crate) fn new(websocket_url: String) -> Self { + pub(crate) fn new(client: LazyRemoteExecServerClient) -> Self { trace!("remote fs new"); - Self { - client: LazyRemoteExecServerClient::new(websocket_url), - } + Self { client } } } diff --git a/codex-rs/exec-server/src/remote_process.rs b/codex-rs/exec-server/src/remote_process.rs index 9de649a274..d8d06735cd 100644 --- a/codex-rs/exec-server/src/remote_process.rs +++ b/codex-rs/exec-server/src/remote_process.rs @@ -25,11 +25,9 @@ struct RemoteExecProcess { } impl RemoteProcess { - pub(crate) fn new(websocket_url: String) -> Self { + pub(crate) fn new(client: LazyRemoteExecServerClient) -> Self { trace!("remote process new"); - Self { - client: LazyRemoteExecServerClient::new(websocket_url), - } + Self { client } } }