Skip to content

Why Invariant?

Building an AI agent is easy. Giving it real responsibility is hard.

"AI makes software probabilistic. Invariant makes its execution durable."

You can build a simple AI agent that answers questions in a few lines of code.

The challenge begins when you want that agent to take consequential actions in the real world:

text
Process a refund
Modify an account
Book an appointment
Approve a purchase request
Run a multi-hour data job
Wait for human approval
Recover cleanly after a crash

When an agent takes real actions, critical infrastructure questions arise:

text
Did this external operation already execute?
Is this customer actually eligible for this operation?
Where in the business process is this execution right now?
What input is the application currently waiting for?
Should a failed external call be retried?
What is the model actually authorized to do?
What happened when an execution failed?

Invariant moves these responsibilities out of the model and into infrastructure.


4 Core Problems Invariant Solves

1. Models shouldn't be your application state

Traditional agent patterns stuff conversation history, tool calls, tool results, instructions, and application state into a single growing LLM prompt.

text
Traditional Agent:
conversation history + tool calls + results + instructions + app state → LLM

Invariant:
durable application state → relevant context projection → LLM

Invariant keeps durable state in the runtime and projects only the context required for the current decision.

Result: Smaller model prompts, lower token costs, and no reliance on asking an LLM to reconstruct where an application is from message transcripts.

2. Models shouldn't determine application truth

Giving an unconstrained LLM a raw refundCustomer() tool grants a probabilistic model direct authority over business actions and real money.

text
Traditional Tool Calling:
LLM ────────────────────────► refundCustomer($500)  (Direct authority over money)

In Invariant, an Agent interprets user intent ("My order arrived damaged") and requests starting an authoritative workflow:

text
Invariant Architecture:
User request ──► LLM Agent ──► "start refund workflow"


                               Refund Workflow
                                 ├─ Load real customer
                                 ├─ Load real order
                                 ├─ Apply deterministic policy
                                 └─ Issue refund only if eligible

The model can interpret intent without becoming the authority that determines truth.

3. AI execution shouldn't disappear when your server dies

Node.js processes restart, servers crash, APIs time out, and users take hours to respond to prompts.

text
Start workflow ──► Call API ──► Wait for user ──► 💀 Server Crash ──► Restart ──► Resume cleanly

Your process is temporary. The execution is not.

Invariant persists workflow progress, execution position, and side-effect boundaries so work can resume automatically after process restarts without re-executing external operations or re-prompting LLMs.

4. When AI fails, "the agent failed" isn't enough

When a production action goes wrong, you need to know exactly what happened:

text
Agent interpreted request

Refund workflow started

Customer loaded

Order loaded

Policy evaluated

Refund approved

issue-refund attempted

External API failed (timeout)

Automatic retry succeeded

Workflow completed

Invariant separates reasoning observability from execution observability.

You don't just know that an agent failed. You can know where, when, and at which boundary it failed.


The Core Idea

text
                  Probabilistic


                 ┌─────────────┐
                 │    Model    │
                 │   reasons   │
                 └──────┬──────┘

                   constrained
                     intent


                 ┌─────────────┐
                 │  Workflow   │
                 │defines truth│
                 └──────┬──────┘


                 ┌─────────────┐
                 │   Runtime   │
                 │  executes   │
                 └──────┬──────┘


                  Real systems

Models reason. Infrastructure executes.


Where Invariant Fits

If you primarily need...Consider
General-purpose durable workflows across many programming languagesTemporal / Restate
Low-level graph orchestration and agent persistenceLangGraph
AI generation, prompt tools, and frontend streaming UIVercel AI SDK
TypeScript-first durable workflows where LLM intent, workflow truth, and runtime execution are explicit boundariesInvariant

Go Deeper

  • Introduction — Understand how Workflows, Agents, and .reason() nodes fit together in code.
  • Mental Model — Explore the 6 core abstractions of the Invariant architecture.
  • Quick Start — Build your first durable AI workflow in 5 minutes.

Invariant Durable Execution Engine.