Skip to main content

run_resume

Function run_resume 

Source
pub async fn run_resume(
    __arg0: State<AppState>,
    __arg1: Path<String>,
) -> Result<(StatusCode, Json<RunResumeResponse>), ApiError>
Expand description

POST /v1/runs/:id/resume. Resumes an Interrupted Run under the SAME run_id (no new RunId is minted): the stored launch-input snapshot (RunRecord.input_json) is rebuilt into a TaskApplicationInput, a ReplayCursor is built from the Run’s logged step snapshots (ReplayStore::list_by_run), and the flow is re-dispatched with both wired into a fresh RunContext. On dispatch the engine’s replay path returns each already-completed step’s stored value verbatim (cursor hit, no Adapter spawn) and dispatches only the steps that never finished — reconstructing the same final Ctx a restart-free run would have reached.

Status codes:

  • 404 — no Run with this id.
  • 409 — the Run is not Interrupted (already Running / Done / Failed / Pending), OR a concurrent resume already won the Interrupted -> Running compare-and-set (double-resume guard).
  • 422 — the Run has no recorded launch-input snapshot, so it cannot be resumed (an older row predating resume support, or a path that does not persist one).
  • 202 Accepted — resume accepted; the flow re-runs in a detached background task (same tokio::spawn + run-TTL ceiling shape as a detached rekick). Poll GET /v1/runs/:id for the terminal status.

The launch-input decode and the 422 check run BEFORE the compare-and-set so a non-resumable Run is never flipped to Running and stranded without a driver behind it.