{"record":{"id":"5d9673bf4e2d3170","repo":"coleam00/Archon","slug":"cannot-actively-cancel-run-with-status-current","errorCode":null,"errorMessage":"Cannot actively cancel run with status '${current.status}'. Only a running detached CLI run has live work to stop.","messagePattern":"Cannot actively cancel run with status '(.+?)'\\. Only a running detached CLI run has live work to stop\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/cli/src/commands/workflow.ts","lineNumber":4395,"sourceCode":" * tree, then record `cancelled`. An unreachable owner never falls back to a DB-only\n * transition — operators use `abandon` separately after verifying an orphan.\n */\nexport async function workflowCancelCommand(\n  runId: string,\n  json?: boolean,\n  cwd?: string\n): Promise<void> {\n  const cancel = async (): Promise<{\n    resolvedId: string;\n    workflowName: string;\n    cascadeFailures: number;\n    blockedParentRunId: string | null;\n  }> => {\n    const resolvedId = await resolveRunIdArg(runId, cwd);\n    const current = await workflowDb.getWorkflowRun(resolvedId);\n    if (!current) throw new Error(`Workflow run not found: ${resolvedId}`);\n    if (current.status !== 'running') {\n      throw new Error(\n        `Cannot actively cancel run with status '${current.status}'. Only a running detached CLI run has live work to stop.`\n      );\n    }\n\n    let containerEnvId: string | undefined;\n    if (current.metadata?.isolation === 'container') {\n      const isolationEnvId = current.metadata.isolation_env_id;\n      if (typeof isolationEnvId !== 'string' || isolationEnvId.trim().length === 0) {\n        throw new Error(\n          `Cannot confirm the isolation container owned by run ${resolvedId}. ` +\n            'The run was not changed; its container tracking ID is missing.'\n        );\n      }\n      containerEnvId = isolationEnvId;\n      const containerEnv = await isolationDb.getById(containerEnvId);\n      if (containerEnv?.provider !== 'container') {\n        throw new Error(\n          `Cannot confirm the isolation container owned by run ${resolvedId}. ` +","sourceCodeStart":4377,"sourceCodeEnd":4413,"githubUrl":"https://github.com/coleam00/Archon/blob/0773b9745896ef0612e709c80845a0f7db315b19/packages/cli/src/commands/workflow.ts#L4377-L4413","documentation":"The active-cancel operation only stops live detached CLI work, so it refuses runs whose status is not `running`. A run in `completed`, `failed`, `cancelled`, `paused`, etc. has no live process to stop; the run state is left untouched.","triggerScenarios":"Calling `archon workflow cancel <id>` on a run whose `status !== 'running'` — e.g. cancelling an already-finished or already-cancelled run, or a paused/gated run.","commonSituations":"Double-cancelling after a prior cancel succeeded; trying to cancel a run that already completed while you read an old status; attempting to use cancel on a waiting-on-gate run that needs `approve`/`reject` instead.","solutions":["Check the run's current status (`archon workflow status <id>`); if it is finished/cancelled, no action is needed","For a gated/paused run use the appropriate command (`approve`/`reject`) instead of cancel","Only actively cancel runs that show `running` with a live detached owner process"],"exampleFix":"// before\nawait cancelWorkflow(runId);\n// after\nconst run = await getWorkflowRun(runId);\nif (run.status === 'running') await cancelWorkflow(runId);\nelse console.log(`run is ${run.status}; nothing to cancel`);","handlingStrategy":"validation","validationCode":"const run = await workflowDb.getWorkflowRun(id);\nif (run?.status !== 'running') {\n  console.log(`run is ${run?.status}; only running detached runs can be actively cancelled`);\n  return;\n}\nawait cancelWorkflow(id);","typeGuard":"const isRunning = (r: { status: string }): boolean => r.status === 'running';","tryCatchPattern":null,"preventionTips":["Check current run status before cancelling","Use approve/reject for gated or paused runs, not cancel","Treat cancel as idempotent-no-op for terminal states in scripts"],"tags":["cli","workflow","cancel","invalid-state"],"backgroundTag":"invalid-state-transition","analyzedSha":"0773b9745896ef0612e709c80845a0f7db315b19","analyzedAt":"2026-09-01T02:28:07.064Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T05:18:18.240Z"}