openai/codex-plugin-cc · error · Error
No previous Codex task thread was found for this repository.
Error message
No previous Codex task thread was found for this repository.
What it means
In executeTaskRun, when request.resumeLast is true the code calls resolveLatestTrackedTaskThread to find a thread to continue. If that returns null (no resumable tracked task, no thread on disk, and no session-scoped thread), there is nothing to resume and the run aborts. This is distinct from the no-prompt error which follows.
Source
Thrown at plugins/codex/scripts/codex-companion.mjs:476
}
async function executeTaskRun(request) {
const workspaceRoot = resolveWorkspaceRoot(request.cwd);
ensureCodexAvailable(request.cwd);
const taskMetadata = buildTaskRunMetadata({
prompt: request.prompt,
resumeLast: request.resumeLast
});
let resumeThreadId = null;
if (request.resumeLast) {
const latestThread = await resolveLatestTrackedTaskThread(workspaceRoot, {
excludeJobId: request.jobId
});
if (!latestThread) {
throw new Error("No previous Codex task thread was found for this repository.");
}
resumeThreadId = latestThread.id;
}
if (!request.prompt && !resumeThreadId) {
throw new Error("Provide a prompt, a prompt file, piped stdin, or use --resume-last.");
}
const result = await runAppServerTurn(workspaceRoot, {
resumeThreadId,
prompt: request.prompt,
defaultPrompt: resumeThreadId ? DEFAULT_CONTINUE_PROMPT : "",
model: request.model,
effort: request.effort,
sandbox: request.write ? "workspace-write" : "read-only",
onProgress: request.onProgress,
persistThread: true,
threadName: resumeThreadId ? null : buildPersistentTaskThreadName(request.prompt || DEFAULT_CONTINUE_PROMPT)View on GitHub (pinned to db52e28f4d)
Solutions
- Run a task without --resume-last first to create an initial thread.
- Verify the workspace state directory contains task jobs with a threadId.
- If session filtering is the cause, ensure SESSION_ID_ENV matches the session that created the prior task.
Example fix
// before codex-companion.mjs task --resume-last // after codex-companion.mjs task "initial prompt" # creates a thread, then --resume-last works
Defensive patterns
Strategy: validation
Validate before calling
const thread = await resolveLatestTrackedTaskThread(workspaceRoot);
if (!thread) throw new Error('no prior thread'); Type guard
/** @param {{id: string}|null} t @returns {t is {id: string}} */
function hasThread(t) { return t != null && typeof t.id === 'string'; } Prevention
- Run an initial task before using --resume-last.
- Do not clear the state directory if you intend to resume.
When it happens
Trigger: First-ever task run in a repo with --resume-last, or after all prior task jobs were cancelled/failed without a threadId, or when the session id filter excludes all existing jobs and no global thread exists.
Common situations: New workspace, cleared state directory, or running under a new Claude session id that has no associated task history.
Related errors
- Task ${activeTask.id} is still running. Use /codex:status be
- No stored job found for ${options["job-id"]}.
- Unsupported reasoning effort "${effort}". Use one of: none,
- Provide a prompt, a prompt file, piped stdin, or use --resum
- Choose either --resume/--resume-last or --fresh.
AI-assisted analysis of openai/codex-plugin-cc@db52e28f4d (2026-08-13).
Data as JSON: /api/errors/b3d85f4dc59c276a.
Report an issue: GitHub.