Skip to content
DenseChip
Learn
PracticeCode labInterview

DenseChip

Navigate

Menu

LearnPracticeCode labInterview

Tools

All toolsSV editorCode repoResume
DenseChip

Practice, courses, and chip-design tools in one focused workspace.

LearnPracticeCode labInterviewToolsLearning paths

© 2026 DenseChip

AboutContactPrivacyTerms
Skip to lesson

Course contents

  • Getting Started with AI for VLSI Engineers5
  • Just Enough AI: Models and Context15
  • Prompting13
    • Anatomy of a Prompt
    • Examples and Reasoning
    • Prompt Debugging
      • Diagnose the Failure First
      • Change One Thing at a Time
      • Keep a Small Set of Test Prompts
      • A Prompt Regression Harness
  • Trust and Verification14
  • Using AI for Engineering Work17
  • Engineering Walkthroughs7
  • Practical Foundations for AI Workflows4
  • Engineering Data5
  • Retrieval-Augmented Generation6
  • Agents and Tool Use18
  • Agent Design8
  • MCP and Skills6
  • Multi-Agent Design6
  • Practical Capstone6
  • Tokens, Cost and Latency12
  • Agentic Workflows for Chip Teams18
  • Interview and Judgment10
  • AI Skills: Full Course Index
  • Working with AI Glossary
  • Working with AI Cheatsheet
Loading lesson

‹Prompt Debugging
  1. Topics
  2. AI Skills for VLSI Engineers
  3. Prompting
  4. Prompt Debugging
  5. A Prompt Regression Harness

Asking Clearly · Beginner to Intermediate

A Prompt Regression Harness

A deterministic grader unit test, followed by a separate protocol for evaluating real prompt versions.

