Getting Started
Guide, moderate, and control your agentic system with human-in-the-loop
Beta release
NeuronAI Workflow is currently in Beta and subject to breaking changes. Please use with caution. We encourage experimenting with this component to better understand the human-in-the-loop pattern and suggest design improvements, bug fixes, or new features. Let's build together.
Think of a Workflow as a smart flowchart for your AI applications. Instead of your AI making every decision independently, a Workflow lets you create a step-by-step process where AI handles what it does best, and humans step in when judgment or oversight is needed.
Here's what makes NeuronAI Workflows special: they're built around interruption and human-in-the-loop capabilities. This means your agentic system can pause mid-process, ask for human input, wait for feedback, and then continue exactly where it left off – even if that's hours or days later.
Imagine you're building a content moderation system. Instead of having AI make final decisions about borderline content, your Workflow can:
Analyze the content using AI
Flag anything uncertain
Pause and ask a human moderator for review
Wait for the human decision
Continue processing based on that feedback
The key breakthrough is that interruption isn't a bug – it's a feature. Your Workflow remembers exactly where it stopped, what data it was working with, and what question it needs answered.
Inspector
Before moving into the Workflow creation process we recommend to have the monitoroing system in place. It could make the learning curve of how Workflow works much more easier. The best way to monitoring Workflow is with Inspector.
After you sign up at the link above, make sure to set the INSPECTOR_INGESTION_KEY
variable in the application environment file to monitoring Workflow execution:
INSPECTOR_INGESTION_KEY=nwse877auxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Create a Workflow
A Workflow in NeuronAI is made up of two elements:
Nodes, with each node responsible for handling a unit of execution (manipulate data, call an agent, etc.).
Edges, responsible to define how the workflow must move from one node to the next. They can be conditional branches or fixed transitions.
In short: Nodes do the work, Edges tell what to do next.
As an illustrative example, let's consider a simple workflow with two nodes. The connection (Edge) tells the workflow to go from A to B to C.
<?php
namespace App\Neuron\Workflow;
use App\Neuron\Workflow\InitialNode;
use App\Neuron\Workflow\MiddleNode;
use App\Neuron\Workflow\FinishNode;
use NeuronAI\Workflow\Edge;
use NeuronAI\Workflow\Workflow;
class SimpleWorkflow extends Workflow
{
public function nodes(): array
{
return [
new InitialNode(),
new MiddleNode(),
new FinishNode(),
];
}
public function edges(): array
{
return [
// Tell the workflow to go to MiddleNode after InitialNode
new Edge(InitialNode::class, MiddleNode::class),
// Tell the workflow to go to FinishNode after MiddleNode
new Edge(MiddleNode::class, FinishNode::class),
];
}
protected function start(): string
{
return InitialNode::class;
}
protected function end(): array
{
return [
FinishNode::class,
];
}
}
Why Use Workflows Instead of Regular Scripts?
You might be thinking: "This sounds great, but why can't I just write a regular PHP script with some if-statements and functions?" It's a fair question, and one I heard a lot while building NeuronAI. The answer becomes clear when you consider what happens when your process needs to pause, wait, and resume.
Another scenario that is practically impossible to reproduce with a procedural approach is when you need complex workflows with many branches, several loops and intermediate checkpoints, etc. When you are at the beginning and your use case is yet quite simple you couldn't see the real potential of Workflow, and it's normal. Keep in mind that if things hit the fan, NeuronAI already has a solution to help you scale.
Development Benefits
From a developer perspective, Workflows solve several painful problems:
Model and maintain complex iterations: With these simple building blocks you will be able to create simple processes with a few steps, up to complex workflows with iterative loops and intermediate checkpoints.
Human in the Loop: Seamlessly incorporate human oversight. You can deploy AI in sensitive areas because humans are always in the loop for critical decisions.
Debugging with inspector: Instead of wondering why your AI made a particular decision, you can see exactly how humans and AI collaborated at each step.
User Trust: When users know a human reviewed important decisions, they're more likely to trust and adopt your AI system.
Last updated