{"record":{"id":"b3d85f4dc59c276a","repo":"openai/codex-plugin-cc","slug":"no-previous-codex-task-thread-was-found-for-this-r","errorCode":null,"errorMessage":"No previous Codex task thread was found for this repository.","messagePattern":"No previous Codex task thread was found for this repository\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"plugins/codex/scripts/codex-companion.mjs","lineNumber":476,"sourceCode":"}\n\n\nasync function executeTaskRun(request) {\n  const workspaceRoot = resolveWorkspaceRoot(request.cwd);\n  ensureCodexAvailable(request.cwd);\n\n  const taskMetadata = buildTaskRunMetadata({\n    prompt: request.prompt,\n    resumeLast: request.resumeLast\n  });\n\n  let resumeThreadId = null;\n  if (request.resumeLast) {\n    const latestThread = await resolveLatestTrackedTaskThread(workspaceRoot, {\n      excludeJobId: request.jobId\n    });\n    if (!latestThread) {\n      throw new Error(\"No previous Codex task thread was found for this repository.\");\n    }\n    resumeThreadId = latestThread.id;\n  }\n\n  if (!request.prompt && !resumeThreadId) {\n    throw new Error(\"Provide a prompt, a prompt file, piped stdin, or use --resume-last.\");\n  }\n\n  const result = await runAppServerTurn(workspaceRoot, {\n    resumeThreadId,\n    prompt: request.prompt,\n    defaultPrompt: resumeThreadId ? DEFAULT_CONTINUE_PROMPT : \"\",\n    model: request.model,\n    effort: request.effort,\n    sandbox: request.write ? \"workspace-write\" : \"read-only\",\n    onProgress: request.onProgress,\n    persistThread: true,\n    threadName: resumeThreadId ? null : buildPersistentTaskThreadName(request.prompt || DEFAULT_CONTINUE_PROMPT)","sourceCodeStart":458,"sourceCodeEnd":494,"githubUrl":"https://github.com/openai/codex-plugin-cc/blob/db52e28f4d9ded852ab3942cea316258ae4ef346/plugins/codex/scripts/codex-companion.mjs#L458-L494","documentation":"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.","triggerScenarios":"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.","commonSituations":"New workspace, cleared state directory, or running under a new Claude session id that has no associated task history.","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."],"exampleFix":"// before\ncodex-companion.mjs task --resume-last\n// after\ncodex-companion.mjs task \"initial prompt\"   # creates a thread, then --resume-last works","handlingStrategy":"validation","validationCode":"const thread = await resolveLatestTrackedTaskThread(workspaceRoot);\nif (!thread) throw new Error('no prior thread');","typeGuard":"/** @param {{id: string}|null} t @returns {t is {id: string}} */\nfunction hasThread(t) { return t != null && typeof t.id === 'string'; }","tryCatchPattern":null,"preventionTips":["Run an initial task before using --resume-last.","Do not clear the state directory if you intend to resume."],"tags":["task","state","resume","not-found"],"backgroundTag":null,"analyzedSha":"db52e28f4d9ded852ab3942cea316258ae4ef346","analyzedAt":"2026-08-13T05:13:20.855Z","schemaVersion":2},"datasetVersion":"2026-08-13T09:17:06.757Z"}