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.
4 h
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
- Treat the prompt as a versioned dependency
- Design explicit result states
- Example v2 contract
- Structural and semantic compatibility
- Adapters and historical data
- Separate provider schema from domain schema
- Build a regression suite across layers
- A release evaluation
- Decide whether the candidate ships
- Recovery, concurrency, and side effects
- Change and rollback plan
Hard questions are part of Premium: the study guide, reference answer, rubric, and exercises unlock with Premium.
Related on CodeSnatch
Lessons, problems, and articles that build the skills this question uses.
System Design
Treats a schema as a consumer contract: version fields, parallel versions during migration, and registry compatibility modes.
AI Engineering
Builds release gates from protected slices, calibrated graders, and stated uncertainty, the basis of a ship call.
System Design
Covers schema evolution for stored events, including upcasting old records on read instead of rewriting them.
System Design
Shows a model registry with lineage and versions, plus a shadow then canary rollout with one-step rollback.
Community article
Expand-contract steps that keep every data state readable by old and new code, including after a rollback.
Practice the interview question
Answer it in your own words before you look at the reference answer.
