resume

suspend fun resume(entries: List<UiResumeEntry>, parameters: RunAgentParameters? = null): RunState

Answers what the last run stopped to ask for, and runs the agent.

This is how a client continues an interrupted thread. entries must cover every interrupt in pendingInterrupts -- each answered, or explicitly abandoned -- and name nothing else; the protocol rejects a resuming input that leaves one uncovered rather than letting a run proceed past a question nobody answered, and this throws before the run starts for the same reason. Omitting an interrupt is not abandoning it: abandon with UiResumeEntry.cancelled.

Whether an interrupt has expired is not judged here. The protocol leaves the format of expiresAt to the producer and the judgment to the consumer; a producer that will not take a late answer says so by failing the run, which this returns as a RunState.Failed.

The history sent is the agent's own, as run sends it, with any tool result an earlier run failed to carry placed after its call: a client that executed a tool while the thread was interrupted has a result to deliver, and this is the first run that can deliver it. A run that fails leaves the thread interrupted and the answers owed. Either retry works: run carries the answers the failed run carried, and a second resume carries whatever it is given -- the questions are still open, so answering them again is not answering them twice, and a reader who clicks Approve a second time is doing the natural thing.

With a tools registry, a run that calls one of its tools is answered by another run, and this returns the state the last of those ended in; see the class note.

Parameters

entries

one answer per pending interrupt.

parameters

as for run.

Throws

when the thread is not interrupted, or when entries leaves a pending interrupt uncovered -- the thread's state is what the entries fail to match.

when entries names an interrupt that is not pending, or names one twice.