Skip to content

Workflows

A workflow in Moira is a directed graph of nodes that defines a multi-step process for AI agents to execute.

Every workflow consists of:

{
"id": "my-workflow",
"metadata": {
"name": "My Workflow",
"version": "1.0.0",
"description": "Description of what this workflow does"
},
"nodes": [
// Array of node definitions
]
}
FieldRequiredDescription
nameYesHuman-readable workflow name
versionYesSemantic version string
descriptionYesWhat the workflow accomplishes

Nodes are the steps in your workflow. Each node has an id and a type that determines its behavior.

When a workflow starts:

  1. Engine creates an execution instance with unique processId
  2. Finds the start node (type: start)
  3. Returns the first directive to the agent
  4. Agent executes and returns result
  5. Engine evaluates connections and moves to next node
  6. Repeat until reaching an end node (type: end)

Each execution maintains a context object containing:

{
variables: Record<string, unknown>; // User-defined variables
nodeStates: Record<string, unknown>; // Per-node state
executionId: string; // Unique execution ID
workflowId: string; // Source workflow ID
currentNodeId: string; // Current position
}

Moira supports 7 node types:

TypePurpose
startEntry point for workflow execution
endTerminal node marking completion
agent-directiveAgent task with directive and completion condition
conditionBranch based on structured conditions
expressionCompute values using arithmetic expressions
subgraphDelegate to another workflow
telegram-notificationSend notifications via Telegram

See Nodes for detailed documentation on each type.

Nodes connect via the connections object that defines the flow. Each node type has specific connection types:

{
"id": "analyze-task",
"type": "agent-directive",
"directive": "Analyze the task requirements",
"completionCondition": "Analysis is complete",
"connections": {
"success": "next-step",
"error": "error-handler"
}
}
{
"id": "check-status",
"type": "condition",
"condition": {
"type": "equals",
"left": { "type": "variable", "path": "status" },
"right": { "type": "literal", "value": "success" }
},
"connections": {
"true": "success-path",
"false": "retry-path"
}
}
{
"id": "simple-workflow",
"metadata": {
"name": "Simple Task Workflow",
"version": "1.0.0",
"description": "A basic workflow demonstrating node connections"
},
"nodes": [
{
"id": "start",
"type": "start",
"connections": { "default": "main-task" }
},
{
"id": "main-task",
"type": "agent-directive",
"directive": "Complete the assigned task",
"completionCondition": "Task is completed successfully",
"connections": { "success": "end" }
},
{
"id": "end",
"type": "end"
}
]
}

Workflows have visibility settings:

  • private - Only the owner can access
  • public - All users can start the workflow
  1. Start with start - Every workflow must have a start node
  2. End with end - Use end nodes to mark completion
  3. Clear Directives - Write unambiguous instructions
  4. Measurable Conditions - Completion conditions should be verifiable
  5. Error Handling - Include error connections for graceful failures
  6. Documentation - Add descriptions to complex nodes
  • Nodes - Node types and configuration
  • Templates - Dynamic content in workflows