mirror of
https://github.com/openai/codex.git
synced 2026-12-03 07:47:10 +00:00
Separate thread settings from environment configuration (#39597)
## Why Environment-owned permission profiles and workspace roots must remain effective without being persisted or restored as thread-owned settings. ## What changed - Keep thread settings snapshots and restore data separate from the effective configuration supplied by the primary environment. - Use resolved environment permissions, active profiles, workspace roots, and network policy when building turn context and session events. - Preserve environment selections when agents are evicted, resumed, or spawned, and validate owner configuration when it becomes ready. - Start memory initialization only after the primary environment is configured. ## Testing - Extend remote-environment and multi-agent tests to cover settings persistence, owner permission profiles, workspace roots, spawning, eviction, and resume. GitOrigin-RevId: d82f126981cd0190233020bbdd61d96c70558868
This commit is contained in:
1 parent
8f4a48a6ad
commit
d75c85f651
35 files changed
+564
-308
No files matched your search
@@ -14,6 +14,7 @@ use codex_exec_server::ExecutorFileSystem;
|
||||
use codex_exec_server::SelectedCapabilityRootsStatus;
|
||||
use codex_protocol::capabilities::CapabilityRootLocation;
|
||||
use codex_protocol::capabilities::SelectedCapabilityRoot;
|
||||
use codex_protocol::models::PermissionProfile;
|
||||
use codex_protocol::protocol::EnvironmentConfig;
|
||||
use codex_protocol::protocol::EnvironmentConfigState;
|
||||
use codex_protocol::protocol::EnvironmentConnectionEvent;
|
||||
@@ -360,6 +361,18 @@ impl ThreadEnvironments {
|
||||
})
|
||||
}
|
||||
|
||||
/// Returns installed owner configuration without treating pending attachments as ready.
|
||||
pub(crate) fn primary_config_for(
|
||||
selections: &[TurnEnvironmentSelection],
|
||||
) -> Option<&EnvironmentConfig> {
|
||||
match &selections.first()?.config {
|
||||
EnvironmentConfigState::Ready(config) => Some(config),
|
||||
EnvironmentConfigState::FromThread
|
||||
| EnvironmentConfigState::Pending
|
||||
| EnvironmentConfigState::Failed(_) => None,
|
||||
}
|
||||
}
|
||||
|
||||
pub(crate) fn primary_workspace_roots_for(
|
||||
selections: &[TurnEnvironmentSelection],
|
||||
) -> Vec<AbsolutePathBuf> {
|
||||
@@ -713,6 +726,16 @@ impl TurnEnvironmentSnapshot {
|
||||
self.turn_environments().next()
|
||||
}
|
||||
|
||||
/// Returns the primary environment's resolved permissions, or the provided fallback.
|
||||
pub(crate) fn permission_profile_or_else(
|
||||
&self,
|
||||
fallback: impl FnOnce() -> PermissionProfile,
|
||||
) -> PermissionProfile {
|
||||
self.primary()
|
||||
.map(TurnEnvironment::permission_profile_with_workspace_roots)
|
||||
.unwrap_or_else(fallback)
|
||||
}
|
||||
|
||||
pub(crate) fn local(&self) -> Option<&TurnEnvironment> {
|
||||
self.turn_environments()
|
||||
.find(|environment| !environment.environment.is_remote())
|
||||
|
||||
Reference in new issue
Block a user