Skip to main content
Services are the databases, caches, and third-party APIs your app talks to. They run inside each trial’s container, next to the app. You declare them on the runner. In each trial of an agent evaluation, lmnr-cli starts the services before your code runs. It runs their migrations and seeds them with the case’s data. Built-in services cover Postgres, ClickHouse, and Valkey. Simulated SaaS APIs, such as Slack, Linear, and GitHub, come from Rystic. For example, an app that uses Postgres, ClickHouse, Valkey, and Slack would declare the services below. Declare only the services your own app uses, at the versions it runs.
Example: evals/support/agent/eval.py

How services run

  • When the image is built, lmnr-cli copies each service’s binaries from the vendor’s official image, at the version you pinned. It also copies the service’s migrations into the image. Changes to your app don’t reinstall the services.
  • In each trial, before setup(), all services start in parallel. Each one runs on 127.0.0.1 as its own OS user, and logs to /logs/agent/<name>.log. Each service waits until it’s ready, runs its migrations, and loads the case’s seed. See the life of a trial. Then its connection env, such as DATABASE_URL, is added to all later commands, including your app’s.
  • If a service fails to start or migrate, the trial fails. The error shows the end of the service’s log.
Pin the version production runs. The version is required. "latest" works, but it prints a warning on each run. Point the app at the service through the app’s own config. Each service sets env vars from templates. The defaults are {"DATABASE_URL": "{url}"} for Postgres, CLICKHOUSE_URL for ClickHouse, and REDIS_URL for Valkey. Rename them to match your app’s config, for example:
Example
The templates are {url}, {host}, {port}, {database}, {user}, and {password}. A variable a service sets can’t also be in the runner’s env.

Migrations

migrations= takes the folder where your app keeps its schema. It can be anywhere in the repo. The path is relative to the file that declares the service. lmnr-cli copies the folder into the image, so --remote trials have it too. Editing a migration rebuilds one small last layer. Reproduce what the app’s own startup does, in the same order:
  1. Extra roles and databases.
  2. The migrations.
  3. Anything the app creates in code after the migrations. This goes in setup().
Your app may have no migrations, for example because another service manages its schema. Then create only the tables and columns that the tested code path needs. Put them in a SQL folder next to eval.py.

Seed data

seed= loads data into a service after its migrations and before setup():
  • seed=case_fixture("accounts.sql") loads each case’s own tests/fixtures/accounts.sql. The agent doesn’t see tests/ as files, and the seed is deleted from the container once loaded. A case without the file starts with empty tables. Pass required=True to make a missing file an error.
  • A plain path, seed="baseline.sql", loads the same file in all cases. Keep it inside the evals/ folder (see Where the code runs).
Some data needs computing, or comes from several files. Seed it in setup() instead, with the service’s helpers or with a script that ctx.container.run_file runs.

Postgres

Example
  • migrate="cd /srv/app && alembic upgrade head" runs your app’s own migration command instead of a SQL folder. It runs in the container with the service’s env.
  • migrate_at="build" runs plain SQL migrations while the image is built, so each trial starts from a migrated database.
  • source="pgvector/pgvector:pg16-bookworm" takes the binaries from a compatible image that has extras. Here, the extra is pgvector, enabled with extensions=["vector"].
  • Helpers:
    • await self.service(Postgres).query(ctx, sql) returns rows as dicts.
    • .execute(ctx, sql) runs SQL.
    • .insert(ctx, "users", rows) inserts a list of dicts.

ClickHouse

Example
  • By default, migrations run with the clickhouse-migrations CLI. It takes files named like 1_init.sql, and records the versions it applied in _migrations. If your app applies migrations some other way, use migrator="clickhouse-client". It runs all *.sql files in natural order.
  • config= and users= merge production’s server and user settings over the defaults. Keep the ports in these files the same as http_port and tcp_port. Leave the default user without a password.
  • Helpers: .query(ctx, sql), .execute(ctx, sql), and .insert(ctx, table, rows).

Valkey

Valkey("8") runs a Redis-compatible server and sets REDIS_URL. Its helper sends one command: await self.service(Valkey).cmd(ctx, "SET", "k", "v").

Other services

For anything else you can run in the container, declare a custom service. For example, say production serves your app behind nginx. Then you can run nginx in front of the app in the container. This example installs nginx from Debian’s packages, with a config that proxies to the app:
Example: evals/support/agent/eval.py
  • install=[...] adds Dockerfile lines to the final image. Here, they install the package and write the config file. To copy a binary from another image instead, pass that image as source= and the paths as bundle=[paths]. lmnr-cli copies those paths and the shared libraries they need.
  • start must stay in the foreground. That’s why nginx gets daemon off;. A process that exits counts as crashed.
  • ready and port tell the runner when the service is up and what {url} is.
Your app may have an in-memory or local-disk fallback for a queue or a cache. If production also supports that fallback, you can use it in evals by leaving the queue’s or cache’s URL unset.

Simulated SaaS APIs with Rystic

A simulator answers in place of a third-party API, such as Slack, Linear, or GitHub. The app talks to it through its usual base-URL setting. Each case seeds the simulator with its own data. verify() reads what the app did to it. Rystic simulators run inside the trial’s container like any other service. For example, the quickstart’s example seeds a Slack workspace for each case:
Example: evals/billing/agent/eval.py
  • version pins the simulator. Each trial downloads that version before it starts.
  • seed=case_fixture("slack.json") loads the case’s workspace: its users, channels, and messages. A case without the file starts with an empty workspace.
  • env templates take {url} and {port}. Point your app’s existing base-URL setting at the simulator. The example uses SLACK_API_URL to point the official Slack SDK at it.
In verify(), read what the app did. For example:
Example
In run(), await slack.settle(ctx) waits until the app has stopped calling the simulator. With a separate verifier, set snapshot=True, so the state and the calls are saved after the run.

Rystic access

  • Local runs use your own Rystic API key. Create one at rystic.ai. Slack, Linear, and GitHub are on the free plan. Put the key in .env as RYSTIC_TOKEN. lmnr-cli eval run passes it to the trials of datasets that have a Rystic simulator. Without the key, it stops before building anything, with exit code 19.
  • --remote runs don’t need your key. Laminar gives each trial its own access to Rystic.
Don’t put RYSTIC_TOKEN in the runner’s env or secrets. On a --remote run, it would replace the trial’s own access.

Base image compatibility

Services need glibc 2.36 or newer in the image: Debian bookworm or trixie, or Ubuntu 24.04. The Image builder’s bases are all trixie. On an older base, pass an official image built on an older distribution as source=, such as Postgres("16", source="postgres:16-bullseye"). Alpine images can’t run services. ClickHouse’s default migrator needs glibc 2.38 (trixie, Ubuntu 24.04). On a bookworm base, pass migrator="clickhouse-client". Otherwise, the build stops with that hint.

Next steps

Mocks

Answer for an internal service or an observed function.

Match production

What to run for real, what to simulate, and what to mock.

Write eval.py

The runner’s attributes, its phases, and the ctx API.

Build the image

Bases, dependencies, and source, or an existing Dockerfile.