A deterministic, dependency‑aware workflow engine for autonomous LLM agents.
It transforms high‑level natural‑language plans into validated, optimized, and parallelizable execution graphs — with built‑in autofix, cycle detection, and tool‑aware execution.
This project demonstrates production‑grade engineering patterns for AI‑driven automation.
Modern LLM agents generate plans that are:
- Imperfect
- Non‑deterministic
- Sometimes invalid
- Often inefficient
This engine solves that by providing:
- Safety (validation, required‑field enforcement, cycle detection)
- Determinism (DAG, topological sorting, dependency resolution)
- Resilience (autofix, retries, multi‑step repair)
- Performance (parallel execution groups)
Ensures every plan is structurally correct before execution:
- Unknown tool detection
- Required‑field enforcement
- Duplicate step detection
- Full‑plan validation with autofix fallback
Automatically repairs:
- Invalid steps
- Invalid plans
- Cascading failures
- Remaining steps after a mid‑plan crash
Uses strict JSON‑only rewriting to guarantee safety.
Automatically analyzes step relationships:
- Detects file read/write/update dependencies
- Builds a Directed Acyclic Graph
- Extracts cycles
- Computes parallel layers
- Performs topological sorting
Improves plan efficiency:
- Removes no‑ops
- Deduplicates steps
- Merges redundant writes
- Reorders steps deterministically
- Assigns parallel groups
Two execution modes:
- Groups independent steps
- Executes each group concurrently
- Handles autofix + retry logic per step
- Deterministic, ordered execution
- Step‑level and multi‑step autofix
- Retry support
import { executePlan } from "./workflowEngine";
const plan = {
goal: "Generate and save a report",
optimize: true,
parallel: true,
autofix: true,
steps: [
{ number: 1, tool: "fileWriterTool", filename: "report.txt", content: "Hello" },
{ number: 2, tool: "fileReaderTool", filename: "report.txt" }
]
};
const results = await executePlan(plan);
console.log(results);- Validation — structural correctness
- Autofix — LLM‑powered repair
- Optimization — step merging, deduping, DAG ordering
- Execution — parallel + sequential engines
- Tooling — registry‑based tool interface
- Validate plan
- Autofix if invalid
- Optimize (optional)
- Build DAG
- Compute parallel layers
- Execute (parallel or sequential)
- Return structured results
Each tool defines:
requiredFieldshandler()
The engine:
- Validates required fields
- Passes arguments in correct order
- Handles tool‑level errors
- Supports autofix when tools fail
Each step returns:
- Step number
- Description
- Tool used
- Parallel group
- Start/end timestamps
- Duration
- Output
- Error (if any)
- Autofix metadata
- Fixed step (if applicable)
This makes debugging and observability straightforward.
workflowEngine.ts # Full engine (validation, DAG, optimization, execution)
toolRegistry.ts # Tool definitions + handlers
fileWriterTool.ts
fileReaderTool.ts
fileUpdaterTool.ts
webSearchTool.ts
memoryTool.ts
skipTool.ts
vector.ts # System prompt for LLM reasoning
- Systems design: DAGs, dependency graphs, parallel execution
- Error handling: retries, autofix, multi‑step repair
- LLM orchestration: structured prompting, JSON‑only constraints
- Production thinking: validation, safety, determinism
- Code quality: modularity, readability, clear subsystem boundaries
This is the kind of project that signals you can handle real engineering challenges — not just toy apps.
- Conditional branching
- Execution sandboxing
- Richer dependency heuristics
- Metrics + tracing hooks
- Plugin system for custom tools
This project is currently unlicensed and provided for portfolio and educational purposes.