shareAI-lab/learn-claude-code · error · WorkflowInputError

resume snapshot not found for {run_id}

Error message

resume snapshot not found for {run_id}

What it means

_read_snapshot(run_id) loads STORE/<run_id>.json; if the file does not exist it raises WorkflowInputError('resume snapshot not found for <run_id>'). Snapshots live under the module's .runtime directory and are what make resume possible, so a missing file means the run identity cannot be resumed on this machine.

Source

Thrown at s16_workflow_runtime/code.py:623

        })
        _save_last_run(run_id)
        task.event("task_notification", status=task.status,
                   agents=task.usage["agents"], tokens=task.usage["tokens"],
                   outputFile=f".runtime/{run_id}.output.json")
        return {"launched": launched, "result": result, "task": task}


def _write_json(path, value):
    path.parent.mkdir(parents=True, exist_ok=True)
    temporary = path.with_suffix(path.suffix + ".tmp")
    temporary.write_text(json.dumps(value, indent=2, default=str))
    os.replace(temporary, path)


def _read_snapshot(run_id):
    path = STORE / f"{run_id}.json"
    if not path.exists():
        raise WorkflowInputError(f"resume snapshot not found for {run_id}")
    try:
        snapshot = json.loads(path.read_text())
    except json.JSONDecodeError as exc:
        raise WorkflowInputError(f"invalid resume snapshot for {run_id}") from exc
    if not isinstance(snapshot, dict):
        raise WorkflowInputError(f"invalid resume snapshot for {run_id}")
    return snapshot


def _save_last_run(run_id):
    (STORE / "last_run.txt").write_text(run_id)


def _read_last_run():
    p = STORE / "last_run.txt"
    return p.read_text().strip() if p.exists() else None

View on GitHub (pinned to 985456f4ad)

Solutions

  1. Verify STORE/<run_id>.json exists (STORE is s16_workflow_runtime/.runtime) and the runId is copied exactly.
  2. If the snapshot is genuinely gone, re-run the workflow from scratch — resume is impossible without the snapshot.
  3. Persist/restore the .runtime directory (snapshot + journal together) when runs cross machines or CI steps.

Example fix

# before
await run_workflow("review", resume_from_run_id="wf_review_deadbeef")  # typo'd id

# after
rid = _read_last_run()  # or copy the exact id from the launch output
await run_workflow("review", resume_from_run_id=rid)
Defensive patterns

Strategy: validation

Validate before calling

from pathlib import Path
from s16_workflow_runtime import STORE, RUN_ID_RE
assert RUN_ID_RE.match(run_id), f"malformed runId: {run_id}"
snap = STORE / f"{run_id}.json"
if not snap.exists():
    raise FileNotFoundError(f"cannot resume: no snapshot at {snap}")

Type guard

def is_resumable(run_id: str) -> bool:
    return (STORE / f"{run_id}.json").exists()

Try / catch

try:
    await run_workflow(name, resume_from_run_id=rid)
except WorkflowInputError as e:
    if "snapshot not found" in str(e):
        return await run_workflow(name, args=args)  # cold start
    raise

Prevention

When it happens

Trigger: Calling run_workflow(..., resume_from_run_id=id) where id was never launched here, was launched in a different STORE directory, or the .runtime directory was cleaned.

Common situations: Resuming on a different machine/container than where the run executed; CI cleaning the workspace between jobs; a truncated or mistyped runId; STORE path resolved differently (module relocated).

Related errors


AI-assisted analysis of shareAI-lab/learn-claude-code@985456f4ad (2026-08-14). Data as JSON: /api/errors/54021f27984449e4. Report an issue: GitHub.