Workflow definition

Errors

Everything a definition can be refused for, and the handful of refusals a run can produce. Almost all of them happen when you save — on purpose.

invalid_workflowrefused on savethe message names the step
Using Python?

Switch any code block to Python: the choice applies to every page. Python SDK guide and resource reference.

On save

One code, invalid_workflow (400), and a message naming the step and the problem. One code because there is one answer: fix the definition.

RefusedBecause
An unknown step typeThe message lists the 23.
A duplicate or malformed step idIds are what edges and templates name.
More than 30 stepsThe ceiling.
A missing required configurationNamed per type — a model, a URL, a storage, a path.
A template naming an unknown stepIt would read nothing.
A template naming a step that is not upstreamIt would always read nothing.
No edge from the trigger, or severalA workflow has one start.
A cycleThe graph must be acyclic.
An unreachable stepNamed, so you can see what was left dangling.
A condition without both branchesEvery path must be one somebody wrote.
A switch missing a case edge or defaultSame reason.
A merge with fewer than two inputsMerging one thing is not merging.
An unknown tool on agent.runThe message lists the ones that exist.
An action outside the account with no human step upstreamThere is nobody to ask during a run.
Why it is all on save

A workflow runs with nobody watching. A refusal while you are writing it is a message you read; the same problem at run time is a failed step in a log at three in the morning.

At run time

CodeWhereWhen
run_not_waitingresume()The run is not stopped at a human step.
run_not_retryableretry()It is still going, or a step before the chosen one did not succeed.
step_not_foundresume() · runStep()No such step.
step_not_executablerunStep()A human step has nothing to execute.
timeoutwait()The ceiling passed. The run keeps going.

A step that fails is not an exception

It is recorded on the step, with its message, and the run's status becomes failed. Nothing throws — reading run.data.status is how a failure is noticed.

await run.wait();

if (run.data.status === "failed") {
  const failed = run.data.steps.find((s) => s.status === "failed");
  console.error(failed.id, failed.error);
  await run.retry();
}
run.wait()

if run.data["status"] == "failed":
    failed = next(s for s in run.data["steps"] if s["status"] == "failed")
    print(failed["id"], failed["error"])
    run.retry()