01What it is
Orchestration is the control of who runs next, what state survives a crash, and when a human must approve. HazelJS does not expose a class named Orchestrator or a first-class handoff API — you compose graphs, delegation, flows, queues, and durable HITL.
02Problem it solves
- Single-shot LLM calls cannot encode retries, approvals, and multi-agent routing
- Ad-hoc Promise chains lose state when the process dies mid-tool
- Business workflows need WAIT/resume without reinventing a job runner
- Cross-agent calls must still pass the same authorization gate
03How you use it today
- Agent graphs (DAGs) and supervisor patterns in @hazeljs/agent
- Delegation via @Delegate between agents
- A2A agent cards / JSON-RPC for inter-agent protocols
- Durable WAIT/resume business workflows with @hazeljs/flow
- Background jobs via @hazeljs/queue (BullMQ) when you need queues
- Retries, timeouts, and crash-safe HITL on durable agent runs
- Human approval through Gatekeeper require-approval + hazel approvals
Prefer AgentGraph / supervisor when the unit of work is an agent. Prefer @hazeljs/flow for explicit WAIT/resume business workflows. Prefer @hazeljs/queue for classic job queues — that package is not the Agent OS kernel.
04Where it sits in the stack
Orchestration sits above tool implementations and below the Control Plane. The Agent Runtime executes steps; orchestration decides sequence, branching, and resume.
05Boundaries
- No invented handoff() API — use @Delegate, graphs, A2A, or flow WAIT
- @hazeljs/queue is optional infrastructure, not required for Agent OS
- Distributed orchestration backends beyond local hazeld are experimental
06FAQ
- Is there an Orchestrator class?
- No. Compose AgentGraph / supervisors, @Delegate, A2A, @hazeljs/flow, and durable HITL.
- When do I use flow vs AgentGraph?
- AgentGraph when agents are the unit of work. @hazeljs/flow when you need durable WAIT/resume business workflows.
- Where is a worked example?
- Start from AI agent orchestration explained and the A2A guide.
07Confidence loop inside AgentRuntime
import { AgentRuntime, createMockLlmProvider } from '@hazeljs/agent';
const runtime = new AgentRuntime({
llmProvider: createMockLlmProvider(),
enableRetry: false,
});
runtime.registerAgent(SupportAgent);
const result = await runtime.execute('support-agent', 'Check open orders', {
maxSteps: 8,
loop: { maxIterations: 8, successScore: 95 },
});