Skip to Content
Levain LabsLevain Labs

Agents

Create, version, and manage your AI agents.

An agent is the unit you deploy on Levain. It has a name, a slug, a description, a lifecycle, and one or more versions. This guide covers the workflow end to end.

Create an agent

Building an agent needs the Team plan or above — Free workspaces get the Levain agent only; see Plans & Billing. On Team and up, the dashboard's Agents page lists everything you've shipped and has a New agent button for spinning up the next one. Give the agent a name and a short description — Levain derives a URL-safe slug you'll use everywhere the agent is referenced.

The same flow is available from the API for scripting:

curl -X POST https://api.levainlabs.com/api/v1/agents \
  -H "Authorization: Bearer $LEVAIN_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "Support triage",
    "description": "Routes inbound tickets to the right queue."
  }'

The response includes the agent's id, its slug (e.g. support-triage), and its first version (version 1, status: draft). Slugs are unique per workspace and safe to hard-code in application configs.

Reference an agent

You can reference an agent by either its id (a UUID) or its slug. The slug is usually the better choice — it's stable, human-readable, and the same across environments if you keep your agent names in sync.

# Both of these work
curl https://api.levainlabs.com/api/v1/agents/support-triage
curl https://api.levainlabs.com/api/v1/agents/3f7a...c2e1

Find agents

GET /api/v1/agents/ lists every agent in the workspace. To look up a few, filter it: slug and id repeat and match any value given, kind is customer, managed or observed. Filters combine with AND, and a filter that matches nothing returns [], not 404.

curl "https://api.levainlabs.com/api/v1/agents/?slug=support-triage&slug=billing-bot"

The MCP list_agents tool takes the same filters.

Version an agent

Every material change to an agent creates a new version. Versions are numbered, they have their own status (draft → active → archived), and each one is pinned to a specific revision of the agent's recipe repo.

Create a new version with POST /api/v1/agents/{agent_id}/versions and promote it by updating its status. Production runs go against the agent's currently active version, which means you can roll a change forward or backward without changing any client code.

The Recipe tab opens on every version of the agent, newest first, with what each one does, the improvements it was built from, and how it did in production: finished runs, success rate, the credits its runs and its build used, and the mean reward under the agent's objective. Pick a version to open its recipe. The same data is available from GET /api/v1/agents/{agent_id}/versions and GET /api/v1/agents/{agent_id}/version-stats.

See the API reference for the full version schema.

Let Levain build the next version

Finished runs are reviewed for recurring problems: every failed run, the first run of each new version, and otherwise at most one run every four hours per agent. The problems worth fixing show up as Suggested improvements on the agent's Recipe tab. From there you can start a new version yourself, or turn on Improve automatically under Config → Settings and let Levain do it: once the suggestions have been triaged, it forks a draft off the active version, builds it from those suggestions, verifies it, and publishes it when verification passes. You get a notification either way. A version that does not pass stays a draft for you to review, and nothing further is built until every draft is published or archived. It waits a day after any new version, yours or its own, before building the next one, and each build is billed like any build.

To roll back, archive the version: runs go to the most recent active one.

An agent your organization publishes to several workspaces works the same way, from its own Recipe tab. Each adopting workspace's runs are reviewed in that workspace; a finding that comes from the recipe rather than from one workspace's data or setup is listed as a suggestion on the org agent, for every workspace that uses it, and is what an automatic build addresses. Findings specific to one workspace stay there. A published automatic version becomes the active one, so adopting workspaces without a version pin follow it on their next run; to roll back, activate an earlier version. Builds run in, and are billed to, your organization's first workspace. See the org agents API for the settings, suggestions and pins.

Send suggestions to GitHub

An agent whose recipe lives in your own repository is improved there: its contract is set by the service it ships with, and a fix often touches both. Pick that repository under Suggestions to GitHub (Config → Settings; the list is what the Levain GitHub App installed on the workspace reaches, so connect GitHub under Integrations first) or set github_issues_repo (owner/name) in the agent's config, and Levain files each triaged suggestion as an issue there, labelled agent-optimizer, with the finding, the axes, the versions it was seen on next to the latest published one, and the latest evidence. When the recipe is one directory of a larger repository, name it after a colon, owner/name:agents/assistant, and each issue says where the recipe lives. Whatever you run on your issues takes it from there, and your pipeline publishes the next version.

The two sides stay in step. A suggestion dismissed on Levain closes its issue with a comment, and so does one the triage merged into another. Closing the issue closes the suggestion once a version published after the close is live, so a fix still on its way to production is not refiled. It closes at once when a comment names the live version that holds the fix (fixed in v12), or when you close it as not planned. A behaviour that recurs afterwards comes back as a new issue.

