Catch Local Prompt Regressions with Promptfoo and Ollama in 5 Steps

Catch Local Prompt Regressions

A prompt can look better in one chat and quietly break another input. A tiny regression suite makes that trade-off visible before you replace the prompt in an application.

This walkthrough uses Promptfoo to test a local Ollama model on a deliberately narrow task: classify a support request as billing or technical. There is no cloud model or model-based grader in the configuration below. The examples are documentation-based, not a report of personally executed tests; a small model may fail some cases.

1. Check the runtime and download a local model

Have Ollama installed and running first. On macOS, use the Ollama app; on Linux, use your existing Ollama service. If you installed only a standalone binary, ollama serve starts the server in a separate terminal. Do not start a second server over an existing service.

Promptfoo currently requires Node.js 22.22.0 or newer and recommends Node.js 24 LTS. Verify your runtime, then pull the documented Llama 3.2 model:

node --version
ollama pull llama3.2
ollama ls
npx promptfoo@latest --version

The model download and npm package retrieval require network access. Local inference still consumes RAM, CPU or GPU time and electricity; it is not costless merely because it avoids a hosted model bill. The default Llama 3.2 tag uses the 3B model. Check the model library and its license before commercial use or redistribution.

2. Create a small, explicit evaluation

In a new working directory, save this as promptfooconfig.yaml. These synthetic messages contain no customer information.

description: Local support routing regression check
prompts:
  - >-
    Classify this support request. Reply with exactly billing or technical,
    in lowercase, without explanation. Request: {{request}}
providers:
  - id: ollama:chat:llama3.2
    config:
      temperature: 0
      num_predict: 32
tests:
  - vars:
      request: I was charged twice for my subscription.
    assert:
      - type: equals
        value: billing
  - vars:
      request: The JavaScript application crashes when I log in.
    assert:
      - type: equals
        value: technical
  - vars:
      request: Please send me an invoice for last month.
    assert:
      - type: equals
        value: billing

The Ollama provider sends chat requests to the local server. An equals assertion deliberately treats extra explanation or a different label as failure. That is useful when downstream code expects one exact string. Temperature zero reduces sampling variability; it is not a universal reproducibility guarantee across hardware, model revisions or runtime versions.

3. Run fresh calls, then inspect the failures

In a macOS or Linux shell, select the loopback endpoint explicitly. These optional environment settings disable Promptfoo usage telemetry and its update check; they do not block npm downloads.

export OLLAMA_BASE_URL=http://127.0.0.1:11434
export PROMPTFOO_DISABLE_TELEMETRY=1
export PROMPTFOO_DISABLE_UPDATE=1
npx promptfoo@latest eval -j 1 --no-cache
npx promptfoo@latest view

Serial target calls (-j 1) are easier on a small machine. --no-cache matters when checking actual rerun behavior: Promptfoo otherwise caches successful responses. Read its caching guide before interpreting an unchanged result as new model evidence.

If a case fails, inspect the actual response. Was the label wrong, or did the model add punctuation? Those are different defects. Do not silently loosen assertions merely to make the score green.

4. Compare one prompt change at a time

Target calls per fresh evaluation. Bar chart: One prompt × three tests 3, Two prompts × three tests 6
© juzhax.com

Add a second item under prompts with a clearer routing rule: invoices, charges and refunds go to billing; crashes and application errors go to technical. Keep the same provider and tests, then rerun the evaluation.

With two prompts, one provider and three test cases, this simple configuration defines six target calls per fresh evaluation. It uses deterministic assertions, so it does not add a separate LLM judge. Adding hosted providers or model-graded checks would change the data flow and possible charges.

Before using a winning prompt, add real failure patterns with identifying details removed. Include ambiguous requests and decide what your application should do with them. A two-label toy task has no safe fallback yet; production routing may need an unknown label and human review.

5. Save the evidence, not just the winning wording

Keep the YAML, your prompt-change rationale, the observed Promptfoo version and model details together in version control. The getting-started commands use @latest for convenience; once you establish a baseline, record and pin the exact dependency version in your project rather than allowing invisible upgrades.

Keep raw evaluation history out of a public repository. Promptfoo stores configuration, history and cached results under ~/.promptfoo by default. Disabling the provider cache does not mean no evaluation history exists. Its telemetry documentation separately explains what usage events contain.

Done means: you can identify which inputs regressed, explain why each assertion exists and reproduce the configuration. Three passing examples are a smoke test, not proof of reliability or security. For a different local workflow, see the existing Ollama and Zod extraction tutorial; this article tests behavior rather than implementing extraction.

Sources checked November 24, 2026. The linked documentation pages do not expose original publication dates. No benchmark or personal testing claims are made.


Discover more from Juzhax Technology

Subscribe to get the latest posts sent to your email.

Leave a Reply