Advanced~28 minHazelJS
Flow vs Multi-Agent Orchestration
Choose @hazeljs/flow for deterministic durable graphs vs AgentGraph for LLM-routed work—with both code paths.
- Authors
- editorial-team
- Published
- Last reviewed
Progress is stored locally in this browser.
Direct answer
| Need | Prefer |
|---|---|
| Stable stages, retries, idempotent nodes | @hazeljs/flow |
| LLM chooses specialist / parallel research | AgentGraph / Supervisor |
| Single tool loop | AgentRuntime alone |
Comparison: /compare/prompt-vs-workflow-vs-graph-vs-agent-loop.
Flow example — durable stages
typescript
import { Flow, Node, Edge, type FlowContext } from '@hazeljs/flow';
@Flow('onboard', '1.0.0')
export class OnboardFlow {
@Node('validate')
async validate(ctx: FlowContext) {
return { status: 'ok', output: { userId: ctx.input.userId } };
}
@Node('provision', {
idempotencyKey: (ctx) => `user:${ctx.input.userId}:prov`,
})
async provision(ctx: FlowContext) {
await accounts.provision(ctx.input.userId);
return { status: 'ok', output: { provisioned: true } };
}
}
@Edge('validate', 'provision')
export class OnboardEdges {}
When teams pick wrong
Encoding validate → provision → email as an open AgentRuntime loop adds cost variance and invents “tools” that are really stages. Keep agents for observation-driven branching; keep flow for known graphs.
Artifact: Decision table for one product capability