Can I continue this Format run? A previous_run_id check in Python

A run can be continued with previous_run_id only if it has a thread_id and is completed or has artifacts. Check first, or handle four named errors.

4 min readSume
All posts

To continue a Format run, send its id as previous_run_id. The old run needs a non-null thread_id and must be either completed or hold artifacts; otherwise the API answers with one of four named errors.

Do not send a thread id yourself: the body field is rejected as unknown_parameter, because the thread comes from the earlier run.

The four refusals

From the Create a run page (read 2026-10-03).

Errors for a bad previous_run_id (read 2026-10-03)
Status and codeCauseFix
404 previous_run_not_foundUnknown id, or not visible to this keyCheck the id and workspace
400 previous_run_format_mismatchThe run belongs to a different FormatPost to the Format that made it
409 previous_run_not_terminalThe earlier run is still activePoll until it ends, then retry
400 previous_run_not_resumableNo thread, or nothing completed or producedStart a fresh run

The pre-check

Fetch the receipt and test it. A terminal run that is failed or canceled can still be continued if it produced artifacts, which is what makes partial assemblies recoverable.

TERMINAL = {"completed", "failed", "canceled", "skipped"}

def can_continue(run):
    if run.get("thread_id") is None:
        return False, "no thread"
    if run["status"] not in TERMINAL:
        return False, "still running"
    if run["status"] == "completed" or run.get("artifacts"):
        return True, "ok"
    return False, "nothing to resume"

print(can_continue({"thread_id": "t", "status": "failed", "artifacts": [{}]}))
print(can_continue({"thread_id": None, "status": "completed"}))

Use it with an idempotency key

Derive the key for the continuation from the previous run id and your instruction, so a retry does not branch twice. The earlier case is in continuing an incomplete assembly.

Sources

Related posts

More in Formats

All Formats posts

Written by Sume