# Latch documentation This is the documentation for `@intentface/latch-*` — Latch, a reusable backend for building, persisting and operating AI agents on the Vercel AI SDK. It is a library that runs inside your own server and database: saved conversations, tool approvals, crash recovery across servers, per-customer isolation, usage limits, schedules, MCP/OpenAPI connections, Slack/Telegram/WhatsApp, and cost per run. Memory is experimental. Every page below is markdown: append `.md` to any docs URL to fetch the same content as plain text. `/llms-full.txt` is every page concatenated. - [Latch](https://intentface-latch-docs.vercel.app/docs.md): 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. - [Build with AI](https://intentface-latch-docs.vercel.app/docs/build-with-ai.md): Give Claude Code, Cursor, Codex and other coding agents the Latch skill and these docs, so they build with Latch the way it's meant to be used. ## Getting Started - [Getting Started](https://intentface-latch-docs.vercel.app/docs/getting-started.md): Two paths to a running agent — everything in one call, or the pieces by hand — and the three adoption tiers behind them. - [Quickstart](https://intentface-latch-docs.vercel.app/docs/getting-started/quickstart.md): A chat agent that remembers, in one file and five minutes. - [By hand](https://intentface-latch-docs.vercel.app/docs/getting-started/by-hand.md): createRuntime piece by piece — storage, context, agents — then durability and a cron, one option at a time. - [Install](https://intentface-latch-docs.vercel.app/docs/getting-started/install.md): Add the packages from npm, wire a database, and get a runtime answering turns. ## How it fits together - [Overview](https://intentface-latch-docs.vercel.app/docs/concepts.md): The parts of Latch, what happens when a message arrives, and why each part exists. - [Runtime](https://intentface-latch-docs.vercel.app/docs/concepts/runtime.md): The one object your code calls. Build it once, call it from your routes, your cron and your tests. - [Agents](https://intentface-latch-docs.vercel.app/docs/concepts/agents.md): A model, its instructions, and what it may do, declared once and resolved for each person. - [Principal, context and params](https://intentface-latch-docs.vercel.app/docs/concepts/inputs.md): What to pass where. Who is asking, what they can work with, what the chat is about, and what they're looking at right now. - [Storage](https://intentface-latch-docs.vercel.app/docs/concepts/storage.md): Where conversations, runs, usage and schedules live, in your own database, through an adapter. - [Tools and connections](https://intentface-latch-docs.vercel.app/docs/concepts/tools-connections.md): What an agent can act on. Your own functions, MCP servers, other services, and the credentials it never sees. - [Secrets (the vault)](https://intentface-latch-docs.vercel.app/docs/concepts/secrets.md): Per-customer API keys and sign-in tokens, encrypted in your database, used by your tools and never seen by the model. - [Server](https://intentface-latch-docs.vercel.app/docs/concepts/server.md): Ready-made HTTP routes over the runtime, mounted in any framework, if you'd rather not write your own. - [Channels](https://intentface-latch-docs.vercel.app/docs/concepts/channels.md): The same agent in Slack, Telegram and WhatsApp, with approvals and questions as native buttons. - [Extensions](https://intentface-latch-docs.vercel.app/docs/concepts/extensions.md): Your own hooks into a run. Block a tool, add a line the user sees, answer a command, without changing Latch. ### In depth - [Inside a turn](https://intentface-latch-docs.vercel.app/docs/concepts/turns.md): What goes into a turn, the three views of a message, compaction, and the order a turn runs in. - [The run log](https://intentface-latch-docs.vercel.app/docs/concepts/run-log.md): State is a fold over an append-only log of turns — which is why streaming, resume, audit, cost and one-turn-per-chat are all reads of the same record. ## Harder than it looks - [Overview](https://intentface-latch-docs.vercel.app/docs/hard-parts.md): The parts of an agent product that seem like an afternoon's work, and what they turn into once real users arrive. - [Conversation history](https://intentface-latch-docs.vercel.app/docs/hard-parts/history.md): Saving messages is easy. Two tabs, retries, regenerate and forged messages are what make it hard. - [Approvals](https://intentface-latch-docs.vercel.app/docs/hard-parts/approvals.md): An Approve button is one line. Clicking it tomorrow, twice, from Slack, is the rest. - [Running on many servers](https://intentface-latch-docs.vercel.app/docs/hard-parts/durability.md): A server dies mid-answer. Exactly one other server should finish it, not zero and not two. - [Who sees what](https://intentface-latch-docs.vercel.app/docs/hard-parts/access.md): Customers, users, teams, and the runs nobody is logged in for. - [Usage limits](https://intentface-latch-docs.vercel.app/docs/hard-parts/limits.md): Caps that hold when five requests arrive in the same moment. - [Files and images](https://intentface-latch-docs.vercel.app/docs/hard-parts/attachments.md): Where files live, how they reach the model, and what never leaves your servers. - [Streaming](https://intentface-latch-docs.vercel.app/docs/hard-parts/streaming.md): Words appearing as the model writes them. Then the user closes the tab, reloads, or sends another message. - [Schedules](https://intentface-latch-docs.vercel.app/docs/hard-parts/schedules.md): Every Monday at 9 sounds like a cron job. It is a run with nobody there, on every server at once. - [Connecting accounts](https://intentface-latch-docs.vercel.app/docs/hard-parts/connections.md): The agent should use the user's Linear. Signing in, keeping them signed in, and keeping their tokens away from the model. - [Subagents](https://intentface-latch-docs.vercel.app/docs/hard-parts/subagents.md): One agent handing work to another sounds like a function call. It's a second conversation that can pause, crash and cost money. - [Chat apps](https://intentface-latch-docs.vercel.app/docs/hard-parts/chat-apps.md): A Slack or Telegram bot is an afternoon's work. A bot your customers can rely on isn't. - [Agent versions](https://intentface-latch-docs.vercel.app/docs/hard-parts/agent-versions.md): Once agents live in a database, someone will edit one, break it, and need to know what was running last Tuesday. ## Guides - [Guides](https://intentface-latch-docs.vercel.app/docs/guides.md): How to do one specific thing with Latch, step by step. ### Build - [Gate a tool behind approval](https://intentface-latch-docs.vercel.app/docs/guides/approvals.md): Pause a run at a risky tool call, decide from any device or after a deploy, and resume — with no connection held open while waiting. - [Run agents on a schedule](https://intentface-latch-docs.vercel.app/docs/guides/schedules.md): Schedules are rows, not timers. Create one, make time pass, and decide what happens when a fire stops for a person. - [Deliver a scheduled brief to a channel](https://intentface-latch-docs.vercel.app/docs/guides/scheduled-brief.md): A cron-driven agent run, claimed exactly once across nodes, delivered into the user's own Telegram, WhatsApp or Slack thread. - [Who owns a conversation](https://intentface-latch-docs.vercel.app/docs/guides/ownership-patterns.md): Six patterns for whose conversations are whose. Private, shared, both, a database per customer, background runs, and support access. - [An agent your customers offer their users](https://intentface-latch-docs.vercel.app/docs/guides/agent-for-your-customers.md): You run a SaaS. Each customer puts your agent in front of their own users. Three layers of people, one runtime. - [Plans and limits](https://intentface-latch-docs.vercel.app/docs/guides/plans-and-limits.md): Give each plan its own caps on requests, tokens and cost, per team, person and agent, and tell users which one they hit. - [Connect other services](https://intentface-latch-docs.vercel.app/docs/guides/connections.md): Give an agent a SaaS service's tools by naming it — per tenant, OAuth once, secrets the model never sees. - [Agents in a database](https://intentface-latch-docs.vercel.app/docs/guides/agents-in-a-database.md): Agents your users create and edit, resolved per caller, with every published version kept and rollback by pointer. - [Write an extension](https://intentface-latch-docs.vercel.app/docs/guides/write-an-extension.md): Add a capability of your own — a veto, a notice, a slash command, a context lens — without touching the runtime. Moments, effects, and the three rules that make them compose. - [Chat apps in depth](https://intentface-latch-docs.vercel.app/docs/guides/channels.md): The same agent in Slack, Telegram and WhatsApp — one kernel for admission, identity and rendering; a platform is a parser plus a surface. ### Ship - [Mount in your framework](https://intentface-latch-docs.vercel.app/docs/guides/mount-the-handler.md): One Web-standard handler, mounted in Hono, Express, Fastify, NestJS, or any framework that speaks Request and Response. - [The chat UI](https://intentface-latch-docs.vercel.app/docs/guides/chat-ui.md): What a browser client owes the handler — streaming, markdown, approval cards, and the OAuth continuation protocol. - [Turn on crash recovery](https://intentface-latch-docs.vercel.app/docs/guides/crash-recovery.md): Leases, a heartbeat and a sweep, so an answer survives its server dying. What to configure and what happens. - [Deploy on Vercel](https://intentface-latch-docs.vercel.app/docs/guides/deploy-on-vercel.md): A Next.js app with Postgres, crash recovery, schedules and limits, on Vercel functions. - [Write your own storage adapter](https://intentface-latch-docs.vercel.app/docs/guides/storage-adapter.md): Keep Latch's data in your own schema or another database, and prove it keeps the same guarantees. ## Reference - [createRuntime](https://intentface-latch-docs.vercel.app/docs/reference/create-runtime.md): Every option createRuntime takes, with what it does and what happens without it. - [Runtime methods](https://intentface-latch-docs.vercel.app/docs/reference/runtime.md): What each method of the runtime does, with every input and result. - [defineAgent](https://intentface-latch-docs.vercel.app/docs/reference/define-agent.md): Every option an agent takes. - [Context and tools](https://intentface-latch-docs.vercel.app/docs/reference/context.md): The context function, and everything a tool receives as options.context. - [Vault](https://intentface-latch-docs.vercel.app/docs/reference/vault.md): createVault, its methods, and the secret store it keeps encrypted records in. ### Packages - [Server](https://intentface-latch-docs.vercel.app/docs/reference/server.md): createLatchApp and createLatchHandler from @intentface/latch-server, every option, and the routes they serve. - [Postgres and SQLite](https://intentface-latch-docs.vercel.app/docs/reference/drizzle.md): The storage adapters, migrations, limit stores, secret stores and agent stores in @intentface/latch-drizzle. - [Connections (MCP)](https://intentface-latch-docs.vercel.app/docs/reference/mcp.md): createMcpConnections, a connection's options, and signing in with OAuth, from @intentface/latch-mcp. - [Channels](https://intentface-latch-docs.vercel.app/docs/reference/channels.md): Every option for the Telegram, Slack and WhatsApp channels in @intentface/latch-channels. - [Agent store](https://intentface-latch-docs.vercel.app/docs/reference/agent-builder.md): The methods of the agent store from @intentface/latch-agent-builder, for agents kept in a database, with versions and candidates. ### Contracts - [Storage](https://intentface-latch-docs.vercel.app/docs/reference/storage.md): The StorageAdapter contract — the one seam you can't omit, and the guarantees it has to make. - [Hooks](https://intentface-latch-docs.vercel.app/docs/reference/hooks.md): The other options on createRuntime, for pricing, prompt caching, tracing, sandboxes and built-in tools. - [Errors and refusals](https://intentface-latch-docs.vercel.app/docs/reference/errors.md): The typed refusals the runtime raises, their stable codes, and how the HTTP handler maps them. - [Packages](https://intentface-latch-docs.vercel.app/docs/reference/packages.md): What each @intentface/latch-* package does, when you need it, and what it depends on. ## Experimental ## Memory - [Memory](https://intentface-latch-docs.vercel.app/docs/memory.md): Facts an agent keeps across sessions — extracted from idle conversations, scoped per agent, user or org, injected next turn.