Skip to main content
Most agent code starts as a loop around a model call, and then production asks for more: a human has to approve the refund before it is sent, the process restarts halfway through a run, the conversation has to continue tomorrow from another server, and somebody wants a test that fails when the agent stops calling the right tool. @lousho/build-ai-agent is that loop with those answers built in. It is a library, with no web framework and no hosted runtime: a typed tool-calling loop with approvals, sessions, streaming, sub-agents, skills, MCP and a CLI. The same agent runs in a script, a Node server, a Docker container or a Cloudflare Worker.

What sets it apart

Durable on any host

Sessions, checkpoints and approval pauses live in pluggable stores: memory, files, one SQLite file, or Cloudflare KV. A paused or interrupted run resumes from another request or another process.

Tested like code

mockModel scripts the model, recordReplay cassettes replay real runs offline, and defineEval() asserts on which tools were called, in what order, with which arguments.

Node and Workers, traced

lousho build ships one agent spec to a Node server, Docker or a Worker. Runs emit OpenTelemetry GenAI spans, and every result reports token usage and USD cost.

The building blocks

Each block is one function or one option on createAgent(). Use the ones you need; none of them requires the others.

Where an agent can live

The agent is the same object everywhere. What changes is the surface in front of it.

In a web app

useLoushoAgent() for React and Vue, a store for Svelte, the Vercel AI SDK’s useChat, or createRouteHandler(agent) in any Fetch-API framework.

In chat and on a schedule

Slack, Discord, webhooks and plain HTTP channels map messages to sessions and send approvals back. Cron schedules start runs on their own.

In an editor

lousho acp serves your agent to Zed and other Agent Client Protocol editors, with tool calls and permission prompts.

As a deployed service

lousho build produces a Node server, a Docker image or a Cloudflare Worker from one spec.

Next steps

  • Quick start: scaffold a project, or run the five-line agent. The snippets run offline with the built-in mock provider.
  • Installation: requirements, peer dependencies, and which provider package pairs with which ai major.
  • Tools: define your first tool and see how arguments are validated.
  • Approvals: pause a run for a human decision and resume it.
  • Testing: write a deterministic test for an agent without an API key.
  • Lousho with coding agents: point Claude Code, Cursor or another coding agent at docs it can read.