Module 2 of 7 · 50 min

Prompt OpenAI Models with Evaluated Contracts

Design clear, versioned prompts for ChatGPT and API workflows, separate instruction authority from variable input, and improve behavior with controlled evaluations.

OpenAI

By the end

You will be able to

  • Define success criteria and representative evaluation cases before tuning a prompt.
  • Structure goals, authoritative instructions, context, examples, variable input, output contracts, and verification.
  • Adapt prompting to the selected model and surface without hard-coding volatile guidance.
  • Classify failures across prompt, context, model, tool, policy, and application boundaries.
01

Start from success evidence

Write the required outcome, target users, unacceptable behavior, output contract, representative cases, rubric, and pass threshold before changing prompt wording. Compare candidates against the same cases and configuration.

Prompt engineering cannot repair unavailable facts, missing permissions, a broken tool, unsuitable latency, or absent application validation. Classify the failed boundary before editing.

02

State the contract clearly and once

Describe the outcome, audience, authoritative context, hard constraints, allowed actions, approval boundaries, required evidence, output shape, and stopping condition. Use ordered steps only when order or completeness is a real requirement.

Avoid duplicated or conflicting instructions. Keep stable policy in the appropriate higher-authority instruction layer and put task-specific requests in the user input.

03

Separate context, examples, and untrusted input

Label authoritative references, examples, and variable user or retrieved content. Use clear delimiters or structured fields, and tell the workflow which evidence may support claims.

Prompt structure does not create security. Treat external text as untrusted data, enforce authorization outside the model, validate outputs, and never include secrets merely to make them available.

Evaluated prompt contract
text
Goal: [OBSERVABLE OUTCOME]
Authoritative instructions: [POLICY + HARD CONSTRAINTS]
Trusted context: [APPROVED SOURCES]
Variable input (untrusted): [USER OR RETRIEVED DATA]
Examples: [RELEVANT, DIVERSE, SECRET-FREE]
Output contract: [SCHEMA OR REQUIRED HEADINGS]
Verify: [CLAIMS, CONSTRAINTS, POSTCONDITIONS]
Stop or escalate when: [BOUNDARY]
04

Adapt with current model guidance

Model families can differ in reasoning controls, verbosity, tool behavior, and recommended prompt patterns. Use the current official model guidance for the configured model and evaluate changes rather than copying a static recipe.

Keep model identifiers and model-specific settings in reviewed configuration. Change one meaningful hypothesis at a time where practical and preserve the baseline for rollback.

05

Iterate and version from evidence

Run baseline and candidate across typical, edge, adversarial, and prior-failure cases. Record per-case rubric results, critical failures, latency, usage, cost, model, prompt, tools, and reviewer disagreement.

Classify each miss as instruction ambiguity, missing context, misleading example, output violation, model limitation, tool failure, policy boundary, or application defect. Add repaired failures to regression coverage.

Practice activity

Build and evaluate an OpenAI prompt contract

  1. Choose a recurring task and define at least four success criteria, one forbidden outcome, and an 80 percent pass threshold.
  2. Create six cases: three typical, one edge, one adversarial instruction-conflict case, and one prior failure.
  3. Write a prompt that separates authoritative instructions, trusted context, untrusted variable input, examples, output contract, verification, and escalation.
  4. Compare a baseline and candidate under identical settings, classify every failure boundary, and make a ship, revise, or reject decision.

What to produce

  • A secret-free versioned prompt, rubric, and six-case suite with explicit trust and approval boundaries.
  • A baseline-versus-candidate report with scores, failures, versions, latency and usage evidence, and a release decision.

Reflect before continuing

Which failed case required a system change rather than another prompt instruction?

Evidence

Sources and verification

Knowledge check

Make it stick.

Pass at 80%

Choose the strongest answer for each question. Your attempts become part of your device-local transcript.

01What should exist before prompt tuning?
02Where should stable policy live?
03What does prompt delimiting guarantee?
04How should model-specific guidance be applied?
05A result lacks data the workflow never supplied. What failed first?