Interruption
The key breakthrough is that interruption isn't a bug – it's a feature.
Human in the loop
How it works
<?php
namespace App\Neuron;
use NeuronAI\Workflow\Events\Event;
use NeuronAI\Workflow\Interrupt\Action;
use NeuronAI\Workflow\Interrupt\ApprovalRequest;
use NeuronAI\Workflow\Node;
use NeuronAI\Workflow\WorkflowState;
class InterruptionNode extends Node
{
public function __invoke(InputEvent $event, WorkflowState $state): OutputEvent
{
// Interrupt the workflow and wait for the feedback.
$humanResponse = $this->interrupt(
new ApprovalRequest(
message: 'Should I continue?'
actions: [
new Action('delete_file', 'Delete File', 'Delete /var/log/old.txt'),
],
)
);
$action = $humanResponse->getAction('delete_file');
if ($action->isApproved()) {
$state->set('is_sufficient', true);
$state->set('user_feedback', $action->feedback);
return new OutputEvent();
}
$state->set('is_sufficient', false);
return new InputEvent();
}
}Interruption Request
Catching the interruption
Unexpected error with integration github-files: Integration is not installed on this space
Checkpointing
Consume The Feedback
Conditional Interruption
Monitoring & Debugging
Last updated