fix: prevent Computer Use subprocess leak on macOS#1182
Open
guangsizhongbin wants to merge 1 commit into
Open
Conversation
Codex spawns a SkyComputerUseClient subprocess for each Computer Use session via the openai-bundled computer-use plugin, but does not reliably clean them up when conversations end. On macOS, these orphaned processes accumulate (~20MB RSS each), eventually causing swap pressure and UI freezes. Changes: - computer_use_guard.rs: Add kill_orphaned_computer_use_processes() for macOS that uses pkill to clean up SkyComputerUseClient processes. Codex re-spawns them lazily on the next Computer Use session, so this is safe to run periodically. - launcher.rs: Add a macOS-specific computer_use_guard_watchdog that runs every 120 seconds and kills orphaned Computer Use subprocesses. The watchdog is always active on macOS (not gated on the computer_use_guard_enabled setting, which is Windows-specific). - relay_config.rs: Replace && let_chains syntax with nested if let blocks for broader Rust version compatibility.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Codex spawns a
SkyComputerUseClientsubprocess for each Computer Use session via the openai-bundled computer-use plugin, but does not reliably clean them up when conversations end. Over time these orphaned processes accumulate (~20MB RSS each), causing swap pressure and UI freezes.On macOS, Codex++'s
computer_use_guardwas a no-op — all guard functionality was#[cfg(windows)]only.Changes
computer_use_guard.rsAdded
kill_orphaned_computer_use_processes()for macOS that usespkill -f SkyComputerUseClientto clean up orphaned processes. Codex re-spawns them lazily on the next Computer Use session, so killing them is safe.node_replprocesses are intentionally left alone — they are lightweight (~1MB RSS) and killing them could disrupt in-flight code execution.launcher.rsAdded a macOS-specific
computer_use_guard_watchdogthat runs every 120 seconds in a background tokio task. The watchdog is always active on macOS (not gated oncomputer_use_guard_enabled, which is a Windows-specific setting).relay_config.rsReplaced
&& let_chainssyntax with nestedif letblocks for broader Rust version compatibility. Thelet_chainsfeature requires nightly or specific Rust ≥1.86 nightly features.Testing
start_computer_use_guard_watchdogand runs every 2 minutesSkyComputerUseClientprocesses