Overview
Interrupts are the core primitive for human-in-the-loop workflows.
An interrupt:
- Pauses execution by raising an
Interrupt exception
- Surfaces a payload to the caller (what you want a human/system to review)
- Allows the workflow to be resumed later with a response value
Raising an interrupt
Use interrupt(value) inside a step when you need input to continue.
from coevolved.base.interrupt import interrupt
def require_approval(state: dict) -> dict:
if state["amount"] > 1000:
decision = interrupt({"question": "Approve?", "amount": state["amount"]})
return {**state, "approved": bool(decision.get("approved"))}
return {**state, "approved": True}
Keep interrupt payloads small and serializable. Treat them as UI/API-friendly messages, not full internal objects.
Resuming execution
When an interrupt is raised, you typically:
- capture the interrupt payload (including its
interrupt_id)
- ask a human (or another system) for a response
- resume by providing a value for that
interrupt_id
Coevolved provides helper functions for setting resume values in context.
Human-in-the-loop patterns
Common patterns built on interrupts:
- Approvals / policy gates
- “Review this draft” workflows
- Manual tool execution steps
- Escalation to an on-call / operator
Next steps