tinyhumansai/openhuman · error

workflow run is already completed

Error message

workflow run {id} is already completed

What it means

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.

Solutions

  1. Start a new run of the same definition instead of resuming the completed one
  2. If a re-run of specific phases is needed, model it as a new workflow or use the definition's phase inputs
  3. Fix the caller that is holding a stale run status
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at src/openhuman/agent/orchestration/workflow_runs/engine.rs:296 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of tinyhumansai/openhuman@7491200858 (2026-08-17). Data as JSON: /api/errors/baefcd38545ec2cf. Report an issue: GitHub.

Appendix: source

Thrown at src/openhuman/agent/orchestration/workflow_runs/engine.rs:296

    log::debug!(target: LOG_TARGET, "[workflow_run_engine] stop.marked_interrupted run={id}");
    Ok(Some(updated))
}

/// Resume an interrupted (or otherwise incomplete) workflow run.
///
/// Reloads the run, clears any stale cancellation flag, flips the row back to
/// `Running`, and spawns a fresh engine loop. Phases already `completed` in
/// `phase_states` are skipped; the loop continues from the first incomplete
/// phase whose dependencies are satisfied. Returns the run row (now `Running`),
/// or an error if the run is unknown / already terminal-complete / its
/// definition no longer exists.
pub async fn resume_workflow_run(config: &Config, id: &str) -> Result<WorkflowRun> {
    log::debug!(target: LOG_TARGET, "[workflow_run_engine] resume.entry run={id}");
    let run = get_workflow_run(&config.workspace_dir, id)?
        .ok_or_else(|| anyhow!("unknown workflow run: {id}"))?;

    if matches!(run.status, WorkflowRunStatus::Completed) {
        return Err(anyhow!("workflow run {id} is already completed"));
    }

    let definition = definition_by_id(&run.definition_id)
        .ok_or_else(|| anyhow!("definition {} no longer exists", run.definition_id))?;

    // Clear any prior cancellation intent and re-register a fresh flag.
    clear_cancel_flag(id);
    register_cancel_flag(id);

    let resumed = upsert_workflow_run(
        &config.workspace_dir,
        WorkflowRunUpsert {
            id: run.id.clone(),
            definition_id: run.definition_id.clone(),
            parent_thread_id: run.parent_thread_id.clone(),
            input: run.input.clone(),
            phase_states: run.phase_states.clone(),
            child_run_ids: run.child_run_ids.clone(),

View on GitHub (pinned to 7491200858)