This playbook is for platform engineers and AI reliability engineers who operate production pipelines with schema-enforced outputs. When automated structured output evaluations begin failing, the root cause often falls into one of two categories: the model produced the wrong content, or the model produced content in the wrong shape. This prompt addresses the second category—format drift—by comparing an actual model output against an expected JSON schema and producing a field-level compliance report. Use it as a first diagnostic step before diving into content-quality investigations, hallucination checks, or retrieval pipeline debugging. If the format is intact, you can confidently shift focus to semantic or factual issues.
Prompt
Format Drift Eval Failure Diagnosis Prompt

When to Use This Prompt
Use this prompt to isolate format-level failures in structured output evaluations before investigating content quality issues.
The prompt expects three inputs: the actual model output that failed evaluation, the expected JSON schema (as a valid JSON Schema object), and any field-level descriptions or constraints that clarify intent. It returns a structured compliance report identifying missing required keys, type violations (e.g., string where an integer was expected), extra fields not declared in the schema, and structural changes such as nested object flattening or array wrapping. The report includes a format_valid boolean, a failure_category classification (e.g., missing_key, type_mismatch, extra_field, structural_change), and a per-field breakdown with the expected type, actual type, and a human-readable diagnosis. This output is designed to be machine-readable so you can wire it into automated triage pipelines that route format failures to prompt repair and content failures to deeper trace analysis.
Do not use this prompt when you already know the output format is correct but the content is wrong—that requires a different diagnostic path, such as the Golden Set Deviation Diagnosis Prompt or the Hallucination Spot-Check Against Eval Rubric Prompt. Also avoid using it for non-JSON outputs unless you adapt the schema comparison logic to the target format (XML, YAML, etc.). For high-risk domains where format errors could cause downstream data corruption or compliance violations, always pair this prompt's output with human review before applying automated fixes. The compliance report is a diagnostic tool, not a repair mechanism—use the Output Repair and Validation Prompts pillar for actual format correction workflows.
Use Case Fit
Where the Format Drift Eval Failure Diagnosis Prompt works and where it does not. Use these cards to decide if this prompt fits your operational context before integrating it into your observability pipeline.
Good Fit: Structured Output Regression
Use when: production responses that previously passed schema validation are now failing. The prompt compares the actual output structure against the expected schema to identify field-level drift, type violations, and structural changes. Guardrail: feed the prompt the raw model output and the exact expected schema—not a description of the schema—to get actionable field-level diffs.
Bad Fit: Semantic Quality Issues
Avoid when: the eval failure is about factual accuracy, tone, or completeness rather than structure. This prompt diagnoses format violations, not content quality. Guardrail: route semantic failures to the Hallucination Spot-Check or Quality Rubric Violation prompts instead. Using this prompt for content issues will produce false negatives.
Required Inputs
What you need: the expected output schema (JSON Schema, TypedDict, or strict field specification), the actual model output that failed validation, and the eval failure message from your validator. Guardrail: if you lack the exact schema the validator used, the diagnosis will be speculative. Always capture the schema version alongside the trace.
Operational Risk: Silent Schema Changes
What to watch: your application code may have changed the expected schema without updating the prompt or eval rubric. The prompt will correctly flag the mismatch, but the root cause is a deployment coordination gap. Guardrail: pair this prompt with a schema version check in your CI/CD pipeline so format drift is caught before production eval failures accumulate.
Operational Risk: Partial Compliance
What to watch: the model output may be valid JSON but fail because optional fields are missing or extra fields are present. The prompt must distinguish between strict and lenient schema expectations. Guardrail: explicitly pass the validation mode (strict vs. lenient) as a constraint so the diagnosis matches your application's actual tolerance.
Integration Point: Trace-to-Eval Loop
What to watch: format drift often correlates with prompt changes, model upgrades, or context window shifts. Running this diagnosis in isolation misses systemic causes. Guardrail: feed the prompt's output into the Eval Failure Root-Cause Triage Prompt to connect format drift to upstream trace events and avoid treating symptoms in isolation.
Copy-Ready Prompt Template
A copy-ready prompt for diagnosing structured output eval failures caused by format drift, schema violations, and structural changes.
Use this prompt to investigate why a structured output evaluation is failing. It is designed for platform engineers who need to compare an actual model output against an expected schema and produce a detailed compliance report. The prompt isolates field-level drift, type violations, missing or extra keys, and structural changes that cause format eval failures. Before pasting, ensure you have the actual output, the expected schema, and any relevant trace data showing the prompt and model version that generated the output.
textYou are a schema compliance auditor for production AI systems. Your task is to compare an actual structured output against an expected schema and produce a detailed compliance report identifying field-level drift, type violations, and structural changes. ## INPUT [ACTUAL_OUTPUT] ## EXPECTED SCHEMA [EXPECTED_SCHEMA] ## TRACE CONTEXT [TRACE_CONTEXT] ## INSTRUCTIONS 1. Parse the actual output and the expected schema. 2. Compare every field, type, and structural element. 3. Classify each finding into one of these categories: - TYPE_VIOLATION: field exists but has wrong type - MISSING_REQUIRED: required field absent from output - EXTRA_FIELD: field present in output but not in schema - STRUCTURAL_CHANGE: nesting, array, or object shape differs - ENUM_VIOLATION: value not in allowed enum set - NULL_VIOLATION: null value where non-null required - FORMAT_DRIFT: valid but unexpected format change (e.g., date format, casing) 4. For each finding, include: - The field path (dot notation) - Expected vs. actual value or type - Severity: CRITICAL, HIGH, MEDIUM, LOW - Likely root cause hypothesis based on trace context 5. Produce a summary with: - Total findings count by severity - Overall compliance score (0-100) - Top 3 recommended fixes - Whether this is likely a prompt regression, model behavior change, or parsing error ## OUTPUT FORMAT Return a JSON object with this exact structure: { "compliance_score": number, "findings": [ { "field_path": "string", "category": "TYPE_VIOLATION | MISSING_REQUIRED | EXTRA_FIELD | STRUCTURAL_CHANGE | ENUM_VIOLATION | NULL_VIOLATION | FORMAT_DRIFT", "expected": "string", "actual": "string", "severity": "CRITICAL | HIGH | MEDIUM | LOW", "root_cause_hypothesis": "string" } ], "summary": { "total_findings": number, "by_severity": { "critical": number, "high": number, "medium": number, "low": number }, "top_recommendations": ["string"], "likely_failure_category": "PROMPT_REGRESSION | MODEL_BEHAVIOR_CHANGE | PARSING_ERROR | UNKNOWN" } } ## CONSTRAINTS - Do not hallucinate fields not present in the actual output. - If the actual output is not valid JSON, report a CRITICAL finding and stop. - Base root cause hypotheses only on evidence in the trace context. - If trace context is insufficient, set root_cause_hypothesis to "INSUFFICIENT_TRACE_DATA".
To adapt this prompt, replace [ACTUAL_OUTPUT] with the raw model response that failed evaluation, [EXPECTED_SCHEMA] with your target schema definition (JSON Schema, TypeScript interface, or plain description), and [TRACE_CONTEXT] with relevant trace data such as the system prompt, model version, and any tool calls or retrieval steps. If you lack trace data, the prompt will still produce findings but root cause hypotheses will be marked as insufficient. For high-risk domains like healthcare or finance, always route the compliance report through human review before taking action on the findings.
Prompt Variables
Inputs required for the Format Drift Eval Failure Diagnosis Prompt. Each placeholder must be populated with structured trace data and schema definitions to produce a reliable compliance report.
| Placeholder | Purpose | Example | Validation Notes |
|---|---|---|---|
[ACTUAL_OUTPUT] | The raw model response that failed the structured output evaluation | {"name": "Jane", "age": "thirty"} | Must be a non-empty string. Parse as JSON in pre-processing; if parsing fails, the prompt should receive the raw string and the error message. |
[EXPECTED_SCHEMA] | The target JSON Schema, TypeScript interface, or structured specification the output was supposed to match | {"type": "object", "properties": {"name": {"type": "string"}, "age": {"type": "integer"}}, "required": ["name", "age"]} | Must be a valid JSON Schema object. Validate with a schema validator before passing to the prompt. If using TypeScript, convert to JSON Schema first. |
[EVAL_FAILURE_LOG] | The specific error messages, assertion failures, or validator output from the eval harness | Error: Field 'age' expected type integer but got string. Field 'email' missing from required set. | Must be a non-empty string. If the eval harness provides structured error objects, serialize them to a readable format. Null allowed only if the failure mode is silent drift. |
[TRACE_CONTEXT] | Optional trace segment showing the prompt version, model ID, and any intermediate steps that produced the output | model: gpt-4o-2024-08-06, prompt_version: v2.3.1, temperature: 0.0 | Can be null. If provided, must include model identifier and prompt version at minimum. Useful for correlating drift to model or prompt changes. |
[OUTPUT_SCHEMA] | The desired structure for the compliance report itself, defining the fields the prompt must return | {"fields": ["field_path", "expected_type", "actual_type", "status", "sample_value", "fix_suggestion"]} | Must be a valid JSON Schema or field definition list. The prompt will use this to format its diagnostic output. Validate before passing. |
[CONSTRAINTS] | Operational constraints for the diagnosis, such as max fields to report, severity thresholds, or ignore rules | max_fields_reported: 50, ignore_nullable_mismatch: false, severity_threshold: warning | Can be null. If provided, must be a valid JSON object with known constraint keys. Unknown keys should be stripped before passing to avoid prompt confusion. |
[HUMAN_REVIEW_FLAG] | Boolean or condition indicating whether the output requires human review before automated action | Must be true or false. Set to true for regulated domains, PII-containing outputs, or when the drift severity is unknown. The prompt should include this in its recommendation logic. |
Implementation Harness Notes
How to wire the Format Drift Eval Failure Diagnosis Prompt into an automated investigation workflow.
This prompt is designed to be the analytical core of an automated schema compliance investigation, not a one-off chat interaction. To use it effectively, you must embed it within a harness that feeds it structured trace data, validates its output, and routes the resulting report to the right team. The prompt expects a specific input shape: the [EXPECTED_SCHEMA] (a JSON Schema or TypeScript interface), the [ACTUAL_OUTPUT] (the raw string the model produced), and any [PARSER_ERRORS] from your initial validation layer. The harness's job is to gather these inputs from your production logging or eval pipeline and present them cleanly to the model.
The implementation should follow a strict validate → diagnose → route pattern. First, your application's existing output parser should attempt to validate the raw model output against the expected schema. If validation fails, capture the exact error message and the raw output string. The harness then calls this prompt with those three inputs. The model's response, a structured JSON report, must itself be validated against a strict schema (e.g., requiring drift_category, field_analysis, and root_cause_hypothesis fields) before being trusted. A retry loop with a maximum of 2 attempts is recommended if the diagnosis output fails its own schema validation, using a temperature of 0 to minimize variance. Log the raw diagnosis report and the final validated report as separate events in your trace for auditability.
For high-stakes systems where format drift could cause downstream data corruption or customer-facing errors, do not automatically apply the prompt's suggested fix. Instead, route the validated diagnosis report to a human review queue or a prompt-version-control system. The report's severity field can be used as a routing key: CRITICAL or HIGH severity findings should trigger an immediate alert and block further automated deployments until a human confirms the root cause and approves a remediation plan. This harness turns a diagnostic prompt into a safe, auditable control point in your MLOps pipeline, preventing a single malformed output from cascading into a full-scale regression.
Expected Output Contract
Schema compliance report fields, types, and validation rules for the format drift diagnosis prompt. Use this contract to validate the model's output before passing it to downstream systems or human reviewers.
| Field or Element | Type or Format | Required | Validation Rule |
|---|---|---|---|
drift_report_id | string (UUID v4) | Must match regex ^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$ | |
timestamp | string (ISO 8601 UTC) | Must parse as valid ISO 8601 datetime with Z suffix; must be within 5 minutes of generation time | |
expected_schema_version | string (semver) | Must match regex ^\d+.\d+.\d+$; must correspond to a known schema version in the schema registry | |
actual_output_structure | object (JSON) | Must be valid JSON; must contain at least one key; top-level keys must be strings | |
field_drift_analysis | array of objects | Must contain at least one element; each element must have field_path, expected_type, actual_type, and drift_severity keys | |
field_drift_analysis[].field_path | string (JSONPath) | Must be a valid dot-notation path to a field in actual_output_structure; must not be empty | |
field_drift_analysis[].drift_severity | string (enum) | Must be one of: critical, major, minor, none; critical reserved for missing required fields or type mismatches on required fields | |
structural_changes | array of objects | Must contain at least one element if structural changes detected; each element must have change_type, description, and affected_fields keys | |
structural_changes[].change_type | string (enum) | Must be one of: field_added, field_removed, field_renamed, nesting_change, array_to_object, object_to_array, type_widening, type_narrowing | |
overall_compliance_score | number (0.0-1.0) | Must be between 0.0 and 1.0 inclusive; 1.0 indicates full schema compliance; score must correlate with drift_severity distribution | |
remediation_suggestions | array of strings | Must contain at least one suggestion if overall_compliance_score < 1.0; each string must be a concrete, actionable instruction referencing specific field paths |
Common Failure Modes
Format drift is the silent killer of structured output pipelines. When the model subtly changes JSON shapes, field types, or enum values, downstream parsers break. These are the most common failure modes and how to catch them before they reach production.
Silent Field Renaming
What to watch: The model outputs customer_name instead of customerName or full_name instead of name. This passes JSON validation but breaks downstream deserialization. Guardrail: Validate against an exact JSON Schema with additionalProperties: false and field-level pattern constraints. Use a strict deserializer that rejects unknown fields rather than silently ignoring them.
Type Coercion Drift
What to watch: A numeric field like "count": 42 becomes "count": "42" (string) or "price": 19.99 becomes "price": "$19.99". The JSON is valid but the type contract is broken. Guardrail: Add type assertions in your validation layer. Use type and format keywords in JSON Schema. For critical fields, add a post-parse type check with explicit error messages naming the drifted field.
Enum Value Mutation
What to watch: Allowed enum values like ["low", "medium", "high"] drift to ["Low", "Medium", "High"] or ["minor", "moderate", "critical"]. Case sensitivity and synonym substitution are the most common drift vectors. Guardrail: Define enums explicitly in your output schema. Use case-insensitive matching only when intentional. Log every enum mismatch with the raw value for pattern analysis.
Optional Field Omission
What to watch: A field marked as optional in the schema is omitted entirely when the model considers it irrelevant, but downstream code expects the key to exist with a null value. Guardrail: Normalize outputs immediately after parsing. For every optional field, explicitly set missing keys to null or a sentinel value. Validate that required fields are present and non-null before any business logic runs.
Nested Structure Flattening
What to watch: A nested object like "address": {"street": "...", "city": "..."} becomes a flat string "address": "123 Main St, Springfield" when the model takes a shortcut. Guardrail: Validate structural depth explicitly. Use JSON Schema type: "object" constraints on nested fields. Add a structural integrity check that counts nesting levels and flags unexpected flattening before the output reaches application code.
Array Wrapping Inconsistency
What to watch: A field expected to always be an array like "tags": ["urgent"] becomes a single string "tags": "urgent" when only one value exists. This is the most common cause of TypeError: .map is not a function in production. Guardrail: Normalize all array fields immediately after parsing. Wrap single values in an array, convert null to an empty array, and reject non-iterable values with a clear error. Add a pre-serialization array assertion.
Evaluation Rubric
Test the quality of the compliance report before relying on it for incident response. Each criterion targets a specific failure mode in format drift diagnosis.
| Criterion | Pass Standard | Failure Signal | Test Method |
|---|---|---|---|
Schema Field Coverage | Report identifies every field in [EXPECTED_SCHEMA] with a status of present, missing, or type_mismatch | Missing fields in the report that exist in [EXPECTED_SCHEMA] or extra fields reported that do not exist in the schema | Diff the set of field paths in the report against the flattened field paths of [EXPECTED_SCHEMA] |
Type Violation Accuracy | Every type_mismatch flagged in the report corresponds to an actual type violation when [ACTUAL_OUTPUT] is validated against [EXPECTED_SCHEMA] | False positive type_mismatch on a field that passes schema validation or false negative where a real type violation is not flagged | Validate [ACTUAL_OUTPUT] against [EXPECTED_SCHEMA] with a JSON Schema validator and compare violations to report entries |
Structural Change Detection | Report correctly identifies structural changes: nesting depth shifts, array-to-object changes, or key renames with before/after paths | Structural change described in prose but missing the specific before/after field path or misidentifying a type change as a structural change | Parse the report's structural_change section and verify each entry against a manual diff of [EXPECTED_SCHEMA] and the inferred schema of [ACTUAL_OUTPUT] |
Drift Severity Classification | Each drift finding is assigned a severity of critical, high, medium, or low consistent with the [SEVERITY_RUBRIC] | Critical severity assigned to a cosmetic whitespace change or low severity assigned to a missing required field in a regulated payload | Sample 5 drift findings and have a human reviewer independently classify severity using [SEVERITY_RUBRIC]; require 80% agreement |
Root-Cause Hypothesis Quality | Root-cause section proposes at least one testable hypothesis linking the drift pattern to a specific prompt change, model version, or pipeline component | Root-cause is generic (e.g., model behavior changed) without linking to a specific trace event, prompt version, or configuration change | Check that the root-cause statement references at least one concrete artifact: a prompt version ID, model snapshot, or pipeline step name from [TRACE_DATA] |
Remediation Actionability | Remediation section includes at least one concrete action: a schema constraint to add, a prompt instruction to revise, or a post-processing fix with before/after example | Remediation is vague (e.g., fix the prompt) without a specific instruction change or validation rule | Extract remediation steps and verify each contains a target location (e.g., system prompt line, output schema field, validator config) and a specific change |
False Positive Rate on Clean Outputs | When [ACTUAL_OUTPUT] fully conforms to [EXPECTED_SCHEMA], the report produces zero drift findings | Report flags drift on a fully conformant output, indicating the diagnosis prompt is hallucinating violations | Run the prompt against 5 known-valid outputs that pass schema validation; require 0 drift findings across all 5 |
Trace Evidence Grounding | Every drift finding cites a specific location in [ACTUAL_OUTPUT] or [TRACE_DATA] as evidence | Drift claim made without a line number, field path, or trace event reference that can be independently verified | For each drift finding, check that the evidence field contains a parseable reference (JSON path, line number, or trace span ID) that resolves to the claimed location |
Enabling Efficiency, Speed & Accuracy
Intelligent Analysis, Decision & Execution
We build AI systems for teams that need search across company data, workflow automation across tools, or AI features inside products and internal software.
Talk to Us
Search across company data
Give teams answers from docs, tickets, runbooks, and product data with sources and permissions.
Useful when people spend too long searching or get different answers from different systems.

