{"record":{"id":"6ab0d399f09ce965","repo":"openai/codex-plugin-cc","slug":"multiple-codex-jobs-are-active-pass-a-job-id-to","errorCode":null,"errorMessage":"Multiple Codex jobs are active. Pass a job id to /codex:cancel.","messagePattern":"Multiple Codex jobs are active\\. Pass a job id to /codex:cancel\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"plugins/codex/scripts/lib/job-control.mjs","lineNumber":300,"sourceCode":"  const workspaceRoot = resolveWorkspaceRoot(cwd);\n  const jobs = sortJobsNewestFirst(listJobs(workspaceRoot));\n  const activeJobs = jobs.filter((job) => job.status === \"queued\" || job.status === \"running\");\n\n  if (reference) {\n    const selected = matchJobReference(activeJobs, reference);\n    if (!selected) {\n      throw new Error(`No active job found for \"${reference}\".`);\n    }\n    return { workspaceRoot, job: selected };\n  }\n\n  const sessionScopedActiveJobs = filterJobsForCurrentSession(activeJobs, options);\n\n  if (sessionScopedActiveJobs.length === 1) {\n    return { workspaceRoot, job: sessionScopedActiveJobs[0] };\n  }\n  if (sessionScopedActiveJobs.length > 1) {\n    throw new Error(\"Multiple Codex jobs are active. Pass a job id to /codex:cancel.\");\n  }\n\n  if (getCurrentSessionId(options)) {\n    throw new Error(\"No active Codex jobs to cancel for this session.\");\n  }\n\n  throw new Error(\"No active Codex jobs to cancel.\");\n}\n","sourceCodeStart":282,"sourceCodeEnd":309,"githubUrl":"https://github.com/openai/codex-plugin-cc/blob/db52e28f4d9ded852ab3942cea316258ae4ef346/plugins/codex/scripts/lib/job-control.mjs#L282-L309","documentation":"Thrown by resolveCancelableJob() when no reference is supplied and more than one active job exists in the current session. The function refuses to pick one arbitrarily; it demands disambiguation. Guards against cancelling the wrong job.","triggerScenarios":"Calling resolveCancelableJob(cwd) (no ref) — i.e. `/codex:cancel` with no id — when two or more jobs in the session are queued or running.","commonSituations":"Multiple parallel Codex jobs launched in one session; a prior job left lingering in queued state while a new one started; forgetting to pass the job id to /codex:cancel.","solutions":["Pass the specific job id: /codex:cancel <id> (find it via /codex:status).","If you genuinely want to stop all of them, cancel each by id in turn.","Avoid launching overlapping jobs in the same session, or always pass an explicit id."],"exampleFix":"// before\nresolveCancelableJob(cwd); // >1 active\n\n// after\nresolveCancelableJob(cwd, \"abc123\");","handlingStrategy":"validation","validationCode":"function activeJobCount(jobs, options) {\n  return filterJobsForCurrentSession(\n    jobs.filter((j) => [\"queued\", \"running\"].includes(j.status)),\n    options\n  ).length;\n}\n\nconst n = activeJobCount(listJobs(workspaceRoot), options);\nif (n > 1) {\n  throw new Error(`${n} active jobs — pass a specific id to disambiguate.`);\n}","typeGuard":null,"tryCatchPattern":"try {\n  resolveCancelableJob(cwd);\n} catch (err) {\n  if (/Multiple Codex jobs are active/.test(err.message)) {\n    const snap = buildStatusSnapshot(cwd);\n    console.log(snap.running.map((j) => j.id).join(\"\\n\")); // present choice\n  } else throw err;\n}","preventionTips":["Always pass an explicit job id to /codex:cancel when more than one job may be active.","Avoid launching overlapping jobs in the same session.","Surface active job ids in the UI before offering a cancel action."],"tags":["job-control","disambiguation","codex","cancel"],"backgroundTag":null,"analyzedSha":"db52e28f4d9ded852ab3942cea316258ae4ef346","analyzedAt":"2026-08-13T05:13:20.855Z","schemaVersion":2},"datasetVersion":"2026-08-13T09:17:06.757Z"}