A suggestion the observer has stopped seeing closes on its own, as not seen since v<K>: three versions published since its last sighting, and ten runs observed on them. Such a suggestion is never filed, so pointing an existing backlog at a repository files only what still happens.

The Levain GitHub App must be installed on the repository, which is checked when you set the value. While it is set, Improve automatically builds nothing: the recipe has one home.

For an agent your organization publishes to several workspaces, the setting sits above its versions on the org agent's page and files the suggestions that apply to the recipe, from every workspace that adopts it, through your organization's first workspace's GitHub integration. An org agent published from a source archive is treated the same way even without the setting: Levain does not build on top of a version your pipeline uploaded, since the next upload would undo it. Building a version in the app hands the agent back.

Agent lifecycle

Agents themselves also have a status:

StatusWhat it means
draftBeing authored. Can't be triggered from production.
activeAvailable for runs. This is the default for everyday agents.
pausedTemporarily blocked from new runs. Existing runs finish.
archivedRetired. Keeps history for audit, but no new runs allowed.

Move between states with PATCH /api/v1/agents/{agent_id}.

Agent settings

Each agent has a Settings card in the dashboard where you configure run limits and notification behaviour. You can:

  • Set a wall-clock timeout, a cost budget, and a step limit — the harness enforces these on every run.
  • Enable Run notifications to receive an in-app alert (and optionally an email) when a run completes or fails. The toggle is off by default; see the Runs guide for how to configure which channels each notification type uses.
  • Turn off Notify on new message when your own system relays the agent's questions and replies to people. It is on by default: an alert each time the agent hands a conversation back to you.
  • Turn on Improve automatically to let Levain build and publish the agent's next version from its suggested improvements. See Let Levain build the next version.
  • Set Suggestions to GitHub to file them as issues in your own repository instead, for a recipe you keep there. See Send suggestions to GitHub.
  • Pick an icon and accent color so the agent is recognizable at a glance in the agents list and its detail header. Leave both unset and the agent falls back to a colored initial.

These settings can also be written through the API as part of an agent update:

curl -X PATCH https://api.levainlabs.com/api/v1/agents/support-triage \
  -H "Authorization: Bearer $LEVAIN_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"config": {"notify_on_run": true}}'

Observed agents

An observed agent is a coding CLI, Claude Code or Codex, working in a repository on a machine you connected. Levain records each of its sessions as runs and never runs it: it has no recipe, triggers or schedules. Its versions are the successive states of the instruction files it reads, and Levain's suggestions are about those files. It appears with kind observed, and personal is true when only you can see it. Environments covers how to switch one on.

Managed agents

Some agents are operated by Levain rather than authored by you — you don't write or version their recipes, and Levain maintains their behavior. They still run, schedule, and report like any agent you built.

The Levain agent

Every workspace comes with the Levain agent already adopted — a managed assistant that Levain operates on your behalf. You don't author or version it; it's always available and always reflects the current platform.

You reach it from the dashboard or by tagging the Levain Slack app in any channel it's invited to. In Slack's Agents & AI Apps pane you can start a direct conversation with it at any time.

The Levain agent does the work itself first: it answers questions, grounds business-number questions in your synced app data, searches the web for anything the workspace doesn't hold, and recalls past sessions instead of asking you to repeat yourself. It only hands a task off to another agent you've built when that agent clearly owns the job — it's an assistant, not just a router.

On the Free plan, the Levain agent is the whole story — see Plans & Billing. Building, template adoption, and managed-agent adoption all start on Team.

The managed-agent catalog

Beyond the Levain agent, Levain ships ready-made analysts you adopt instead of build. Adopting one — like building your own agent — requires a platform app connected — see Integrations — before it can be adopted:

AgentSlugNeedsWhat it does
Revenue Analystrevenue_analystStripeAnswers revenue questions and drafts digests from your synced Stripe data — MRR movement, failed charges, past-due invoices. Reads only; it can't move money.
E-commerce Analystecommerce_analystShopifyWatches orders and listings — abandoned checkouts, stuck orders, underselling listings. Proposes store changes; only executes what you explicitly approve.

GET /api/v1/managed-agents lists everything available to your workspace and whether you've already adopted it. Adopt one with POST /api/v1/managed-agents/{slug}/adopt or the adopt_managed_agent MCP tool — returns 409 if the agent isn't adoptable yet (missing integration, no published recipe, or already adopted). Once adopted, the agent appears in your agent list with kind managed and behaves like any agent you built: schedule it, talk to it, watch its runs. There's no in-dashboard catalog browser yet, so adoption is API- or MCP-only for now.

What's true for every managed agent

  • Runs on Levain's account and doesn't count against your run limits.
  • Not editable — you can't change its recipe or instructions.
  • Can be given access to your workspace integrations the same way any agent you built can.

Next

On this page