Cortex · API

resumeRun

resumeRun continues a run from a snapshot. A run paused for approval can be serialized with run.snapshot(), which returns plain JSON; resumeRun restores it in another process that has the same agent definition, emits approval-required again with a new approval id, and continues. The model’s turns are scripted; no model is called.

Gate and agent
const askFirst: ToolGate = (call) =>
  call.toolId === 'refund' ? { ask: { reason: 'A refund moves money.' } } : { allow: true };

const desk = defineAgent({
  id: 'desk',
  instructions: 'Help the member. Refund a booking when the member asks for it.',
  tools: [refund],
  toolGates: [askFirst],
});

const run = desk.run('Please refund my two seats for Saturday. Grace', { llm });
Run, step by step
Scripted model turn
calls refund {"booking":"B-2041","amount_cents":7600}
Event
{
  type: 'approval-required',
  approval: {
    toolId: 'refund',
    args: { booking: 'B-2041', amount_cents: 7600 },
    reason: 'A refund moves money.',
  },
}
Output matches the expected value

Runs in this page on the installed package. The input and the expected output are defined by the example.