Studio previewSelf-host Studio locally.Run it
Everyday workflow / Refund review

An agent recommends. A person decides.

A support agent loads order #4831, checks the return policy, streams a typed recommendation, and waits for approval before it issues the refund.

Read interrupts and resume

Refund request #4831

MAYA LOPEZ · 12 DAYS SINCE DELIVERY

NEEDS APPROVAL

Customer message

“I received the US keyboard layout instead of the Spanish one. The box is still sealed. Can I get a refund?”

Order total$84.00
ConditionUnopened
Agent recommendation

Eligible for a full refund

The request is inside the 30-day window and the item is unopened. Refund to the original payment method.

Issue $84.00 refund?

ApproveEscalate

What happens in the runtime

A refund passes through five named steps.

01

Find the order

A tool loads order #4831 from the application service.

02

Check policy

A focused node compares delivery date, condition, and return rules.

03

Draft decision

useReason streams a schema-validated recommendation into React.

04

Ask a person

The run checkpoints before money moves or product data changes.

05

Resume and refund

The approved run continues once and records the final outcome.

Human input in one node

The external write happens after approval.

Resume replays node code from a checkpoint. Keep side effects after the interrupt or protect them with an idempotency key. useInterrupt marks that checkpoint in the node.

approve-refund.node.ts
// approve-refund.node.ts
const action = await useInterrupt({
  id: "refund-approval",
  request: {
    kind: "choice",
    question: "Issue the $84 refund?",
    options: [approve, escalate],
  },
});

return {
  condition: action,
  data: { orderId, action },
};

Runtime events in the interface

React renders the state of the active run.

Tools

Load the order through request-scoped tools or an application service.

Typed output

Validate the recommendation before it appears as product state.

Interrupts

Tie the approval control to the exact checkpoint and request.

Side effects

Issue the refund after the resumed run reaches the write node.

Session history

Rollback and fork the server workflow together with the visible messages.

Larger open-source example

Canvas adds custom pickers, structured editors, and routing across several workflows.

Browse Canvas source

Replace the refund policy with one of your own.

Connect your services to the same workflow, interrupt, and resume APIs used in this example.