DEV Community

Grzesiek
Grzesiek

Posted on Fully Autonomous

Compare Two AI Prompts on the Same Inputs With a Tiny Regression Test

Disclosure: This article was generated with AI. The Python example was tested with fictional data. Prompt Secure, mentioned at the end, is our product.

When a new prompt sounds smoother, that doesn't tell me whether it handles missing information better. Here's a small regression test for a concrete job: turning meeting notes into one next action.

1. Pick one normal case and one failure case

Case Fictional meeting note What a good result preserves
Known The purchasing team will compare supplier quotes by 2026-12-18. Purchasing team; 2026-12-18.
Unknown Compare supplier quotes. No owner or date was agreed. Both values stay unknown.

The second case is the important one. A plausible guess can assign work nobody accepted.

2. Change one instruction

Prompt A

Extract one action from the note. Return only a JSON object with the keys task, owner, and due_date. Write the task in English. Use YYYY-MM-DD for a known due date.

Note: [meeting_note]
Enter fullscreen mode Exit fullscreen mode

Prompt B uses the same text, with this instruction before the note:

Set owner and due_date to JSON null when the note does not explicitly provide them. Copy the named role without adding a person or a role.
Enter fullscreen mode Exit fullscreen mode

Run both prompts on both notes in fresh conversations. Keep the model and settings the same. Save the raw responses as a-known.json, a-unknown.json, b-known.json, and b-unknown.json. If the model wraps a response in Markdown fences, leave the fences in the file: raw JSON is part of the contract.

3. Run the check

Save the script as check.py next to the response files and run python check.py.

import json
from pathlib import Path

ROOT = Path(__file__).resolve().parent
CASES = {"known": ("Purchasing team", "2026-12-18"), "unknown": (None, None)}
KEYS = {"task", "owner", "due_date"}


def check(filename, expected_owner, expected_due):
    try:
        result = json.loads((ROOT / filename).read_text(encoding="utf-8"))
    except (OSError, UnicodeError, json.JSONDecodeError) as error:
        return f"cannot read a JSON object ({type(error).__name__})"

    if not isinstance(result, dict) or set(result) != KEYS:
        return "wrong keys"
    if not isinstance(result["task"], str) or not result["task"].strip():
        return "missing task"
    owner = result["owner"]
    if isinstance(owner, str):
        owner = owner.strip().casefold()
    target_owner = expected_owner.casefold() if expected_owner else None
    if owner != target_owner:
        return "wrong owner"
    if result["due_date"] != expected_due:
        return "wrong due date"
    return "pass"


for variant in ("a", "b"):
    for case, (owner, due) in CASES.items():
        filename = f"{variant}-{case}.json"
        print(f"{filename}: {check(filename, owner, due)}")
Enter fullscreen mode Exit fullscreen mode

For the unknown case, this response passes:

{"task":"Compare supplier quotes","owner":null,"due_date":null}
Enter fullscreen mode Exit fullscreen mode

Changing the owner to "Purchasing team" makes it fail. These are fixture examples, not measured results from a model benchmark.

4. Check what the script can't

The script checks the fields we can verify precisely. It would accept "task":"Approve supplier quotes" if the other fields were correct. Compare the action to the source yourself. If the variants behave identically, add a case where the team discussed a date without agreeing on it. Repeat important cases to see whether the behavior is consistent.

Save the prompt, input cases, and your results together. Plain files or Git work fine. If you already reuse prompts across devices, the Prompt Secure interactive example shows how to fill a field such as [meeting_note] before copying the prompt.

Top comments (0)