AI Engineering
/
Prompting & Structured Output
/

Design a versioned output contract and migration

Prompting & Structured Output · 3 to 4 hours

Design a versioned output contract and migration

Upgrade a ticket classifier to a versioned contract with multiple IDs, evidence, and review states, keep two v1-only consumers working, and decide from evaluation data whether a candidate prompt should ship.

Hard
System Design

4 h

Premium

Used in interview rounds:

AI System Design (Hard)

Overview

Design a versioned output contract that survives prompt changes, model changes, old records, and multiple consumers. A strong answer connects semantic compatibility, validation, evaluation, and operational behavior without assuming that schema compliance alone protects the application.

Study time: 3 to 4 hours

Interview format: System design

By the end you can

  • Treat the prompt, examples, contract, model, and validator as one versioned configuration
  • Design explicit result states inside an application-owned envelope the model cannot forge
  • Classify contract changes by structural and semantic compatibility, in both directions
  • Migrate historical records without inventing information that was never stored
  • Read a release evaluation by subgroup and reject a candidate that regresses a protected slice
  • Plan recovery and rollback so failed attempts, late responses, and v2 records stay well defined

Prerequisites

Helpful background: Familiarity with API contracts and regression testing helps.

In this guide

  1. Treat the prompt as a versioned dependency
  2. Design explicit result states
  3. Example v2 contract
  4. Structural and semantic compatibility
  5. Adapters and historical data
  6. Separate provider schema from domain schema
  7. Build a regression suite across layers
  8. A release evaluation
  9. Decide whether the candidate ships
  10. Recovery, concurrency, and side effects
  11. Change and rollback plan

Hard questions are part of Premium: the study guide, reference answer, rubric, and exercises unlock with Premium.

Practice the interview question

Answer it in your own words before you look at the reference answer.