Sub topic 13
Live smoke tests, and why they are not evals
This chapter assumes you have read the earlier chapters on the client seam, the scripted fake, and recorded responses. You should be comfortable with pytest markers and environment variables.
Fakes and recordings keep your test suite fast and deterministic. They also share a weakness: both only prove your code works against replies you already have. If the provider renames a field, retires a model, or changes how errors look, offline tests stay green. A small live test closes that gap.
What a smoke test checks
A live smoke test sends one or two real requests through the real client and checks only that the plumbing works. It answers questions like these:
- Does the API key authenticate?
- Does the configured model name still exist?
- Does the SDK still accept the request shape you send?
- Does the reply still have the structure your parser expects?
It does not judge whether the answer is good. The assertions are loose and structural, because the output changes on every run.
import json
import os
import pytest
from myapp.clients import make_real_client # your factory that wraps the SDK
from myapp.invoices import extract_total
pytestmark = pytest.mark.live
requires_key = pytest.mark.skipif(
not os.environ.get("LLM_API_KEY"),
reason="LLM_API_KEY not set; skipping live smoke test",
)
@requires_key
def test_live_reply_is_parseable_json():
client = make_real_client()
reply = client.complete('Reply with exactly this JSON and nothing else: {"total": 1}')
data = json.loads(reply)
assert "total" in data
@requires_key
def test_live_extract_total_returns_a_number():
client = make_real_client()
total = extract_total(client, "Invoice 17. Total due: $42.50")
assert isinstance(total, float)make_real_client stands for your own factory. The second test does not assert total == 42.5. A model might misread the text, and that would be a quality question. The test only asserts that a float came back, which shows the call and the parser still fit together.
Register the marker so pytest does not warn about it, and exclude it from the default run:
[tool.pytest.ini_options]
markers = ["live: calls the real LLM API; needs credentials and costs money"]
addopts = "-m 'not live'"Run the smoke tests on demand with pytest -m live. Passing -m live on the command line overrides the -m 'not live' default in addopts, because the last -m wins.
Where smoke tests run
Keep the live suite tiny: a handful of calls, short prompts, and the cheapest model that exercises the same code path. Run it on a schedule or before a release, not on every push. Two practical rules apply:
- Use a separate API key with a spending cap for tests.
- Make failures easy to read. A 401 means a credential problem, a 404 on the model means the model name is stale, and a
KeyErrormeans the reply shape changed.
A smoke test can fail for reasons unrelated to your code, such as rate limits or provider outages. Treat one red run as a signal to look, and avoid blocking merges on it.
Why this is not an eval
A smoke test and an eval both call a real model, so they look alike. They answer different questions.
| Row | Live smoke test | Eval |
|---|---|---|
| Question | Does the integration still work? | Is the output good enough? |
| Input | One or two fixed prompts | A dataset of many cases |
| Pass condition | Structural: valid JSON, expected keys, no exception | Scored: accuracy, rubric grade, or comparison to a baseline |
| Result | Pass or fail | A number you track over time |
| Cost | Cents | Can be substantial |
A passing smoke test says nothing about quality. The model could return {"total": 0} for every invoice and the test above would pass. An eval would catch that, because it compares many answers to known-correct ones. An eval can also fail to catch a broken integration if its harness hides errors. You need both, and neither replaces the offline tests.
Exercise
A teammate says, "Our live smoke test passes every night, so our invoice extraction is accurate." What is wrong with this claim, and what would you add to support it?
Show answer
The smoke test only checks structure: the call succeeds and the reply parses into a float. It would pass even if every extracted total were wrong. To support a claim about accuracy, build an eval: a dataset of invoices with known correct totals, run the extraction on each one, and track the fraction that match.