How to Resume a Previous Rescue Task After Interruption in Codex
When you run /codex:rescue, the plugin automatically detects existing Codex rescue threads and prompts you to continue or start fresh, or you can bypass the prompt by adding --resume or --fresh flags directly to the command.
The openai/codex-plugin-cc plugin provides a seamless way to pick up where you left off after interrupting a Codex rescue session. When you invoke the /codex:rescue command, the system checks for active threads and offers intelligent continuation options. Understanding the resume mechanism ensures you never lose context when switching between tasks or recovering from an interrupted session.
Automatic Detection of Resumable Threads
Before launching a new rescue operation, the command checks for existing state. This prevents accidental overwrites of in-progress work.
Querying for Active Rescue Sessions
The detection logic resides in plugins/codex/commands/rescue.md. When you execute /codex:rescue, the plugin first runs:
node "${CLAUDE_PLUGIN_ROOT}/scripts/codex-companion.mjs" task-resume-candidate --json
This returns a JSON object indicating whether a Codex rescue thread is still alive for the current repository. When available: true, the plugin knows a previous session exists and can be resumed.
Interactive User Prompts
If the script detects a resumable thread, the command issues an AskUserQuestion prompt offering two distinct choices:
- Continue current Codex thread (recommended when your wording suggests "continue", "resume", or "apply the top fix")
- Start a new Codex thread (recommended for entirely new tasks)
Routing Flags Through the Sub-Agent
Once you make a selection (or provide explicit flags), the system routes your request through the codex-rescue sub-agent defined in plugins/codex/agents/codex-rescue.md.
Flag Translation Logic
The sub-agent translates your choice into arguments for the companion script:
- Selecting Continue adds
--resume, which becomes--resume-lastwhen callingcodex-companion.mjs - Selecting Start a new thread adds
--fresh, which invokes the script without resume flags
The sub-agent then executes a single Bash call:
node "${CLAUDE_PLUGIN_ROOT}/scripts/codex-companion.mjs" task <flags> <natural-language-prompt>
The raw stdout from the companion script returns verbatim to you, preserving Codex's original output without additional commentary.
Manual Resume with Explicit Flags
If you already know your intent, you can skip the interactive prompt by appending flags directly to the /codex:rescue command.
Use --resume to explicitly continue the most recent thread:
/codex:rescue --resume investigate flaky test
Use --fresh to force a brand-new thread, discarding any previous state:
/codex:rescue --fresh investigate flaky test
Practical Code Examples
Here are common patterns for managing rescue session continuity:
# Let the plugin decide (prompts you if a thread exists)
/codex:rescue investigate flaky test
# Explicitly continue the most recent thread
/codex:rescue --resume investigate flaky test
# Explicitly start a new thread, discarding any previous state
/codex:rescue --fresh investigate flaky test
# Run the rescue in the background while you keep working
/codex:rescue --background --resume investigate flaky test
Summary
- The
/codex:rescuecommand automatically detects resumable threads usingcodex-companion.mjs task-resume-candidate --json - When a pending session exists, the plugin prompts you to continue or start fresh via
AskUserQuestion - The
codex-rescuesub-agent translates--resumeto--resume-lastand--freshto no-resume-flag when calling the companion script - Append
--resumeor--freshto bypass prompts and control session behavior explicitly - Background execution works with resume flags for multitasking scenarios
Frequently Asked Questions
What happens if I don't specify --resume or --fresh?
If you run /codex:rescue without explicit flags, the plugin executes the resume candidate check. When an active thread exists, it prompts you interactively to choose between continuing the existing session or starting fresh. If no resumable thread exists, it automatically starts a new session.
Where is the resume logic implemented in the source code?
According to the openai/codex-plugin-cc source code, the detection logic resides in plugins/codex/commands/rescue.md, which handles the task-resume-candidate query and user prompting. The flag translation and execution logic lives in plugins/codex/agents/codex-rescue.md, where the sub-agent forwards requests to codex-companion.mjs.
Can I resume a rescue task while running other Claude Code operations?
Yes. Use the --background flag combined with --resume to continue a previous rescue session without blocking your terminal. This allows the Codex companion script to run independently while you execute other commands.
What's the difference between --resume and --fresh at the companion script level?
As implemented in openai/codex-plugin-cc, --resume becomes --resume-last when passed to codex-companion.mjs task, which instructs Codex to load the previous conversation state. The --fresh flag results in no resume argument being passed, forcing Codex to initialize a completely new task context.
Have a question about this repo?
These articles cover the highlights, but your codebase questions are specific. Give your agent direct access to the source. Share this with your agent to get started:
curl -s "https://instagit.com/install.md" Maintain an open-source project? Get it listed too →