Skip to content

Add /restart to reinitialize Codex and resume the current thread #37628

Open

Description

@harunaOseni

What variant of Codex are you using?

CLI / TUI

What feature would you like to see?

Add a /restart slash command that performs the equivalent of:

  1. Running /quit and completing the normal shutdown sequence.
  2. Relaunching Codex in the same working directory.
  3. Resuming the current thread automatically.

Some MCP servers occasionally fail to initialize, load their tools, or begin working within an active Codex session. Even when the MCP configuration is correct, the only reliable recovery is often to:

  1. Quit Codex.
  2. Relaunch it from the same directory.
  3. Resume the same session manually.

After relaunching, the affected MCP tools load and work normally. This workaround requires several unnecessary steps just to restore the MCP tools.

The /restart command should:

  • wait for normal session shutdown and cleanup;
  • preserve the current working directory;
  • resume the same thread and conversation context;
  • reinitialize components normally initialized during startup, including MCP connections;
  • avoid replaying the original prompt or attached images;
  • avoid requiring the user to find and select the session manually.

This differs from /new, which starts a new conversation. /restart should preserve the current conversation while providing the same recovery behavior as quitting Codex, relaunching it, and resuming the session.

Additional information

A similar request was opened in #33370, but that discussion was clarified as requesting a fresh conversation context while retaining the existing process.

This proposal has the opposite session behavior: preserve the current thread and context while performing the equivalent of a clean quit and resume.

I have a tested implementation available on the feat/restart-session branch of my fork and would be happy to submit a pull request if the Codex team would like the contribution.

Activity

  1. added
    enhancement
    CLI
    mcp
    TUI
    session
    on Aug 8, 2026
  2. nikoisthebest commented on Sep 20, 2026

    @nikoisthebest

    +1 for this feature.

    I use Codex in long-running development sessions on a fairly complex local AI project. There are cases where startup-initialized components, especially MCP connections or other integrations, need to be fully reinitialized, while the current Codex thread and its accumulated context are still valuable.

    Today the recovery flow is essentially:

    /quit → restart Codex from the same working directory → find/resume the previous session.

    A /restart command that performs a clean shutdown, reinitializes the runtime/MCP layer, and automatically resumes the same thread would make this much safer and more practical.

    For long-running engineering sessions, preserving the existing context is important — starting /new is not equivalent.

    I would use this regularly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    CLITUIenhancementmcpsession

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions