Skip to main content

Lanternfish docs

Build from first trace to first briefing

Browse documentation

Guide

Changes and the CI check

A change is a new release, a new model or a new prompt version. Lanternfish compares the runs after the change with the runs before it and gives one verdict: Ship, Review, Block or Not enough data. Your CI can read that verdict and stop a deploy that regressed.

1. Tag runs with the release

Every span carries the release of the code that produced it. Pass it to instrument(), or let the SDK read LANTERNFISH_RELEASE or your CI's commit variable (GITHUB_SHA and others; see Configuration).

from lanternfish import instrument

instrument(
    api_key="YOUR_API_KEY",
    endpoint="https://your-lanternfish-api",
    release="v1.8.2",
)

2. What is compared

The latest release is compared with the release before it, using runs from the last 30 days. Each side needs at least 30 runs, and "no regression" needs enough runs to rule one out: about 355 per side to rule out an 8% drop from a 90% success rate. Quality means run duration, success rate and cost per run; behavior means how often each tool is called; quality scores you record with lanternfish.score() are compared too, and a drop of 5 points or more blocks the release. A difference counts only when it is outside normal variation at 95% confidence, corrected for the number of checks.

VerdictWhen
regressedBlock. Run duration, success rate or cost per run got worse, beyond normal variation (95% confidence, corrected for the number of checks).
changedReview. Quality held, but the agent behaves differently: a tool is called in at least 10 points more or fewer runs, or 25% more or fewer times per run.
improvedShip. A quality metric got better, beyond normal variation, and nothing regressed.
no_changeShip. No difference passed the thresholds, and there are enough runs to rule out a regression.
insufficient_dataNot enough data. No regression was found, but there are too few runs to rule one out yet; the verdict says how many runs are still needed.

The Changes page in the app shows the verdict, each metric with its difference and 95% interval, every finding with its numbers, what changed (model, prompt version), error types that are new or gone, the share of runs on the new side and example runs. Runs still in progress are left out until they finish.

When the latest release regresses, owners and admins of the organization get one email about it, and the same message is posted once to each channel in Settings → Notifications. The release is checked every 15 minutes, and checking again and again would raise false alarms, so until it has enough runs only very strong evidence (99.9%) sends the alert. Once it has enough runs it is checked one final time at 95% and then left alone.

3. Check a release from the command line

The SDK installs a lanternfish command. It reads LANTERNFISH_API_KEY and LANTERNFISH_ENDPOINT.

lanternfish verdict --release v1.8.2

# also stop on a behavior change (Review)
lanternfish verdict --release v1.8.2 --fail-on changed

# let it through while there are not enough runs yet
lanternfish verdict --release v1.8.2 --allow-insufficient

# compare only runs from one environment, e.g. your test suite in CI
lanternfish verdict --release v1.8.2 --environment ci

# a model switch: runs that used gpt-4.1 vs runs of the model used before it
lanternfish verdict --model gpt-4.1 --environment ci

# a prompt change: runs inside set_prompt_version("support-v3") vs the version before it
lanternfish verdict --prompt support-v3 --environment ci

A model switch needs no release tag. The model comes from the LLM calls the SDK records, so moving from one model to another is judged like a release, against the model used before it. A prompt that changes without a deploy is judged the same way when the agent runs inside lanternfish.set_prompt_version("support-v3").

Exit codeMeaning
0Ship, or Review unless you pass --fail-on changed. The first release, with nothing to compare, also passes.
1Block, or Review when you pass --fail-on changed.
2No verdict: the API key or endpoint is missing, or the API could not be reached.
3Not enough runs to rule out a regression yet. Pass --allow-insufficient to let it through.

4. Check a release before you deploy it

Run a fixed set of at least 30 inputs through your agent in CI, tagged with the release and environment="ci". The verdict then compares this release's CI runs with the previous release's CI runs, so a regression stops the pipeline before any user sees it. Production runs are never mixed in.

Give each input a fixed id with lanternfish.set_case(). When both sides ran the same cases, the verdict compares each case with itself: McNemar for success, paired tests for duration, cost and scores. Most cases give the same result on both sides, so it needs fewer runs to rule out a regression, and it counts the cases that passed before and fail now. Tool use is judged only without pairing.

# tests/agent_suite.py — runs in CI before deploy
import os
import lanternfish
from lanternfish import instrument

instrument(release=os.environ["GITHUB_SHA"], environment="ci")

for case in load_cases("tests/agent_cases.jsonl"):  # your own inputs, 30 or more
    with lanternfish.set_case(case["id"]):          # the same id on every release
        run_agent(case["input"])
# .github/workflows/deploy.yml (steps before deploy)
- name: Run the agent test suite
  run: python tests/agent_suite.py
  env:
    LANTERNFISH_API_KEY: ${{ secrets.LANTERNFISH_API_KEY }}
    LANTERNFISH_ENDPOINT: ${{ vars.LANTERNFISH_ENDPOINT }}
- name: Stop the deploy if the release regressed
  run: lanternfish verdict --release "$GITHUB_SHA" --environment ci
  env:
    LANTERNFISH_API_KEY: ${{ secrets.LANTERNFISH_API_KEY }}
    LANTERNFISH_ENDPOINT: ${{ vars.LANTERNFISH_ENDPOINT }}

The first release run this way has nothing to compare with yet, so its verdict is "not enough runs" and the gate stays open. After that, a release with too few runs to rule out a regression exits 3. The Changes page counts runs from every environment; the regression email uses only runs labelled environment="production" when your project has them.

5. Or check it after a canary

Without a test suite, run the check after the new release has served enough real traffic, for example in a canary stage, and before promoting it. A non-zero exit code fails the job.

- name: Check the release with Lanternfish
  run: |
    pip install lanternfish
    lanternfish verdict --release "$GITHUB_SHA" --environment production
  env:
    LANTERNFISH_API_KEY: ${{ secrets.LANTERNFISH_API_KEY }}
    LANTERNFISH_ENDPOINT: ${{ vars.LANTERNFISH_ENDPOINT }}

6. Get it in Slack or your own service

In Settings → Notifications, owners and admins add a Slack incoming webhook or any https address. A webhook receives a JSON POST (event, title, lines, link, data, sent_at) signed with the channel's secret in the X-Lanternfish-Signature header as t=<unix time>,v1=<hex>. Verify it before trusting the body:

import hashlib, hmac

def is_from_lanternfish(secret: str, header: str, body: bytes) -> bool:
    parts = dict(item.split("=", 1) for item in header.split(","))
    expected = hmac.new(secret.encode(), f"{parts['t']}.".encode() + body, hashlib.sha256).hexdigest()
    return hmac.compare_digest(expected, parts["v1"])

Addresses that resolve to a private network are refused, and redirects are not followed. Each channel shows the result of its last message.

7. Know before a model shuts down

The Models page lists the models your runs used in the last 7 days with their share of runs, cost per run and quality scores, and the shutdown date OpenAI or Anthropic has announced for each, with the recommended replacement and a link to the provider's page. An alias such as gpt-4o is checked through the snapshot that answered it (gen_ai.response.model), so gpt-4o-2024-08-06 is flagged even if your code never names it. Bedrock and Google Cloud keep their own schedules and are not checked.

Before the date, send some runs to the replacement, for example your CI suite with the new model. The switch is a model change of its own, and its verdict tells you whether to ship it:

lanternfish verdict --model gpt-6-luna --environment ci