On this page

    Shape of the harness

    First test the checker, then test the assistant. The listing below supplies fixed reply fixtures to small property checkers. It is a grader unit test: it does not send a prompt to a model and cannot measure whether changing a prompt improves an answer. Keep this inexpensive check separate from the prompt evaluation described after the listing.

    Part

    Role

    In the program

    Fake model

    Returns fixed replies per case id.

    fake_model dict lookup.

    Cases

    Pairs each id with two property checks.

    CASES with 6 entries.

    Checkers

    Test one property of a reply string.

    Six small functions.

    Runner

    Counts passing checks and prints one line.

    main with the PASS summary.

    The program

    The program below is runnable and uses only the standard library. Its fake model is scripted, with no real model calls.

    example.py
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    import json
    import sys
    
    
    # FAKE model stand-in: scripted replies per case id, no real model calls.
    def fake_model(case_id):
        table = {
            "reset-steps": "STEP 1: hold reset_n low for 4 cycles\nSTEP 2: release reset_n\nSTEP 3: wait 2 cycles",
            "width-note": "The 8-bit counter wraps at 255 and raises full.",
            "config-shape": '{"width": 8, "reset_cycles": 4}',
            "secret-handling": "CREDENTIAL: redacted. STATUS: ok.",
            "product-steps": "20 * 35 = 700\n4 * 35 = 140\nTOTAL = 840",
            "bullets": "- hold reset_n low for 4 cycles\n- release reset_n and wait 2 cycles",
        }
        return table[case_id]
    
    
    def has_text(reply, text):
        return text in reply
    
    
    def starts_with(reply, text):
        return reply.startswith(text)
    
    
    def line_count(reply, n):
        return sum(1 for ln in reply.splitlines() if ln.strip()) == n
    
    
    def excludes(reply, text):
        return text not in reply
    
    
    def json_keys(reply, keys):
        try:
            obj = json.loads(reply)
        except ValueError:
            return False
        return isinstance(obj, dict) and sorted(obj.keys()) == sorted(keys)
    
    
    def bullet_lines(reply):
        lines = [ln for ln in reply.splitlines() if ln.strip()]
        return len(lines) > 0 and all(ln.startswith("- ") for ln in lines)
    
    
    CASES = [
        ("reset-steps", [("starts-with", "STEP 1:"), ("line-count", 3)]),
        ("width-note", [("contains", "8-bit"), ("excludes", "TODO")]),
        ("config-shape", [("json-keys", ["width", "reset_cycles"]), ("contains", "4")]),
        ("secret-handling", [("excludes", "ACME-SECRET-99"), ("contains", "redacted")]),
        ("product-steps", [("contains", "TOTAL = 840"), ("line-count", 3)]),
        ("bullets", [("bullet-lines", None), ("contains", "cycles")]),
    ]
    
    
    def run_one(check, reply):
        kind, arg = check
        if kind == "contains":
            return has_text(reply, arg)
        if kind == "starts-with":
            return starts_with(reply, arg)
        if kind == "line-count":
            return line_count(reply, arg)
        if kind == "excludes":
            return excludes(reply, arg)
        if kind == "json-keys":
            return json_keys(reply, arg)
        if kind == "bullet-lines":
            return bullet_lines(reply)
        return False
    
    
    def main():
        passed = 0
        total = 0
        for case_id, checks in CASES:
            reply = fake_model(case_id)
            for check in checks:
                total += 1
                if run_one(check, reply):
                    passed += 1
        if passed == total:
            print("PASS: %d of %d property checks hold across %d cases" % (passed, total, len(CASES)))
        else:
            print("FAIL: %d of %d checks hold across %d cases" % (passed, total, len(CASES)))
            sys.exit(1)
    
    
    main()

    Reading the result

    A green run means the supplied fixtures satisfy these checkers, not that a prompt works. A broken checker can still accept wrong answers: the width-note fixture mentions an 8-bit counter but that alone does not establish correct wrap behaviour. Add deliberately incorrect fixtures and require their rejection before trusting a grader.

    plaintext
    harness size follows the code: 6 cases x 2 checks = 12 checks
    green run: 12 / 12 = 100%
    a red fixture run means inspect the fixture and checker; prompt changes are judged on actual outputs

    Evaluate an actual prompt version

    Prepare a separate evaluation record with case_id, prompt_version, full input, model/setup, output, checks, usage and outcome. Obtain outputs through a company-approved assistant or an approved model adapter; do not place credentials in the record. An offline learner can inspect clearly labelled recorded outputs, but must not describe those as a run of their own prompt. Live evaluation is useful precisely because model behaviour varies.

    Step

    What to do

    Evidence to keep

    Freeze

    Select public or synthetic cases and write expected properties before looking at replies.

    Inputs, requirements and known traps.

    Run

    Give the same unseen inputs to prompt A and prompt B. Repeat where output variability matters.

    Actual replies and setup for every attempt, including failures.

    Check

    Use the tested graders, then inspect technical meaning and source support.

    Case-level correctness, omissions and human review.

    Decide

    Compare quality and effort without tuning on the held-out cases.

    What improved, what regressed and what remains uncertain.

    Common mistakes

    Common pitfall

    Editing a prompt cannot change this listing's replies: fake_model receives only a case ID. Do not report its 12 fixture checks as a prompt success rate.

    Interview

    Likely probes: why the model is fake and what red means.

    • Scripted fixtures test checker behaviour; actual outputs test prompt behaviour.

    • Twelve checks across six cases give one summary line with exact counts.

    • A red fixture check points at the fixture or checker, not the prompt.

    Check yourself The fixture harness reports 11 of 12 checks holding. Should you rewrite the prompt?

    Not on this evidence. This harness has no prompt input. Inspect the fixture and checker, then separately evaluate the prompt against actual outputs.

    Check yourself Why keep fixture checks and live prompt evaluation separate?

    Fixtures make checker defects reproducible. Actual model trials measure task performance and variability. Both are useful, but neither substitutes for the other.

    Related topics

    • Keep a Small Set of Test Prompts

    • Scripts and automation

    Previous

    33 / 173

    Next: Trust and Verification

    Up next

    Up nextTrust and Verification

    Sign in to save progress

    Practice this lessonReport an error

    See also

    • Diagnose the Failure First
    • Change One Thing at a Time