Beyond the DAG

Real work doesn't run
in a straight line.
It loops.

DAGs only go forward. cycgraph loops back — agents retry on feedback, route on the fly, evolve in parallel, and pause for a human mid-run. That's the Cyclic State Graph: durable, auditable, zero-trust.

$ npm install @cycgraph/orchestrator
The edge that loops back

A loop is just one edge, pointing back.

Declare nodes, edges, and conditions as plain config — no subclasses, no callback spaghetti. Point a single edge backward and you have a loop. The runtime owns state, persistence, security, and streaming; you just describe the shape.

Durable execution
Every action is persisted. Runs survive crashes and replay straight from the event log.
Zero-trust
Agents see only their keys. External data is taint-tracked; MCP servers are allowlisted.
Budget guardrails
Hard caps on tokens, cost, iterations, and wall-clock — enforced by the engine, not by you.
Observability
OpenTelemetry traces, structured events, and token-level streaming, out of the box.
review-loop.ts
import {
  GraphRunner,
  createGraph,
  createWorkflowState,
} from '@cycgraph/orchestrator';

// Agents are data, not classes.
const graph = createGraph({
  name: 'review-loop',
  start_node: 'draft',
  end_nodes: ['done'],
  nodes: [
    { id: 'draft',  type: 'agent',      agent_id: WRITER },
    { id: 'critic', type: 'agent',      agent_id: REVIEWER },
    { id: 'route',  type: 'supervisor', agent_id: LEAD },
  ],
  edges: [
    { from: 'draft',  to: 'critic' },
    { from: 'critic', to: 'route'  },
    // the cycle: loop back until the critic is satisfied
    { from: 'route',  to: 'draft', when: 'needs_work' },
    { from: 'route',  to: 'done',  when: 'approved'   },
  ],
});

const runner = new GraphRunner(
  graph,
  createWorkflowState({ workflow_id: 'r1', goal: 'Ship it' }),
);

for await (const event of runner.stream()) {
  console.log(event.type);
}
Composable by design

Nine patterns, built in. Twelve node types to compose your own.

All patterns ↗
Build your first loop

Five minutes from install to a workflow that loops.

$ npm install @cycgraph/orchestrator