This example demonstrates the pattern and data flow used for breakpoints. In a real deployment the interrupt/continue primitives would be provided by the platform runtime.
Overview
The demo implements a lightweight pattern that:- Generates content.
- Interrupts execution and returns an interrupt payload for human review.
- Resumes execution using the reviewer’s decision and updates the workflow state.
- Breakpoint / Interrupt: the point where the workflow pauses and returns a payload for review.
- Resume: receiving an external decision and continuing execution from the same logical point.
- Workflow State: an object carrying the data that travels between nodes.
Setup and types
Begin with the necessary imports and the type that represents the workflow state. ThisReviewState carries the generated content, the approval decision, and a status flag.
InterruptRequest dataclass to represent a pause/interrupt. In a real runtime, invoking an interrupt would hand control back to the host with a payload describing what needs review.
Workflow nodes: generate, interrupt, resume
Below are the three main nodes in this simulated workflow: content generation, issuing an interrupt, and resuming based on a decision.State and function summary
Use the following table to quickly understand the state fields and the purpose of each function in this demo.Example run (end-to-end)
This block shows the full flow: initialize state, generate content, request review (interrupt), then resume after a simulated reviewer decision.How this maps to workflow runtimes
- The
InterruptRequestmodels the runtime interrupt object you would encounter when a node pauses for external input in a workflow system. - The
payloadcontains only the minimal necessary data for a human reviewer; in production this can be extended with metadata, links to artifacts, or audit IDs. - When the external decision returns, the workflow runtime or controller reconciles state and resumes processing from the same logical point, preserving idempotency and traceability.
- This pattern enables manual checks, approvals, gated deployments, or other human approvals within otherwise automated processes.
In production systems, interrupts are typically implemented as runtime primitives that persist state, emit events/notifications, and secure the review channel. Use this pattern to model human review gates while keeping your core workflow logic deterministic and resumable.
Links and references
- Kubernetes Documentation
- Workflow Patterns and Best Practices
- Designing Human-in-the-Loop Systems — Research and Guidelines