{"record":{"id":"baefcd38545ec2cf","repo":"tinyhumansai/openhuman","slug":"workflow-run-id-is-already-completed","errorCode":null,"errorMessage":"workflow run {id} is already completed","messagePattern":"workflow run (.+?) is already completed","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/openhuman/agent/orchestration/workflow_runs/engine.rs","lineNumber":296,"sourceCode":"    log::debug!(target: LOG_TARGET, \"[workflow_run_engine] stop.marked_interrupted run={id}\");\n    Ok(Some(updated))\n}\n\n/// Resume an interrupted (or otherwise incomplete) workflow run.\n///\n/// Reloads the run, clears any stale cancellation flag, flips the row back to\n/// `Running`, and spawns a fresh engine loop. Phases already `completed` in\n/// `phase_states` are skipped; the loop continues from the first incomplete\n/// phase whose dependencies are satisfied. Returns the run row (now `Running`),\n/// or an error if the run is unknown / already terminal-complete / its\n/// definition no longer exists.\npub async fn resume_workflow_run(config: &Config, id: &str) -> Result<WorkflowRun> {\n    log::debug!(target: LOG_TARGET, \"[workflow_run_engine] resume.entry run={id}\");\n    let run = get_workflow_run(&config.workspace_dir, id)?\n        .ok_or_else(|| anyhow!(\"unknown workflow run: {id}\"))?;\n\n    if matches!(run.status, WorkflowRunStatus::Completed) {\n        return Err(anyhow!(\"workflow run {id} is already completed\"));\n    }\n\n    let definition = definition_by_id(&run.definition_id)\n        .ok_or_else(|| anyhow!(\"definition {} no longer exists\", run.definition_id))?;\n\n    // Clear any prior cancellation intent and re-register a fresh flag.\n    clear_cancel_flag(id);\n    register_cancel_flag(id);\n\n    let resumed = upsert_workflow_run(\n        &config.workspace_dir,\n        WorkflowRunUpsert {\n            id: run.id.clone(),\n            definition_id: run.definition_id.clone(),\n            parent_thread_id: run.parent_thread_id.clone(),\n            input: run.input.clone(),\n            phase_states: run.phase_states.clone(),\n            child_run_ids: run.child_run_ids.clone(),","sourceCodeStart":278,"sourceCodeEnd":314,"githubUrl":"https://github.com/tinyhumansai/openhuman/blob/749120085864ce16e0f273c7b86fac7740b39c5b/src/openhuman/agent/orchestration/workflow_runs/engine.rs#L278-L314","documentation":"resume_workflow_run refuses to resume a run whose persisted status is already terminal-complete. Resume is only valid for interrupted/incomplete runs; a completed run's phases are all done, so 'resuming' would be a no-op that misleadingly flips status back to Running. The ledger row is the faulting state.","triggerScenarios":"Thrown at src/openhuman/agent/orchestration/workflow_runs/engine.rs:296 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Start a new run of the same definition instead of resuming the completed one","If a re-run of specific phases is needed, model it as a new workflow or use the definition's phase inputs","Fix the caller that is holding a stale run status"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"749120085864ce16e0f273c7b86fac7740b39c5b","analyzedAt":"2026-08-17T21:21:45.363Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}