Fix and continue
On this page
A run stopped halfway: a library threw, the program divided by zero, or someone pressed Ctrl-C. You don't have to start again and risk sending the email or charging the card a second time. A stopped run keeps every call it made and every answer it got, including answers that arrive while it is stopped, and only you continue it (history). Fix what went wrong and continue the same run, under the same keys, so nothing that already happened happens again by accident.
Find out why it stopped
flow run exits with code 3 when a run stops, and prints the reason, the
run's id and its open calls
(execution). flow runs shows
the same for every run. Each reason is spelled as --json spells it, and
the stop reasons
list them all:
| Reason | What it means | Usual fix |
|---|---|---|
asked |
Ctrl-C, flow stop, or another run's runs.stop |
flow resume RUN |
tool-bug |
a library gave no answer: an undeclared exception, a value that does not fit its type, or its process ended while the call was out | fix the library, find out what the call did, then resend it |
fault |
the program itself faulted, such as a division by zero | fix the program, then resume |
working |
the host stopped a program that looped without calling a Tool | fix the loop, then resume |
host |
the host stopped the run for a cause of its own, which it names in words: with the reference host, its evaluator's process ended, or the host was stopped or restarted and lost the run's environment | flow resume RUN from a shell with that environment |
outer |
a child run whose starter stopped, or whose driving call was closed | resume the starter |
A run that only waits for replies has no reason: it is waiting, and nothing is wrong with it.
Fix a bug in a library
When a library raises an exception it didn't declare, its call stays open and the run stops with the call and the error. Flow decides nothing for you: the call might have done its work before the exception, or not.
- Read the error, and fix the library:
flow logs RUN - Decide what to do with the open call.
- If the library recognises the call's key, or the call had no effect, send
it again:
flow resume RUN --resend 'root#7' - If you know what happened, the answer still comes from the library: an
answer enters a run only through a Tool. Make the fixed library find it,
for example by looking the call's key up at the service it calls, then
resend the call as above and it answers with what it finds. A library that
cannot find out says so with
Interrupted, which is what the program handles as an uncertain effect. A library whose own receiver replies by key can also answer from a short script with the toolkit'sreplyon the daemon's socket, for a run kept inFLOW_HOME/runs(people and webhooks). The key is the run's full id and the call, asflow show RUNprints it.
- If the library recognises the call's key, or the call had no effect, send
it again:
Resume restarts a library whose source changed since the run last started it,
so the resent call reaches the fixed code. --resend with no call sends every
open call that a library isn't holding, and the CLI lists them first
(execution).
Fix a fault in the program
A fault, such as a division by zero or waiting on a stopped task, stops the whole run where it happened. Fix the code, then resume:
flow resume RUNResume reads the edited file. It re-runs the program against the record, serving every answer it already has, and goes live where the record ends. The calls the run made before the fault aren't made again.
Continue on an edit the run has passed
An edit can change what the run already did: a different prompt in a round that has already run, or a removed call. Resume fits the new program to the whole record and continues only if the new program makes every recorded call the same way: at the same place, with the same Tool, the same types and equal arguments. The first call it makes differently refuses the resume, and nothing is written (history). A call the run already answered is never made again by a resume onto an edit.
- Try the edit with a dry run. It says whether the program reproduces the
record, or where it first differs, and writes nothing:
flow replay RUN app.flow - If it differs, make the edit leave the past alone. Gate the new
behaviour on data the run already has, such as
if day >= 4, so the rounds already run compute what they recorded. Or read the behaviour that changes through a Tool call: the recorded answers stay what they were, and later calls get the new ones. - Resume. One kind of call can be replaced: a call still open at the end of
its task, such as a long wait the edit no longer makes. Resume lists such
calls and refuses until you name exactly those with
--drop:flow resume RUN --drop 'root#9'
A dropped call is closed, and nobody can answer it afterwards. Its implementation is told, but it may already have acted, and a call the new program makes in its place is a new call with a new key.
The entry function must keep its name, its parameter types and its result type. If any of them changes, the run can't continue on the edit.
Fork instead
Continuing changes the run. To try something and leave the run as it is, fork it:
flow resume RUN --from 12 --name try-shorter-promptThe fork is a new run that starts as a copy of the first 12 facts and
continues on the program on disk, edited or not, which must reproduce those
facts. Every call the original recorded after fact 12 may already have had
its effect, and the fork may make it again, so the fork lists those calls and
starts only when you name exactly them with --drop. It has its own id, so
every key in it is new:
- a reply to the original never reaches the fork;
- a call that was open at fact 12 stays open in the fork until you answer or resend it there;
- the original stays where it was.
To redo a model's answer you didn't like, fork from just before its call and drop it. The fork makes the call again, under its own key.
Exact rules: open calls, continuing on edited code, forks, stopping, resume, replay.