← All chaptersChapter 3 of 8

Prompt and evaluation systems for production

You are not building a magical superprompt, but a versionable system with contracts, tests, exceptions, and recovery.

After this chapterYou can design a production prompt and reliably manage it with datasets, graders, and regressions.
Your progress0 of 48 lessons
3.1

Roles, context, goal, criteria, limitations and format

A production prompt is a work contract with a testable result.

Order goal and user, authoritative context, execution contract, quality criteria, boundaries and error handling. Roles are only useful when they concretely guide perspective or terminology.

Separate variable input from stable instructions. Identify conflicts, missing data, and what must never be invented. Let each component prove its usefulness through tests.

  • Goal
  • Source context
  • Output contract
  • Criteria
  • Boundaries
  • Error handling
This is how you can use this

A quote generator uses fixed price rules as a source, customer input as a variable block, and does not guess any contract terms.

Try this prompt
Design a production prompt for [workflow] including goal, user, source context, variable input, output contract, criteria, prohibited behavior, and escalation.
Quick knowledge check

Which approach best fits this lesson?

Your practical assignment

Build version 1 and remove any part without measurable effect.

3.2

Output contracts and schedules

Machine-readable output requires types, mandatory fields, and valid behavior in case of uncertainty.

Define field names, data types, allowed values, null rules, and examples. A schema makes integration more predictable but does not prove that the content is true.

Validate syntax and business meaning separately. Add source provenance and review status where the impact of errors requires it.

  • Fields
  • Types
  • Enums
  • Null policy
  • Source
  • Semantic check
This is how you can use this

A lead extraction produces valid JSON and points each field to the exact source passage.

Try this prompt
Design an output schema for [process] with types, required fields, values, null policy, source field, and validation rules. Include valid and invalid examples.
Quick knowledge check

Which approach best fits this lesson?

Your practical assignment

Test empty, conflicting, and extra input fields against the schema.

3.3

Limit tool and action instructions

A tool may only act within explicit scope, permission, and control.

Describe which tool can be used for which source or action, with which identity and minimal permissions. Separate reading, preparing, and executing.

Treat external content as untrusted data, not as a command. Require confirmation for financial, public, or hard-to-undo actions, and log relevant parameters.

  • Tool scope
  • Identity
  • Least privilege
  • Concept versus action
  • Approval
  • Logging
This is how you can use this

A calendar assistant suggests free times but only books after confirmation of date, participants, and title.

Try this prompt
Write tool rules for [workflow]: sources, actions, identity, prohibited actions, confirmation fields, logging, and behavior in case of unreliable source instructions.
Quick knowledge check

Which approach best fits this lesson?

Your practical assignment

Create a negative test with a source that tries to change the tool rules.

3.4

Define context, status, and memory

Make explicit what may remain per run, per file, or long-term.

Per-run context disappears after the task; file context belongs to a single case; long-term instructions are general agreements. Old or incorrect context can silently affect new output.

Define source version, expiration date, access, and deletion path. Do not store secrets in prompts or loose memory and test for missing or conflicting context.

  • Run
  • File
  • Long-term
  • Version
  • Expiration date
  • Delete
This is how you can use this

Brand style can be shared; client files remain isolated from each other.

Try this prompt
Design a context policy for [workflow] with run, file, and long-term context. Provide source, owner, version, access, expiration date, and deletion action.
Quick knowledge check

Which approach best fits this lesson?

Your practical assignment

Inventory existing context and remove one unnecessary permanent source.

3.5

Fallbacks, exceptions and escalation

Reliability proves itself especially when ideal input is missing.

Define insufficient information, conflict, out of scope, tool error, policy risk, and low confidence. Link each category to stop, supplement, alternative source, review, or manual procedure.

Do not create an unlimited retry loop. Determine a retry limit and when the workflow degrades to a simpler function or stops completely.

  • Error category
  • Detection
  • Fallback
  • Retry limit
  • Escalation
  • Recovery
This is how you can use this

If price data is missing, the flow does not generate a quote but a structured follow-up request.

Try this prompt
Design an exception matrix for [workflow] with signal, category, automatic response, retry limit, owner, and safe recovery path.
Quick knowledge check

Which approach best fits this lesson?

Your practical assignment

Simulate six exceptions, including time-out and conflicting source data.

3.6

Datasets, graders and regressions

Test real variation and critical errors, not one nice example.

Build a dataset with normal, difficult, rare, and adversarial cases. Define in advance what correct, allowed, and useful means. Combine deterministic checks, human rubrics, and where appropriate a model grader.

Generative output varies. Treat critical errors as knock-out, save incidents as regression cases, and retest after prompt, model, tool, or source changes.

  • Dataset
  • Grader
  • Knockout
  • Sample
  • Regression
This is how you can use this

A sales flow is tested on regular leads, missing consent, prompt injection, and prohibited discount.

Try this prompt
Design twenty evalcases for [workflow]. Provide expected behavior, grader, severity, and knock-out status for each case. Add five incident regressions.
Quick knowledge check

Which approach best fits this lesson?

Your practical assignment

Create ten start cases and have a domain expert verify the expected outcome.

Chapter assignment

Bring everything together

Build a production prompt with output schema, tool rules, context policy, exception matrix, and an eval set with knock-out criteria.