Repository navigation
Description
What variant of Codex are you using?
CLI / TUI, installed through npm, running in Warp on macOS (Apple Silicon, zsh). Installed package checked for this report: @openai/codex 0.162.1.
What feature would you like to see?
Add a native /restart command that cleanly exits the current CLI runtime, launches the currently installed executable, and automatically resumes the same conversation in the same terminal pane.
Use case and current workflow
I keep Codex sessions open in Warp while upgrading the npm package. Updating the package on disk does not switch an already-running session to the new executable. I then have to exit each session, launch Codex again from the correct directory, and resume the matching conversation.
The desired sequence is:
- Update the installed Codex package using the existing update mechanism, for example from another terminal.
- In an existing Codex session, run
/restart. - Complete the normal shutdown/cleanup sequence, then launch the updated CLI with the equivalent of
codex resume <current-session-id>. - Continue the same conversation in the existing Warp pane.
A per-session command is sufficient. The first implementation does not need to update packages itself or broadcast restarts to other terminals.
Expected behavior and acceptance criteria
- Load the installed version: after upgrading from version A to B, restarting an A session must run B. Re-entering a TUI loop inside the old executable would not satisfy this requirement.
- Resume the exact conversation: retain its session/thread ID and persisted history, without opening a picker, creating a new conversation, or selecting another session via
--last. - Preserve the terminal and launch context: keep the same terminal pane and working directory; carry relevant launch/profile overrides through normal resume behavior. Do not replay the original prompt or image attachments.
- Exit cleanly: use the normal
/exitshutdown path, including its handling of an active turn, and allow session persistence and terminal cleanup to finish before relaunching. - Remain a native CLI operation: no tmux migration, external PTY supervisor, or shell wrapper should be required. Other open terminals and unrelated sessions should remain usable.
- Handle relaunch failure clearly: report an actionable error and the exact manual resume command. Avoid repeatedly relaunching or rerunning an update command.
Additional information
Source observations
In the inspected 0.162.1 CLI exit/update implementation, handle_app_exit prints exit information and optionally runs the update action. A successful package update prints “Update ran successfully! Please restart Codex.” and returns.
This suggests keeping the change around the existing exit/resume lifecycle. The important requirement is an executable handoff after cleanup, resolving the updated installation entrypoint rather than retaining a replaced or version-specific old binary path. The implementation choice is left to maintainers.
Restarting only the shared app-server daemon is a different operation: this request concerns the foreground CLI executable and its current conversation. Shared-daemon handling should follow normal startup compatibility behavior without forcibly interrupting unrelated sessions.
Related discussions and overlap
- Add /restart to reinitialize Codex and resume the current thread #37628 — Add /restart to reinitialize Codex and resume the current thread: substantial overlap. This issue adds the package-upgrade use case and an explicit requirement to load the new executable. It is not intended to suggest that the earlier request has already been accepted or rejected. Please consolidate into Add /restart to reinitialize Codex and resume the current thread #37628 if that is the preferred tracking issue.
- CLI: automatically relaunch after accepting the startup update prompt #48831 — Automatically relaunch after accepting the startup update prompt: related executable-handoff work, but scoped to startup before entering the intended interactive session. This request starts from an already-running conversation and must preserve its identity.
- feat(cli) Restart Codex after completing update flow #9240 — Restart Codex after completing update flow: a previous, unmerged implementation attempt. Its Windows launcher review is relevant when considering npm
.cmd/.batentrypoints.
Suggested validation
Exercise an A-to-B package upgrade followed by restart/resume; verify the running version, exact session ID, history, working directory, and terminal usability. Also cover relevant launch overrides, startup-prompt non-replay, clean shutdown, and an unavailable relaunch target. A Unix executable handoff and Windows npm launcher behavior should both be considered for a cross-platform implementation.
The installed package version and cited source were inspected. No real upgrade/restart experiment or local build/test was performed for this report; the above are proposed acceptance checks.
This is a feature/design request under the current contribution policy. @etraut-openai, could you help assess whether this fits the CLI lifecycle direction or route it to the appropriate maintainer?
Activity