Use optional default environment for disabled mode

Restore CODEX_EXEC_SERVER_URL=none semantics by making EnvironmentManager::default_environment return None when environment access is disabled. Remove the separate disabled-for-agent flag and derive tool availability from the optional default environment.

Add an end-to-end tool exposure test for CODEX_EXEC_SERVER_URL=none.

Co-authored-by: Codex <noreply@openai.com>
This commit is contained in:
starr-openai
2026-04-21 10:35:53 -07:00
co-authored by Codex
parent 64a9a98695
commit 9d3188f79b
11 changed files with 145 additions and 107 deletions
+3 -1
View File
@@ -461,7 +461,9 @@ impl Codex {
let (tx_event, rx_event) = async_channel::unbounded();
let environment = environment_manager.default_environment();
let fs = Some(environment.get_filesystem());
let fs = environment
.as_ref()
.map(|environment| environment.get_filesystem());
let plugin_outcome = plugins_manager.plugins_for_config(&config).await;
let effective_skill_roots = plugin_outcome.effective_skill_roots();
let skills_input = skills_load_input_from_config(&config, effective_skill_roots);
-4
View File
@@ -641,8 +641,6 @@ impl Session {
Arc::clone(&auth_manager),
session_configuration.session_source.clone(),
));
let environment = environment_manager.default_environment();
let allows_agent_environment_access = environment_manager.allows_agent_environment_access();
let services = SessionServices {
// Initialize the MCP connection manager with an uninitialized
// instance. It will be replaced with one created via
@@ -698,8 +696,6 @@ impl Session {
config.js_repl_node_path.clone(),
),
environment_manager,
environment: Some(environment),
allows_agent_environment_access,
};
services
.model_client
-6
View File
@@ -3245,8 +3245,6 @@ pub(crate) async fn make_session_and_context() -> (Session, TurnContext) {
config.js_repl_node_path.clone(),
),
environment_manager: Arc::new(codex_exec_server::EnvironmentManager::default()),
environment: Some(Arc::clone(&environment)),
allows_agent_environment_access: true,
};
let js_repl = Arc::new(JsReplHandle::with_node_path(
config.js_repl_node_path.clone(),
@@ -3280,7 +3278,6 @@ pub(crate) async fn make_session_and_context() -> (Session, TurnContext) {
model_info,
&models_manager,
/*network*/ None,
/*allows_agent_environment_access*/ true,
Some(environment),
"turn_id".to_string(),
Arc::clone(&js_repl),
@@ -4346,8 +4343,6 @@ where
config.js_repl_node_path.clone(),
),
environment_manager: Arc::new(codex_exec_server::EnvironmentManager::default()),
environment: Some(Arc::clone(&environment)),
allows_agent_environment_access: true,
};
let js_repl = Arc::new(JsReplHandle::with_node_path(
config.js_repl_node_path.clone(),
@@ -4381,7 +4376,6 @@ where
model_info,
&models_manager,
/*network*/ None,
/*allows_agent_environment_access*/ true,
Some(environment),
"turn_id".to_string(),
Arc::clone(&js_repl),
+4 -7
View File
@@ -345,7 +345,6 @@ impl Session {
model_info: ModelInfo,
models_manager: &ModelsManager,
network: Option<NetworkProxy>,
allows_agent_environment_access: bool,
environment: Option<Arc<Environment>>,
sub_id: String,
js_repl: Arc<JsReplHandle>,
@@ -382,7 +381,7 @@ impl Session {
)
.with_web_search_config(per_turn_config.web_search_config.clone())
.with_allow_login_shell(per_turn_config.permissions.allow_login_shell)
.with_has_environment(allows_agent_environment_access)
.with_has_environment(environment.is_some())
.with_spawn_agent_usage_hint(per_turn_config.multi_agent_v2.usage_hint_enabled)
.with_spawn_agent_usage_hint_text(per_turn_config.multi_agent_v2.usage_hint_text.clone())
.with_hide_spawn_agent_metadata(per_turn_config.multi_agent_v2.hide_spawn_agent_metadata)
@@ -545,9 +544,8 @@ impl Session {
.await;
let effective_skill_roots = plugin_outcome.effective_skill_roots();
let skills_input = skills_load_input_from_config(&per_turn_config, effective_skill_roots);
let fs = self
.services
.environment
let environment = self.services.environment_manager.default_environment();
let fs = environment
.as_ref()
.map(|environment| environment.get_filesystem());
let skills_outcome = Arc::new(
@@ -577,8 +575,7 @@ impl Session {
)
.then(|| started_proxy.proxy())
}),
self.services.allows_agent_environment_access,
self.services.environment.clone(),
environment,
sub_id,
Arc::clone(&self.js_repl),
skills_outcome,
-3
View File
@@ -17,7 +17,6 @@ use crate::tools::network_approval::NetworkApprovalService;
use crate::tools::sandboxing::ApprovalStore;
use crate::unified_exec::UnifiedExecProcessManager;
use codex_analytics::AnalyticsEventsClient;
use codex_exec_server::Environment;
use codex_exec_server::EnvironmentManager;
use codex_hooks::Hooks;
use codex_login::AuthManager;
@@ -68,6 +67,4 @@ pub(crate) struct SessionServices {
/// Shared process-level environment registry. Sessions carry an `Arc` handle so they can pass
/// the same manager through child-thread spawn paths without reconstructing it.
pub(crate) environment_manager: Arc<EnvironmentManager>,
pub(crate) environment: Option<Arc<Environment>>,
pub(crate) allows_agent_environment_access: bool,
}
+3 -3
View File
@@ -923,8 +923,8 @@ impl ThreadManagerState {
user_shell_override: Option<crate::shell::Shell>,
) -> CodexResult<NewThread> {
let environment = self.environment_manager.default_environment();
let watch_registration = match environment.is_remote() {
false => {
let watch_registration = match environment.as_ref() {
Some(environment) if !environment.is_remote() => {
self.skills_watcher
.register_config(
&config,
@@ -934,7 +934,7 @@ impl ThreadManagerState {
)
.await
}
true => crate::file_watcher::WatchRegistration::default(),
Some(_) | None => crate::file_watcher::WatchRegistration::default(),
};
let CodexSpawnOk {
codex, thread_id, ..