New: Decision Runtime — closed-set judgments for Agent OS. Read the guide →
HazelJS LogoHazelJS

Durable AI Agents

Durable AI agents keep working across crashes, network failures, and human waits. A bare while(true) loop cannot recover cleanly — HazelJS uses AgentRuntime plus DurableRunStore / DurableJobStore and crash-safe HITL (the durable kernel composition).

01Why not a forever loop?

while (true) {
  await agent.run();
}

Process death loses in-memory state. Model and tool failures need retries with leases. Long-running tasks and human approvals need suspend/resume. HazelJS stores durable runs, supports worker leases, and resumes HITL after restart when durable suspend is enabled.

02Mapped to HazelJS

  • Checkpoints / state → DurableRunStore run records
  • Leases → worker lease fields on durable jobs
  • HITL → HumanTaskService + hazel approvals / approve / deny
  • Recovery → hazel agent runs resume; hazeld keeps the node alive
  • Idempotency → prefer tool design + flow WAIT/resume patterns; do not invent APIs

03Execute with a confidence loop

typescript
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 },
});