The value to include in the interrupt. This will be available in task.interrupts[].value
The resume value provided when the graph is re-invoked with a Command
// Define a node that uses multiple interrupts
const nodeWithInterrupts = () => {
// First interrupt - will pause execution and include {value: 1} in task values
const answer1 = interrupt({ value: 1 });
// Second interrupt - only called after first interrupt is resumed
const answer2 = interrupt({ value: 2 });
// Use the resume values
return { myKey: answer1 + " " + answer2 };
};
// Resume the graph after first interrupt
await graph.stream(new Command({ resume: "answer 1" }));
// Resume the graph after second interrupt
await graph.stream(new Command({ resume: "answer 2" }));
// Final result: { myKey: "answer 1 answer 2" }
Interrupts the execution of a graph node. This function can be used to pause execution of a node, and return the value of the
resumeinput when the graph is re-invoked usingCommand. Multiple interrupts can be called within a single node, and each will be handled sequentially.When an interrupt is called:
resumevalue available (from a previousCommand), it returns that value.GraphInterruptwith the provided valueCommandwith aresumevalueBecause the
interruptfunction propagates by throwing a specialGraphInterrupterror, you should avoid usingtry/catchblocks around theinterruptfunction, or if you do, ensure that theGraphInterrupterror is thrown again within yourcatchblock.