2 min read

Reflex - a Chompsky Type I Workflow Engine

Reflex - a Chompsky Type I Workflow Engine

We've released Reflex, a DAG-based workflow orchestration engine with call stack composition and append-only blackboard semantics. It has two independent implementations — TypeScript and Go — both conforming to a shared formal specification. MIT licensed.

The Problem Space

Building agentic systems that go beyond single-step tool calling requires some kind of orchestration. The current landscape offers frameworks like LangChain, LangGraph, and CrewAI, which provide sequencing and branching but are generally context-free in the formal sense — transitions don't depend on accumulated non-local state. On the other end, traditional workflow approaches like BPMN and statecharts offer more structure but don't afford recursion — you can't easily compose workflows from workflows or push a running process onto a stack while a sub-process executes.

Reflex occupies the space between these: formally constrained, compositionally expressive, and explicitly characterized in terms of computational power.

The Design

A few key choices define the approach:

DAGs with guarded transitions. Workflows are directed acyclic graphs. Edges can carry guard conditions evaluated against accumulated state, so at fan-out points, guards filter which transitions are valid before the decision agent selects from the valid set. Repetition happens through recursive sub-workflow invocation, keeping loops visible in the call stack rather than embedded in graph structure.

Call stack composition. Workflows can invoke sub-workflows. The parent is pushed onto a LIFO stack and resumed when the child completes. Complex processes can be built from composable pieces without flattening everything into a single graph.

Append-only blackboard with scoped reads. Each workflow has a local blackboard. Writes are always local. Reads walk the scope chain — local, then parent, then grandparent, etc. — so child workflows can see ancestor context without explicit parameter passing. The append-only constraint means established context is never contradicted. Values flow back up through explicit return maps.

Pluggable decision agent. The engine itself provides no intelligence. At each non-invocation node, the runtime calls a decision agent with the current node, valid edges, and scoped blackboard state. The agent returns one of: advance (pick an edge), suspend (await external input), or complete. The decision agent can be an LLM, a rule engine, a human participant, or any combination. That's your problem. The engine's job is to provide a formally bounded space for it to operate within.

Formal Characterization

Reflex implements a pushdown automaton with an append-only tape — equivalent to a linear-bounded automaton, Chomsky Type 1 (context-sensitive).

For context: most existing agentic orchestration frameworks are effectively Type 2 (context-free) or Type 3 (regular) in computational power. Sequencing is Type 3. State machines are Type 2. Scoped composition with guard conditions that depend on non-local accumulated state is Type 1. The guard mechanism is specifically what makes Reflex context-sensitive — transitions can depend on anything in the scope chain, not just the current node.

The append-only constraint is the principled ceiling. Maximal expressiveness while preserving the invariant that established context holds. You can always add to what you know. You can never unsay what's been said.

AI systems need real computational infrastructure. The explicit attempt at formalism here — characterizing what class of computation the orchestration engine actually implements, what invariants it maintains, where the boundaries are — is something we haven't seen done elsewhere in this space. It seems worth doing.

Where to Find It

The repository is at github.com/corpus-relica/reflex. Both implementations, the shared design specification, and the roadmap are there. Please, go take a look.