HazelJS LogoHazelJS
Agent OS Gamma: Durable Runs, SQL Stores, and Worker Leases
HazelJS Blog

Agent OS Gamma: Durable Runs, SQL Stores, and Worker Leases

Author
HazelJS Team
8/5/2026
General
← Back to Blog

Crash-safe HITL, Prisma SQL AgentRun stores on any SQL provider, worker leases, and hazel agent run — Agent OS kernel Gamma.

Author: HazelJS Team

Agent OS started as the production lifecycle around HazelJS agents — loops, policies, DNA, twins, and Inspector timelines. Gamma hardens the kernel so AI-native agents behave like durable processes: crash-safe human approval, SQL-backed run records on any Prisma SQL database, and multi-worker leases.

New to the term? Start with What is an Agent OS?.


What shipped

CapabilityWhat you get
Durable HITLdurableSuspend + approveAndResume — workers free while waiting for humans
SQL AgentRun storecreateSqlDurableRunStore(prisma) — PostgreSQL, MySQL, SQLite, SQL Server, …
File storecreateDurableRunStore(dir) for local / CLI
Worker leasesworkerId + RepositoryAgentRunLeaseService.reclaimExpired
CLIhazel agent run / logs / doctor / runs *
DNA bootstrapbootstrapRuntimeFromDna for embedded / CLI runners
SkillgateCurated REST → skills with HITL defaults (guide)

OSS runtime stays correct without Hazel Cloud. Cloud remains the optional control plane.


Why it matters

Prototypes hold an approval promise in memory. Production needs:

  1. Restart mid-HITL without losing the run
  2. Queryable process history in your SQL engine
  3. Two workers that cannot double-execute the same run
  4. A CLI path to smoke-test DNA without wiring a full HTTP app

Gamma closes those gaps inside @hazeljs/agent.


Durable HITL

With durableSuspend: true, approval-required tools suspend the AgentRun instead of parking an in-process promise. Operators (or your UI) call approveAndResume later — even after a process restart.

That is the difference between a demo chatbot and an AI-native agent you can ship.


SQL AgentRun store (any Prisma provider)

import { createSqlDurableRunStore } from '@hazeljs/agent';

const store = createSqlDurableRunStore(prisma);

Wire runRepository, checkpointService, and humanTaskService into AgentRuntime. Use PostgreSQL, MySQL, SQLite, SQL Server, or another Prisma-supported SQL engine — same duck-typed client shape.

For local / CLI smoke tests, prefer createDurableRunStore(dir) (file backend).


Worker leases

Set workerId on the runtime. RepositoryAgentRunLeaseService acquires a lease while executing, heartbeats as needed, and releases on suspend/complete/fail. Call reclaimExpired() from a cron or queue worker so dead workers do not leave forever-RUNNING zombies.

This is how you stop two pods from double-running the same AgentRun — without inventing a second kernel.


CLI path

hazel agent run ./agent.dna.json "hello" --mock
hazel agent doctor
hazel agent runs list --dir ./runs

DNA bootstrap (bootstrapRuntimeFromDna) powers embedded runners and the CLI without a full HTTP app.


Pair with Skillgate

Gamma persists and leases the run. Skillgate curates which REST operations become tools. Together: governed OpenAPI skills + crash-safe Agent OS execution.

Starter: hazeljs-skillgate-agent-starter.


Vs in-memory prototypes (and graph-only stacks)

PatternWeaknessGamma
In-memory approval promiseLost on restartDurable HITL + checkpoints
Single processNo HALeases + reclaim
Graph lib onlyYou own SQL + fencingAgentRun store in @hazeljs/agent

Compare orchestration-first stacks: HazelJS vs LangGraph.


Quick start

# Offline DNA smoke test
hazel agent run ./agent.dna.json "hello" --mock
hazel agent doctor
import {
  AgentRuntime,
  createSqlDurableRunStore,
  RepositoryAgentRunLeaseService,
} from '@hazeljs/agent';

const store = createSqlDurableRunStore(prisma);
const runtime = new AgentRuntime({
  llmProvider,
  durableSuspend: true,
  workerId: process.env.WORKER_ID,
  runRepository: store.runRepository,
  checkpointService: store.checkpointService,
  humanTaskService: store.humanTaskService,
});

await new RepositoryAgentRunLeaseService(store.runRepository).reclaimExpired();

Learn more

Apache-2.0 · ship agents as part of your product, not bolted on.