Add process-scoped PSP routing for ChatGPT requests (#36986)

## What changed

- Add a hidden global `--psp` runtime flag and propagate it through TUI, exec,
  app-server, remote-control, and in-process startup paths.
- Attach the `oai-chat-psp=true` cookie to first-party ChatGPT requests when
  enabled, using a cached cookie-aware client with sensitive request logging
  disabled.
- Keep the routing selection out of persistent configuration layers while
  preserving it across config refreshes and agent role changes.

## Testing

- Cover global flag parsing, app-server propagation, config-layer isolation,
  and preservation across config rebuilds and role changes.

GitOrigin-RevId: 05cdc61ffd7162d8e48fc1e166f4732113e5a816
This commit is contained in:
stevenlee-oai authored and copyberry committed 2026-08-04 22:23:40 +00:00
1 parent 411f3f0680
commit 1d952f027e
25 files changed
+199 -16

No files matched your search

+4 -1
View File
@@ -437,6 +437,7 @@ pub struct AppServerRuntimeOptions {
pub plugin_startup_tasks: PluginStartupTasks,
pub remote_control_startup_mode: RemoteControlStartupMode,
pub install_shutdown_signal_handler: bool,
pub psp: bool,
}
impl Default for AppServerRuntimeOptions {
@@ -446,6 +447,7 @@ impl Default for AppServerRuntimeOptions {
plugin_startup_tasks: PluginStartupTasks::Start,
remote_control_startup_mode: RemoteControlStartupMode::ResolvePersisted,
install_shutdown_signal_handler: true,
psp: false,
}
}
}
@@ -486,7 +488,7 @@ pub async fn run_main_with_transport_options(
arg0_paths.codex_linux_sandbox_exe.clone(),
)?;
let ignore_user_config = loader_overrides.ignore_user_config;
let config_manager = ConfigManager::new(
let mut config_manager = ConfigManager::new(
codex_home.to_path_buf(),
cli_kv_overrides.clone(),
loader_overrides,
@@ -495,6 +497,7 @@ pub async fn run_main_with_transport_options(
arg0_paths.clone(),
Arc::new(NoopThreadConfigLoader),
);
config_manager.psp = runtime_options.psp;
match config_manager
.load_latest_config(/*fallback_cwd*/ None)
.await