Foundation~12 minHazelJS
Sequential Workflow
Fixed-stage pipelines with @hazeljs/flow nodes or runtime.pipeline—when stages are stable.
- Authors
- editorial-team
- Published
- Last reviewed
Problem
Known multi-stage processes are encoded as fragile free-form agent loops.
Context
Business processes with stable stages and clear contracts between steps.
Forces and constraints
- Predictability and auditability matter
- Some stages may still need an LLM node
- Retries/idempotency belong in the engine
Recommended design
Prefer @hazeljs/flow (@Flow/@Node/@Edge) for durable deterministic graphs with idempotencyKey on side-effecting nodes. For a short sequence of agents, runtime.pipeline([...]) is acceptable. Do not use an open AgentRuntime loop for A→B→C scripts.
Minimal pseudocode
// Flow — durable stages
@Flow('onboard', '1.0.0')
class OnboardFlow {
@Node('validate') async validate(ctx) { /* ... */ }
@Node('provision', { idempotencyKey: (ctx) => `user:${ctx.input.id}:prov` })
async provision(ctx) { /* ... */ }
}
// Or sequential agents
await runtime.pipeline([researchAgent, writerAgent]);Failure modes
- Encoding a stable pipeline as an unbounded agent loop
- Missing idempotency on write nodes
Security considerations
- Auth per stage; no shared god credentials
Observability signals
- Stage timing; failure node identity
Evaluation approach
Contract tests per node; end-to-end fixture for happy path.
Trade-offs
- Less flexibility than agent loops
- Graph maintenance when stages change often