Automate internal workflows
Use AI to route work, draft outputs, trigger actions, and keep approvals and logs in place.
Useful when repetitive work moves across multiple tools and teams.

Add AI to products and internal tools
Build assistants, guided actions, or decision support into the software your team or customers already use.
Useful when AI needs to be part of the product, not a separate tool.
Adapt This Prompt
How to adapt
Start with the base prompt and a single schema definition. Use a lightweight validator that checks only top-level field presence and type. Run against 10–20 recent production outputs to surface obvious drift patterns before building full automation.
code[EXPECTED_SCHEMA] = { "fields": ["id", "summary", "score"] } [ACTUAL_OUTPUT] = [paste raw model response]
Watch for
- Missing nested field checks that hide deep structural drift
- Overly broad type matching (e.g., accepting any object when an array is required)
- No baseline comparison against a known-good output sample

About the author
Prasad Kumkar
CEO & MD, Inference Systems
Prasad Kumkar is the CEO & MD of Inference Systems and writes about AI systems architecture, LLM infrastructure, model serving, evaluation, and production deployment. Over 5+ years, he has worked across computer vision models, L5 autonomous vehicle systems, and LLM research, with a focus on taking complex AI ideas into real-world engineering systems.
His work and writing cover AI systems, large language models, AI agents, multimodal systems, autonomous systems, inference optimization, RAG, evaluation, and production AI engineering.
Partnered with leading AI, data, and software stack.
How We Work
Custom AI workflows for your Business
One-fit-all AI don't work for modern businesses. At Inferensys, we aim to understand your business & custom requirements; which we use to define most efficient agentic workflows, the data, and the tools for your business.
01
Review the use case
We understand the task, the users, and where AI can actually help.
Read more02
Pick the right approach
We define what needs search, automation, or product integration.
Read more03
Build the first useful version
We implement the part that proves the value first.
Read more04
Improve from there
We add the checks and visibility needed to keep it useful.
Read moreThe first call is a practical review of your use case and the right next step.
Talk to Us