Collapse duplicate startup environment state

Co-authored-by: Codex <noreply@openai.com>
This commit is contained in:
starr-openai
2026-04-30 15:27:18 -07:00
co-authored by Codex
parent d9d6623508
commit fc26e1b683
4 changed files with 22 additions and 28 deletions
+10 -14
View File
@@ -31,7 +31,6 @@ use crate::context::PermissionsInstructions;
use crate::context::PersonalitySpecInstructions;
use crate::default_skill_metadata_budget;
use crate::environment_selection::ResolvedEnvironmentSelections;
use crate::environment_selection::resolve_environment_selections;
use crate::exec_policy::ExecPolicyManager;
use crate::installation_id::resolve_installation_id;
use crate::parse_turn_item;
@@ -113,7 +112,6 @@ use codex_protocol::protocol::SubAgentSource;
use codex_protocol::protocol::TurnAbortReason;
use codex_protocol::protocol::TurnContextItem;
use codex_protocol::protocol::TurnContextNetworkItem;
use codex_protocol::protocol::TurnEnvironmentSelection;
use codex_protocol::protocol::W3cTraceContext;
use codex_protocol::request_permissions::PermissionGrantScope;
use codex_protocol::request_permissions::RequestPermissionProfile;
@@ -406,8 +404,7 @@ pub(crate) struct CodexSpawnArgs {
pub(crate) parent_rollout_thread_trace: ThreadTraceContext,
pub(crate) user_shell_override: Option<shell::Shell>,
pub(crate) parent_trace: Option<W3cTraceContext>,
pub(crate) environments: Vec<TurnEnvironmentSelection>,
pub(crate) resolved_environments: Option<ResolvedEnvironmentSelections>,
pub(crate) environment_selections: ResolvedEnvironmentSelections,
pub(crate) analytics_events_client: Option<AnalyticsEventsClient>,
pub(crate) thread_store: Arc<dyn ThreadStore>,
}
@@ -464,20 +461,15 @@ impl Codex {
inherited_exec_policy,
parent_rollout_thread_trace,
parent_trace: _,
environments,
resolved_environments,
environment_selections,
analytics_events_client,
thread_store,
} = args;
let (tx_sub, rx_sub) = async_channel::bounded(SUBMISSION_CHANNEL_CAPACITY);
let (tx_event, rx_event) = async_channel::unbounded();
let resolved_environments = match resolved_environments {
Some(resolved_environments) => resolved_environments,
None => resolve_environment_selections(environment_manager.as_ref(), &environments)?,
};
config.cwd = resolved_environments.primary_cwd_or_fallback(&config.cwd);
config.cwd = environment_selections.primary_cwd_or_fallback(&config.cwd);
let load_config = config.clone();
let fs = resolved_environments.primary_filesystem();
let fs = environment_selections.primary_filesystem();
let plugins_input = load_config.plugins_config_input();
let plugin_outcome = plugins_manager.plugins_for_config(&plugins_input).await;
let effective_skill_roots = plugin_outcome.effective_skill_roots();
@@ -500,7 +492,7 @@ impl Codex {
let _ = config.features.disable(Feature::Collab);
}
let primary_environment = resolved_environments.primary_environment_backend();
let primary_environment = environment_selections.primary_environment_backend();
let user_instructions = AgentsMdManager::new(&load_config)
.user_instructions(primary_environment.as_deref())
.await;
@@ -614,7 +606,11 @@ impl Codex {
cwd: config.cwd.clone(),
codex_home: config.codex_home.clone(),
thread_name: None,
environments,
environments: environment_selections
.turn_environments
.iter()
.map(|environment| environment.selection())
.collect(),
original_config_do_not_use: Arc::clone(&config),
metrics_service_name,
app_server_client_name: None,