Skip to main content

Examples

// With cancellation
const { outputStream } = await graph.start(input);
setTimeout(() => outputStream.abort(), 5000); // Cancel after 5 seconds

for await (const result of outputStream) {
  // Processing will stop when abort() is called
}

Methods


Methods

next

next(): Promise<GraphOutputStreamResponse<any>>
Gets the next result from the execution.

Returns

Promise<GraphOutputStreamResponse<any>>

abort

abort(): void
Cancels the graph execution and stops processing. This method immediately aborts the ongoing graph execution, canceling any pending operations including LLM generation, TTS synthesis, and custom node processing. The cancellation propagates through the entire execution graph. Use Cases: - User-initiated cancellation (e.g., stop button) - Timeout handling - Early termination based on conditions - Resource cleanup Behavior: - Safe to call multiple times (subsequent calls are no-op) - Stops all async operations in the graph - Causes streams to end early - Triggers cancellation context in custom nodes (context.isCancelled)

Returns

void