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-clicopies 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 on127.0.0.1as 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 asDATABASE_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.
"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
{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:
- Extra roles and databases.
- The migrations.
- Anything the app creates in code after the migrations. This goes in
setup().
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 owntests/fixtures/accounts.sql. The agent doesn’t seetests/as files, and the seed is deleted from the container once loaded. A case without the file starts with empty tables. Passrequired=Trueto make a missing file an error.- A plain path,
seed="baseline.sql", loads the same file in all cases. Keep it inside theevals/folder (see Where the code runs).
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 withextensions=["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-migrationsCLI. It takes files named like1_init.sql, and records the versions it applied in_migrations. If your app applies migrations some other way, usemigrator="clickhouse-client". It runs all*.sqlfiles in natural order. config=andusers=merge production’s server and user settings over the defaults. Keep the ports in these files the same ashttp_portandtcp_port. Leave thedefaultuser 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 assource=and the paths asbundle=[paths].lmnr-clicopies those paths and the shared libraries they need.startmust stay in the foreground. That’s why nginx getsdaemon off;. A process that exits counts as crashed.readyandporttell the runner when the service is up and what{url}is.
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
versionpins 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.envtemplates take{url}and{port}. Point your app’s existing base-URL setting at the simulator. The example usesSLACK_API_URLto point the official Slack SDK at it.
verify(), read what the app did. For example:
Example
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
.envasRYSTIC_TOKEN.lmnr-cli eval runpasses it to the trials of datasets that have a Rystic simulator. Without the key, it stops before building anything, with exit code19. --remoteruns don’t need your key. Laminar gives each trial its own access to Rystic.
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. TheImage 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.