Derive sandbox contexts from turn environments (#40551)

## What changed

- Add Windows sandbox mode, private-desktop behavior, and legacy Landlock selection to each `EnvironmentConfig`.
- Centralize sandbox context construction on `TurnEnvironment`, preserving environment-owned permissions, paths, and backend settings while applying additional permission grants.
- Use the environment-derived context for project instructions, capability discovery, file uploads, and filesystem-oriented tools.

## Testing

- Verify capability discovery uses the selected environment's permission profile and sandbox backends when they differ from the thread defaults.

GitOrigin-RevId: 7ae2fed90c8ada950f2e8431e571e9b2c793c291
This commit is contained in:
Adam Perry @ OpenAI authored and copyberry committed 2026-08-25 05:16:45 +00:00
1 parent 348f49b292
commit 8444cf63b5
47 files changed
+341 -151

No files matched your search

+3 -3
View File
@@ -28,7 +28,6 @@ pub(super) struct McpDesiredState {
pub(super) session_source: SessionSource,
pub(super) environments: TurnEnvironmentSnapshot,
pub(super) local_process_cwd: PathBuf,
pub(super) windows_sandbox_level: WindowsSandboxLevel,
}
impl Session {
@@ -38,6 +37,9 @@ impl Session {
next: &SessionConfiguration,
updates: &SessionSettingsUpdate,
) -> bool {
// TODO(anp): Reconcile invalidation with TurnEnvironment::sandbox_context.
// This gap predates that API: an internal Windows-level-only settings update
// can leave the published MCP configuration stale.
current.cwd() != next.cwd()
|| current.approval_policy.value() != next.approval_policy.value()
|| current.approvals_reviewer != next.approvals_reviewer
@@ -97,7 +99,6 @@ impl Session {
session_source: session_configuration.session_source.clone(),
environments,
local_process_cwd,
windows_sandbox_level: session_configuration.windows_sandbox_level,
}
}
@@ -124,7 +125,6 @@ impl Session {
session_source: session_configuration.session_source.clone(),
environments: resolved_environments.clone(),
local_process_cwd,
windows_sandbox_level: session_configuration.windows_sandbox_level,
};
self.publish_mcp_runtime(
&desired,