Add /detach for active Codex CLI sessions
What feature would you like to see?
Add a /detach command to active Codex CLI/TUI sessions so a running agent task can continue after the terminal UI exits, without requiring tmux or screen.
Problem
Many Codex tasks start interactively and only later become long-running: repo-wide reviews, refactors, test runs, migrations, or investigations on a remote VM. Today, once the task is running, the user generally has to keep the terminal open or rely on tmux/screen to avoid losing the live session.
This is especially painful over SSH, where disconnects or local terminal closes can interrupt the workflow.
Proposed UX
Inside an active Codex session:
/detach
Codex should keep the current run alive in the background, exit the TUI, and print something like:
Detached session: 019e...
Reattach with: codex resume 019e...
Reattaching should reconnect to the live session if it is still running, or open the completed session if it has already finished.
Expected behavior
/detachpreserves the current session, working directory, config, auth context, and pending task state.codex resume <session-id>can reattach to the live detached session.- Detached sessions appear in
codex resume --allwith a clear running/paused/completed state. - If Codex needs approval or user input while detached, it should pause safely and make that state visible when resumed.
- Session output should remain available after detaching through normal resume/history behavior.
Why this matters
This would make long-running Codex CLI workflows much more robust without forcing users to manage terminal multiplexers. It fits naturally with Codex's existing session/resume model and would improve remote development workflows, where keeping an SSH terminal alive is often the weakest part of the loop.
Related to #3968, but this request is specifically about detaching an already-running interactive Codex session rather than starting arbitrary background terminal commands.
This issue has 1 comment on GitHub. Read the full discussion on GitHub ↗