Centralize thread environment selection state (#38423)

## What changed

- Make `ThreadEnvironments` the source of truth for live environment selections and use it when building configuration snapshots, permission profiles, per-turn configuration, and MCP refresh inputs.
- Keep settings previews side-effect free while applying accepted environment updates consistently to subsequent turns.
- Move `EnvironmentConfig` into `codex-protocol` so environment ownership no longer depends on a core-only type.

## Testing

- Cover environment previews and snapshots, accepted and rejected steer updates, and active-turn environment stability.

GitOrigin-RevId: 7bcf8fb5df1215f720e4e9c419541a51a871aa5e
This commit is contained in:
sayan-oai
2026-08-13 19:25:05 +00:00
committed by copyberry
parent 588e18aae5
commit 781445f7c6
16 changed files with 428 additions and 327 deletions
+2 -2
View File
@@ -1,7 +1,6 @@
use crate::agent::AgentStatus;
use crate::config::ConstraintResult;
use crate::elicitation::ElicitationRegistration;
use crate::environment_config::EnvironmentConfig;
use crate::session::SessionIo;
use crate::session::SessionSettingsUpdate;
use crate::session::session::Session;
@@ -27,6 +26,7 @@ use codex_protocol::models::PermissionProfile;
use codex_protocol::models::ResponseItem;
use codex_protocol::openai_models::ReasoningEffort;
use codex_protocol::protocol::AskForApproval;
use codex_protocol::protocol::EnvironmentConfig;
use codex_protocol::protocol::Event;
use codex_protocol::protocol::MultiAgentVersion;
use codex_protocol::protocol::Op;
@@ -669,7 +669,7 @@ impl CodexThread {
}
pub async fn environment_selections(&self) -> Vec<TurnEnvironmentSelection> {
self.session.thread_environment_selections().await
self.session.services.turn_environments.selections()
}
/// Installs resolved environment configuration and capability roots on this thread.