
Agent OS Gamma: Durable Runs, SQL Stores, and Worker Leases
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
| Capability | What you get |
|---|---|
| Durable HITL | durableSuspend + approveAndResume — workers free while waiting for humans |
| SQL AgentRun store | createSqlDurableRunStore(prisma) — PostgreSQL, MySQL, SQLite, SQL Server, … |
| File store | createDurableRunStore(dir) for local / CLI |
| Worker leases | workerId + RepositoryAgentRunLeaseService.reclaimExpired |
| CLI | hazel agent run / logs / doctor / runs * |
| DNA bootstrap | bootstrapRuntimeFromDna for embedded / CLI runners |
| Skillgate | Curated 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:
- Restart mid-HITL without losing the run
- Queryable process history in your SQL engine
- Two workers that cannot double-execute the same run
- 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)
| Pattern | Weakness | Gamma |
|---|---|---|
| In-memory approval promise | Lost on restart | Durable HITL + checkpoints |
| Single process | No HA | Leases + reclaim |
| Graph lib only | You own SQL + fencing | AgentRun 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
- What is an Agent OS?
- Agent OS guide — Gamma section
- Skillgate comprehensive guide
- Production AI agents in Node.js
- Agent package
- HazelJS vs LangGraph
- Earlier announcement: What's new in Agent OS
Apache-2.0 · ship agents as part of your product, not bolted on.