Latch

The backend around your AI agent. Saved conversations, approvals, crash recovery, per-customer isolation, usage limits and chat apps, inside your own server and database.

The Vercel AI SDK gives you the model call and the tool loop. Latch is the backend around it: everything an agent needs once real customers use it. Conversations that are saved, risky actions that wait for a person, answers that survive a crashed server, customers who never see each other's data, usage limits, and the same agent in Slack.

It's a library, not a service. It runs inside your own server, on the Postgres or SQLite you already have, behind your own login.

What it looks like

An agent that helps customers with their orders, and asks before refunding:

lib/latch.ts
import { anthropic } from "@ai-sdk/anthropic";
import { createRuntime, defineAgent } from "@intentface/latch-core";
import { createPostgresAdapter } from "@intentface/latch-drizzle";
import { context, find_order, refund } from "./tools";

// Who is asking. Ids only: it's saved with every run and schedule.
// Anything you look up (plan, names, clients) goes in the context.
export type Principal = { orgId: string; userId: string };

export const runtime = createRuntime<Principal>({
  // Every conversation belongs to one person in one organization.
  storage: createPostgresAdapter(db, {
    owner: (p) => [p.orgId, p.userId],
  }),
  // What tools receive on each turn (see the Tools tab).
  context,
  agents: {
    support: defineAgent({
      model: anthropic("claude-sonnet-4-6"),
      instructions: "You help customers with their orders.",
      tools: { find_order, refund },
      // A person clicks Approve before a refund runs.
      toolApproval: { refund: "user-approval" },
    }),
  },
  // A crashed answer is finished by another server.
  durability: { enabled: true },
});

That's the whole integration. The conversation is saved, the refund waits for a click (today, tomorrow, from another device), and if a server dies mid-answer, another one finishes it.

The principal you pass once is what keeps customers apart. Storage scopes every read and write by it, every tool receives it through the context, your limits are keyed from it, connected accounts are stored under it, and it's saved with each run and schedule, so a resumed answer or a 9:00 report still acts as the right person. More in Principal, context and params.

What you get

Plus schedules, connections to other services (MCP, OAuth), subagents, Slack, Telegram and WhatsApp, and cost per answer.

Build with your coding agent

Install the Latch skill and your agent (Claude Code, Cursor, Codex and more) gets the recipes, the rules that break quietly, and these docs:

bash
npx skills add https://intentface-latch-docs.vercel.app

More, including llms.txt for agents that read the web, in Build with AI.

When not to use it

If you're building a single-user prototype that doesn't need to remember anything, the AI SDK alone is the better tool. Latch earns its place when a second customer, a second server or a second channel shows up.