This page documents how AI Agent Automation actually runs workflows — from task creation to final persistence — with nothing hidden.
Every workflow execution follows the same immutable path. No shortcuts. No branching logic injected by agents.
A trigger (manual, scheduler, webhook, or API) creates a Task document in MongoDB with steps, edges, and initial context.
The worker polls for PENDING tasks and atomically marks one as RUNNING using MongoDB findOneAndUpdate with $set.
The runner builds an execution context containing workflow input, step outputs, variables, and metadata.
The executor dispatches each step to the correct handler. Parallel branches acquire distributed locks before executing.
Step results, logs, and trace IDs are written to the database. Socket.IO broadcasts progress to connected clients.
The task is marked COMPLETED, FAILED, PENDING_APPROVAL, or REJECTED. No further steps run unless explicitly resumed.