Preserve Windows proxy settings in Guardian sessions (#40641)

## Why

Guardian sessions can run alongside another Windows sandbox launch and should not reconcile the persistent proxy settings established by that launch.

## What changed

- Start internal Guardian sessions with `WindowsSandboxProxySettingsMode::Preserve`.
- Continue using `Reconcile` for other sessions.

## Testing

Added a thread manager test that verifies a parent session reconciles proxy settings while its internal Guardian session preserves them.

GitOrigin-RevId: c6a31637ecdf828548cfd7153da7e9405abe34fa
This commit is contained in:
Won Park authored and copyberry committed 2026-08-25 16:53:47 +00:00
1 parent 5ce04789fb
commit da4cf1cdea
2 files changed
+55 -2

No files matched your search

+45
View File
@@ -878,6 +878,51 @@ async fn start_thread_keeps_internal_threads_hidden_from_normal_lookups() {
assert!(manager.list_thread_ids().await.is_empty());
}
#[tokio::test]
async fn spawn_internal_guardian_session_preserves_windows_sandbox_proxy_settings() {
let temp_dir = tempdir().expect("tempdir");
let mut config = test_config().await;
config.codex_home = temp_dir.path().join("codex-home").abs();
config.cwd = config.codex_home.abs();
std::fs::create_dir_all(&config.codex_home).expect("create codex home");
let manager = ThreadManager::with_models_provider_and_home_for_tests(
CodexAuth::from_api_key("dummy"),
config.model_provider.clone(),
config.codex_home.to_path_buf(),
Arc::new(codex_exec_server::EnvironmentManager::default_for_tests()),
);
let parent = manager
.start_thread(StartThreadOptions::new(config.clone()))
.await
.expect("start parent thread");
let reviewer = manager
.spawn_internal_session(
parent.thread_id,
StartThreadOptions {
session_source: Some(SessionSource::Internal(InternalSessionSource::Guardian)),
..StartThreadOptions::new(config)
},
)
.await
.expect("start internal reviewer");
assert_eq!(
(
parent.thread.session.windows_sandbox_proxy_settings_mode,
reviewer.thread.session.windows_sandbox_proxy_settings_mode,
),
(
codex_sandboxing::WindowsSandboxProxySettingsMode::Reconcile,
codex_sandboxing::WindowsSandboxProxySettingsMode::Preserve,
)
);
manager
.shutdown_all_threads_bounded(Duration::from_secs(10))
.await;
}
#[tokio::test]
async fn spawn_internal_session_preserves_parent_lineage_without_forking_history() {
struct ParentLifecycleContributor {