Overview
The ctx object provides workflow control methods that help you manage execution timing and optimize resource usage.
Methods
sleep()
Pause execution for a specified duration.
ctx.sleep(milliseconds: number): Promise<void>
Example:
await ctx.sleep(1000); // Sleep for 1 second
halt()
Signal to the workflow orchestrator that this column’s result makes all other columns in the row pointless. This helps the system avoid wasted parallel work.
ctx.halt(reason?: string): void
halt() should only be used AFTER expensive operations when the result disqualifies the entire row. Don’t use it for simple validation or early returns.
Example:
const analysis = await services.ai.generateObject({
prompt: `Analyze if ${companyName} is in our ICP`,
schema: z.object({ isICP: z.boolean() }),
});
if (!analysis.object.isICP) {
ctx.halt("Not in ICP");
return false;
}