You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Signatures currently support a rich set of lifecycle actions — pause (SUSPEND / INTERRUPT), suspend, interrupt, cancel, and resume — implemented on Signature / ChainTaskSignature / SwarmTaskSignature in libs/third-magic/thirdmagic/signature/model.py:160-194 and honored at per-task execution via SignatureLifecycle.should_run_task (libs/mageflow/mageflow/lifecycle/signature.py:78-91).
Hatchet workflows dispatched via MageflowWorkflow do not yet honor these signature-level actions. When a workflow is attached to a signature (see #116 / #118), pausing or canceling that signature should propagate to the running workflow — stopping new tasks from dispatching on SUSPENDED, aborting in-flight execution on INTERRUPTED, and cleaning up on CANCELED.
Features / Details
Respect SignatureStatus.SUSPENDED on MageflowWorkflow runs: do not dispatch subsequent tasks; invoke on_pause_signature with the current input; leave the workflow in a resumable state
Respect SignatureStatus.INTERRUPTED on in-flight workflow runs: best-effort abort of the running workflow (analogous to the Signature.interrupt TODO at libs/third-magic/thirdmagic/signature/model.py:172-177)
Respect SignatureStatus.CANCELED on workflow runs: invoke on_cancel_signature, remove signature state, and stop the workflow
Support resume on a previously SUSPENDED workflow signature — re-dispatching the workflow should pick up from a resumable state (similar to resume_from_key on signatures)
Propagate pause/cancel through nested workflow signatures (chain / swarm wrapped in a MageflowWorkflow) so pausing the parent signature pauses the nested execution, consistent with ChainTaskSignature.change_status / SwarmTaskSignature.change_status
Reuse the existing PauseActionTypes enum (SUSPEND / INTERRUPT) and Signature.pause_task entry point rather than introducing a parallel action set
Use Cases
A caller that dispatched a workflow with a signature wants to pause the workflow mid-run (e.g. rate-limit backoff, manual hold) — they call Signature.pause_from_key and the running MageflowWorkflow stops dispatching further tasks
A caller cancels a workflow signature — the running workflow winds down, on_cancel_signature runs, and Redis state is cleaned up
Resume: a suspended workflow is re-dispatched and continues without re-executing already-DONE sub-tasks (relies on existing idempotency guards — 070f2d4, f58d2b3, 893d8ac)
Hard stop: INTERRUPT forcibly aborts the workflow's async context rather than waiting for the next task boundary
Implementation Considerations
SignatureLifecycle.should_run_task already implements the per-task version of this check — the workflow-level equivalent needs to run at workflow-start (and potentially between tasks) rather than only at task entry
MageflowWorkflow._serialize_input (libs/mageflow/mageflow/clients/hatchet/workflow.py:109-122) is where the workflow-level signature reference should be carried so workflow hooks can resolve and inspect the signature's status
Signature.interrupt is currently a TODO that delegates to suspend (libs/third-magic/thirdmagic/signature/model.py:172-177) — this issue must either implement real interrupt semantics at the hatchet layer or explicitly document the current suspend-equivalent behavior
Pausing an in-flight hatchet workflow likely requires hatchet-sdk cancellation APIs — investigate what hatchet exposes for stopping a running workflow from an external actor vs. a cooperative check at task boundaries
Must preserve existing nested-signature propagation: ChainTaskSignature.change_status / SwarmTaskSignature.change_status fan out to children; wrapping those in a MageflowWorkflow must not break the fan-out
Tasks
Add a workflow-start status check that honors SUSPENDED / CANCELED / INTERRUPTED (workflow-level analogue of should_run_task)
Wire on_pause_signature / on_cancel_signature invocation into the MageflowWorkflow entry path
Implement cooperative suspend: stop dispatching further tasks on SUSPENDED mid-run
Investigate and implement hatchet-level workflow cancellation for INTERRUPT semantics
Implement resume path for a SUSPENDED workflow signature, leveraging task-level idempotency so completed children are not re-run
Ensure pause/cancel propagates correctly through MageflowWorkflow-wrapped chain / swarm signatures
Unit tests: workflow signature in each of SUSPENDED / INTERRUPTED / CANCELED states yields the expected behavior on dispatch
Integration test: dispatch a MageflowWorkflow, externally pause_from_key the signature, verify no further tasks dispatch
Integration test: resume a suspended workflow signature and verify it completes without re-running done tasks
Update documentation to describe workflow-level pause/suspend/interrupt/cancel semantics
Summary
Signatures currently support a rich set of lifecycle actions —
pause(SUSPEND/INTERRUPT),suspend,interrupt,cancel, andresume— implemented onSignature/ChainTaskSignature/SwarmTaskSignatureinlibs/third-magic/thirdmagic/signature/model.py:160-194and honored at per-task execution viaSignatureLifecycle.should_run_task(libs/mageflow/mageflow/lifecycle/signature.py:78-91).Hatchet workflows dispatched via
MageflowWorkflowdo not yet honor these signature-level actions. When a workflow is attached to a signature (see #116 / #118), pausing or canceling that signature should propagate to the running workflow — stopping new tasks from dispatching onSUSPENDED, aborting in-flight execution onINTERRUPTED, and cleaning up onCANCELED.Features / Details
SignatureStatus.SUSPENDEDonMageflowWorkflowruns: do not dispatch subsequent tasks; invokeon_pause_signaturewith the current input; leave the workflow in a resumable stateSignatureStatus.INTERRUPTEDon in-flight workflow runs: best-effort abort of the running workflow (analogous to theSignature.interruptTODO atlibs/third-magic/thirdmagic/signature/model.py:172-177)SignatureStatus.CANCELEDon workflow runs: invokeon_cancel_signature, remove signature state, and stop the workflowresumeon a previouslySUSPENDEDworkflow signature — re-dispatching the workflow should pick up from a resumable state (similar toresume_from_keyon signatures)MageflowWorkflow) so pausing the parent signature pauses the nested execution, consistent withChainTaskSignature.change_status/SwarmTaskSignature.change_statusPauseActionTypesenum (SUSPEND/INTERRUPT) andSignature.pause_taskentry point rather than introducing a parallel action setUse Cases
Signature.pause_from_keyand the runningMageflowWorkflowstops dispatching further taskson_cancel_signatureruns, and Redis state is cleaned upDONEsub-tasks (relies on existing idempotency guards —070f2d4,f58d2b3,893d8ac)INTERRUPTforcibly aborts the workflow's async context rather than waiting for the next task boundaryImplementation Considerations
SignatureLifecycle.should_run_taskalready implements the per-task version of this check — the workflow-level equivalent needs to run at workflow-start (and potentially between tasks) rather than only at task entryMageflowWorkflow._serialize_input(libs/mageflow/mageflow/clients/hatchet/workflow.py:109-122) is where the workflow-level signature reference should be carried so workflow hooks can resolve and inspect the signature's statusSignature.interruptis currently a TODO that delegates tosuspend(libs/third-magic/thirdmagic/signature/model.py:172-177) — this issue must either implement real interrupt semantics at the hatchet layer or explicitly document the current suspend-equivalent behaviorACTIVE → SUSPENDED → ACTIVE(resume) andACTIVE → CANCELEDpathsChainTaskSignature.change_status/SwarmTaskSignature.change_statusfan out to children; wrapping those in aMageflowWorkflowmust not break the fan-outTasks
SUSPENDED/CANCELED/INTERRUPTED(workflow-level analogue ofshould_run_task)on_pause_signature/on_cancel_signatureinvocation into theMageflowWorkflowentry pathSUSPENDEDmid-runINTERRUPTsemanticsresumepath for aSUSPENDEDworkflow signature, leveraging task-level idempotency so completed children are not re-runMageflowWorkflow-wrapped chain / swarm signaturesSUSPENDED/INTERRUPTED/CANCELEDstates yields the expected behavior on dispatchMageflowWorkflow, externallypause_from_keythe signature, verify no further tasks dispatchRelated
with_signaturesupportACTIVE/DONE/FAILED)