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

Agent Runtime

Agent Runtime (`AgentRuntime` in @hazeljs/agent) is the execution kernel for HazelJS Agent OS. It registers agents and tools, runs execute/streaming, graphs, policies, and durable suspend.

01What it is

AgentRuntime is the in-process kernel that knows your @Agent / @Tool classes, talks to an LLM provider, and drives execute / stream / graph paths. Optional loop enables plan → execute → critique → validate. Policies, governance, cost routing, and timeline stores attach here (or via AgentModule.forRoot).

02Problem it solves

  • One place to register agents and tools inside a TypeScript DI app
  • Confidence loops instead of a single opaque LLM call
  • Hooks for Gatekeeper authorization, durable suspend, and Inspector timelines
  • Same kernel whether you call execute() from HTTP or from hazeld

03How you use it today

Construct AgentRuntime, register agent classes, call execute(name, input, options). For production wiring prefer AgentOS (facade over runtime + platform + HITL) — see Control Plane.

Commercial keyword page: AI agent runtime.

04Where it sits in the stack

Runtime is the Run layer. Above it: DNA packages and Control Plane deploy. Beside it: Decision Runtime judgments. After it: Gatekeeper before tools. Beneath durable paths: Durable Kernel stores and crash-safe HITL.

05Boundaries

  • AgentRuntime is not hazeld — the daemon hosts a node; the runtime executes agents
  • It is not a workflow engine — use @hazeljs/flow for WAIT/resume business flows
  • It does not authorize tools by itself — attach Gatekeeper / authorizationGate

06FAQ

Is AgentRuntime the same as Agent OS?
No. Runtime is the execution kernel. Agent OS is the full lifecycle: DNA, Skillgate, Gatekeeper, durable runs, and local apply.
Do I need the confidence loop?
Optional. Pass options.loop when you want plan → execute → critique → validate; otherwise execute is a single pass.
Where do I put policies?
On the runtime (PolicyEngine / governanceGate) or via AgentModule.forRoot — same place Inspector and Run attach.

07Bootstrap AgentRuntime

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