cancel_workflow
Cancel a workflow to move it to the terminal CANCELLED state. Use when an approval is rejected or a plan is flagged as unsafe, preventing future execution.
Instructions
[WRITE] Cancel a workflow — move it to the terminal CANCELLED state.
Use this when an approval is REJECTED, a review flags the plan as unsafe, or an operator decides the workflow must never run. A cancelled workflow is dead: run_workflow and approve refuse to execute it. Without this, an approval-rejected PENDING workflow could still be picked up and run.
Cancel only stops FUTURE steps. It does NOT undo already-completed steps — use rollback() to reverse those. Cancel is valid only from a non-terminal state; cancelling an already completed/failed/cancelled workflow returns a teaching error. The cancellation is written to the workflow audit log.
Args: workflow_id: The workflow ID to cancel. reason: Optional human-readable reason (e.g. "approval rejected by on-call"), recorded in the audit log.
Returns: Updated workflow state (state='cancelled', outcome='cancelled'), or an error if the workflow is already terminal.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| workflow_id | Yes | ||
| reason | No |