Agent OS — durable agents in your TypeScript backend. Start with Meridian →
HazelJS LogoHazelJS

Comparison

NestJS + LangChain vs HazelJS

Nest + LangChain works but creates two paradigms. HazelJS Agent OS unifies durable agents, DNA, Skillgate, and local apply in the same DI app as your APIs.

Updated August 7, 2026

NestJS + LangChain vs HazelJS

TL;DR

  • NestJS + LangChain is the default “production AI backend” recipe for many TypeScript teams.
  • It works — and it creates two frameworks, two config stories, and a lot of glue between HTTP and AI.
  • HazelJS Agent OS: DNA packages, crash-safe HITL, Skillgate, and local apply — one DI app, not Nest + LangChain glue.
  • Keep Nest + LangChain if you already invested heavily and AI is a thin layer.
  • Switch (or start new) on HazelJS when durable agents are the product — clone Meridian.

Who this is for

Teams that:

  • Run NestJS APIs and added LangChain for RAG/agents
  • Feel pain from dual paradigms (Nest providers vs LangChain runnables)
  • Want auth, caching, observability, and agents under one roof

Not ideal if:

  • You only need a few LLM calls in Nest controllers (raw OpenAI SDK may be enough)
  • You depend on LangChain ecosystem plugins HazelJS does not mirror yet
  • You are Python-first (LangChain’s gravity is stronger there)

The glue-code problem

A typical Nest + LangChain setup looks like:

NestJS module
  └─ Controller / Guard / Pipe
       └─ Service
            └─ LangChain chain / agent / retriever
                 └─ Vector store, embeddings, tools, memory

Every new AI feature means bridging:

  • Nest DI ↔ LangChain constructors
  • Nest config ↔ LangChain env/secrets
  • Nest logging/OTel ↔ LangSmith or custom LLM traces
  • Nest auth context ↔ tool execution identity

HazelJS collapses that bridge: Agent OS runs in the same graph as your HTTP layer. HCEL chains are optional for brownfield orchestration — not the wedge.

Side-by-side

ConcernNestJS + LangChainHazelJS Agent OS
ScopeWeb framework + AI libraryDurable agents inside your TypeScript backend
Mental modelTwo: Nest modules + LCEL/runnablesOne: modules, decorators, DI
Crash-safe HITLSession hacks / external queuesDurable AgentRun suspend/resume across restarts
PackagingPrompts in repo / vendor consoleDNA + Store — identity, prompt, policies as packages
REST as toolsHand-written tool schemasSkillgate — curated REST, writes need approval
Desired stateDIY / K8s scriptsLocal apply / Definitions — K8s optional
HTTP surfaceNest controllersSame DI process as your APIs
Teaching pathScattered samplesMeridian flagship

Code: glue vs native

Nest service wrapping LangChain (illustrative glue):

// Nest provider manually constructs LangChain pieces
@Injectable()
export class ChatService {
  private chain: any;

  constructor(private config: ConfigService) {
    const model = new ChatOpenAI({ apiKey: this.config.get('OPENAI_API_KEY') });
    const retriever = /* wire vector store */;
    this.chain = RunnableSequence.from([
      /* prompt */,
      retriever,
      model,
    ]);
  }

  async ask(input: string) {
    return this.chain.invoke({ input });
  }
}

HazelJS Agent OS execute in the same DI world:

await runtime.execute('support-desk', input, {
  loop: { maxIterations: 4, successScore: 90 },
  contract: { fallbackAgent: 'safe-desk' },
  recovery: { maxRetries: 2, fallbackAgent: 'safe-desk' },
});

Also available — HCEL for brownfield chains only:

import { Injectable } from '@hazeljs/core';
import { AIService } from '@hazeljs/ai';

@Injectable()
export class ChatService {
  constructor(private ai: AIService) {}

  async ask(input: string) {
    return this.ai.hazel
      .prompt('Answer using docs: {{input}}')
      .rag('engineering-docs')
      .agent('support-specialist')
      .execute(input);
  }
}

Support agent with real @Tool handlers (DNA lists names only):

import { Agent, Tool } from '@hazeljs/agent';

@Agent({
  name: 'support-desk',
  enableMemory: true,
  systemPrompt: 'Resolve tickets with tools when needed.',
})
export class SupportDeskAgent {
  @Tool({
    description: 'Create a ticket',
    parameters: [{ name: 'title', type: 'string', required: true }],
  })
  async createTicket(input: { title: string }) {
    return { id: 'T-100', title: input.title };
  }
}

Decision guide

SituationRecommendation
Greenfield durable agents in TypeScriptHazelJS Agent OS — clone Meridian
Nest monorepo, AI is 5% of surfaceStay Nest; add thin LLM SDK or LangChain
Nest monorepo, AI is becoming the productPilot @hazeljs/agent vertical or full migrate
Need crash-safe HITL + HTTPAgent OS durable AgentRun (not only LangGraph)
Heavy LangChain Hub / Python research pipelinesLangChain; use HazelJS only for the TS API edge

When NestJS + LangChain is better

  • Your org standardized on LangSmith / LangGraph and training is done
  • You need a LangChain integration HazelJS does not ship yet
  • Political cost of introducing another framework exceeds glue-code cost

HazelJS is the better default when durable agents in your TypeScript backend matter more than LangChain ecosystem breadth.

Related comparisons

Next steps

  1. Clone Meridian
  2. Agent OS guide
  3. Skillgate guide
  4. Docs: Agent package
  5. GitHub

FAQ

Why not just use NestJS with LangChain?
It works. The cost is dual DI/config, manual wiring of agents into controllers, and separate observability. Agent OS collapses that: durable HITL, DNA, Skillgate, and HTTP in one stack.
Is HazelJS a LangChain replacement?
For TypeScript backends that need durable agents and APIs together, yes — Agent OS + Skillgate cover the production path. HCEL is optional for light chains. Deep LangChain plugins may still matter in research-heavy setups.
What about LangGraph for durable agents?
HazelJS Agent OS provides crash-safe HITL on durable AgentRun, multi-agent routing, and local apply for Definitions. @hazeljs/flow is separate for WAIT/resume business workflows — not a substitute for AgentRun HITL.
Can I migrate incrementally?
Yes. Clone Meridian as the teaching path, or add @hazeljs/agent for a vertical slice while Nest remains elsewhere. Full Nest → HazelJS migration is documented separately.

Docs & next steps

Related comparisons

  • HazelJS vs NestJS

    NestJS structures backends well. HazelJS Agent OS keeps familiar modules/DI and adds DNA packaging, crash-safe HITL, Skillgate, and local apply — clone Meridian to see it.

  • HazelJS vs LangChain

    LangChain composes LLM pipelines. HazelJS Agent OS runs those agents inside a production TypeScript backend — DNA, crash-safe HITL, Skillgate, local apply, same DI as your APIs.

  • HazelJS vs LangGraph

    LangGraph is a strong agent graph runtime. HazelJS Agent OS covers durable AgentRun HITL, DNA packaging, Skillgate, local apply, and your API layer without a separate web framework.

← All comparisons