Continuing a run
A run that ended without an answer, such as one at its turn limit, keeps what it did: its replies and
its calls' results. session.continue({ requestId }) starts a run on the session's context as it is,
without a new message, so the model carries on from where the run stopped, on the round's results:
const { id } = await instance.createSession({ maxTurns: 3 });
// ... a run ends with `run:end` and `code: "turn_limit"`: the user agrees to let it go on.
await instance.session(id).configure({ maxTurns: 10 });
await instance.session(id).continue({ requestId: crypto.randomUUID() });- It is pi-durable's continue. It starts a run only while none is going: a busy session rejects with
SessionBusyError(session_busy), and nothing is written. Inputs a failed run left waiting (pi-durable'safterFailedRun: "keep", its default) join the run it starts. - A context with nothing to answer, empty or ending in an answer, ends the run at once without a
model request:
run:endwithreason: "error"andcode: "nothing_to_answer". - It is idempotent on
requestId, assubmitis: a retry, also at once, returns the first continue'ssubmissionIdand starts nothing. - The run resolves the scope's models first, as
submitdoes. A child session refuses it withSessionOwnedError.
pi-durable's continue places no entry, so the stream could not tell from history alone where the
failed run ended and the continued one began. In the commit that admits a continue whose run takes no
waiting input, the runtime writes a motoko.continue entry (nothing the model reads) naming the
continue's submission. The stream shows that run as run:start there, then its replies and calls, and
its run:end, live and in history alike, and a cursor's run names that entry, as it names the user
entry of a run an input started (see Cursors). A run that takes waiting inputs starts at
the first of them, as any run does.