Skip to content

Graphs

A Graph defines the deterministic structure of a workflow — which nodes exist, how they connect, and the conditions under which edges are traversed. They can be cyclic or acyclic depending on the need.

Use the createGraph helper to build a validated Graph object. The id is auto-generated if omitted:

import { createGraph } from '@cycgraph/orchestrator';
const graph = createGraph({
name: "Research Pipeline",
description: "Searches the web and writes a summary",
start_node: "researcher",
end_nodes: ["writer"],
nodes: [
// ... Node definitions ...
],
edges: [
// ... Edge definitions ...
]
});
FieldTypeDefaultDescription
idstring (UUID)auto-generatedUnique identifier for the graph definition.
namestringrequiredHuman-readable name.
descriptionstringrequiredDescription of what this graph does.
nodesGraphNode[]requiredList of nodes that define the work to be done.
edgesGraphEdge[]requiredDirected edges defining the flow of execution.
start_nodestringrequiredThe ID of the first node to execute.
end_nodesstring[]requiredTerminal node IDs. Execution stops here.

An Edge is a directed connection between a source node and a target node.

When a node completes, the orchestrator evaluates all outgoing edges from that node. The condition determines whether the edge is traversed.

FieldTypeDefaultDescription
idstring (UUID)auto-generatedUnique identifier for the edge (used in validation messages and debug logs).
sourcestringrequiredSource node ID.
targetstringrequiredTarget node ID.
conditionEdgeCondition{ type: 'always' }Routing logic.
metadataobject{}Arbitrary metadata for tooling/debugging.
TypeDescriptionRequired fields
alwaysUnconditional routing. The edge is always traversed.
conditionalDynamic routing. Evaluates an expression against the workflow’s memory state.condition: string
mapSpecialized edge used exclusively by map-reduce fan-out nodes.

Conditional example:

Loops back to the writer if score is low.

{
source: "evaluator",
target: "writer",
condition: {
type: "conditional",
condition: "memory.draft_score < 0.8"
}
}
  • Nodes — node types, configuration, and state slicing
  • Workflow State — the shared state object
  • Agents — how agent nodes work