This prompt is for ingestion pipeline owners and platform engineers who need to verify that every required field exists in structured LLM outputs before data reaches downstream systems. It acts as a schema-aware gate that distinguishes between missing keys, null values, and empty strings, producing a per-field presence report against a registry of required and optional attributes. Use this when malformed JSON payloads break ETL jobs, API contracts, or database inserts, and you need an automated, model-graded audit that runs at inference time.
Prompt
Field Presence and Required Attribute Audit Prompt

When to Use This Prompt
A practical guide for ingestion pipeline owners and platform engineers who need to automate the verification of structured LLM outputs before they reach downstream systems.
The ideal user is an engineer who already has a defined schema registry—a source of truth that declares which fields are required, which are optional, and what constitutes a valid value. This prompt is not a schema designer; it assumes you bring the contract. It is also not a type checker (see the sibling Type Correctness and Coercion Detection Prompt for that). Instead, it answers one question with high precision: 'Is every required field present, and are optional fields correctly absent or populated?' The output is a structured report you can feed into a validation gateway, an alerting system, or a repair loop. For example, if your customer_order object requires order_id, timestamp, and line_items, but the model returns order_id as null and omits timestamp entirely, this prompt will flag both failures distinctly—one as a null violation, the other as a missing key.
Do not use this prompt when you need to validate the semantic content of fields (e.g., 'Is this email address deliverable?'), when you need cross-field consistency checks (e.g., 'Does status: shipped require a non-null tracking_number?'), or when you are validating against a formal JSON Schema with type and format constraints. Those jobs belong to other prompts in the Format Compliance and Schema Validation group. This prompt is the first gate: presence before correctness. Wire it directly after LLM generation and before any downstream transformer, database writer, or API responder. If the presence report shows failures, route the payload to a repair prompt or a human review queue—never let it silently hit production.
Use Case Fit
Where the Field Presence and Required Attribute Audit Prompt delivers reliable automation and where it introduces unacceptable risk.
Strong Fit: CI/CD Schema Gates
Use when: You need an automated gate in a deployment pipeline that blocks malformed LLM outputs before they reach a production API. Guardrail: Pair the audit verdict with a hard failure threshold; any missing required field or type mismatch fails the build.
Strong Fit: Ingestion Pipeline Hygiene
Use when: You are ingesting structured LLM outputs into a data warehouse or operational database and must guarantee schema conformance. Guardrail: Run the audit before the write operation and route rejected payloads to a dead-letter queue for human triage.
Poor Fit: Subjective Content Quality
Avoid when: You need to judge the tone, helpfulness, or factual accuracy of a response. Guardrail: This prompt only checks structural presence, not semantic quality. Combine it with a separate LLM judge for groundedness or instruction adherence.
Required Inputs
What you must provide: A target JSON payload to audit and a schema registry defining required vs. optional fields, expected types, and nullable rules. Guardrail: The schema must be machine-readable and versioned; ambiguous schemas produce unreliable audits.
Operational Risk: Schema Drift
Risk: The audit prompt passes payloads that conform to an outdated schema, letting breaking changes into production. Guardrail: Version-lock the schema reference in the prompt and add a compatibility check step when schemas evolve.
Operational Risk: Null Ambiguity
Risk: The LLM confuses a missing field with an explicit null value, causing incorrect pass/fail decisions. Guardrail: Configure the prompt to distinguish three states—field absent, field null, field empty—and test against deliberately ambiguous payloads before deployment.
Copy-Ready Prompt Template
Paste this prompt into your evaluation harness to audit structured LLM outputs for field presence, distinguishing missing, null, and empty values against a schema registry.
The following prompt template is designed to be dropped directly into your evaluation harness. It instructs the model to act as a field-presence auditor, comparing a structured payload against a provided schema registry that defines required, optional, and nullable fields. The prompt is built to produce a deterministic, machine-readable report rather than conversational prose, making it suitable for automated CI/CD gates or pre-ingestion validation steps.
textYou are a field-presence auditor for structured LLM outputs. Your task is to compare the provided [PAYLOAD] against the [SCHEMA_REGISTRY] and produce a per-field presence report. ## INPUT [PAYLOAD] ## SCHEMA REGISTRY [SCHEMA_REGISTRY] ## NULL-HANDLING POLICY [NULL_HANDLING_POLICY] ## INSTRUCTIONS 1. Parse the [PAYLOAD] as [INPUT_FORMAT]. 2. For every field defined in the [SCHEMA_REGISTRY], determine its presence status in the [PAYLOAD]. 3. Classify each field into exactly one of the following categories: - **PRESENT_AND_VALID**: The field exists and its value is non-null and non-empty (unless the schema explicitly allows empty values). - **MISSING_REQUIRED**: The field is defined as required in the schema but is absent from the payload. - **NULL_WHEN_REQUIRED**: The field exists but its value is null, and the schema marks it as required and non-nullable. - **NULL_WHEN_OPTIONAL**: The field exists with a null value, and the schema permits null for this field. - **EMPTY_WHEN_REQUIRED**: The field exists with an empty value (empty string, empty array, empty object), and the schema requires a non-empty value. - **PRESENT_BUT_UNDEFINED**: The field exists in the payload but is not defined in the [SCHEMA_REGISTRY]. 4. Apply the [NULL_HANDLING_POLICY] to resolve ambiguous cases where the schema and payload disagree on nullability intent. 5. Do not validate types, formats, or value ranges. Only audit field presence and null/empty status. ## OUTPUT FORMAT Return a JSON object with the following structure: { "audit_summary": { "total_schema_fields": <number>, "present_and_valid_count": <number>, "missing_required_count": <number>, "null_when_required_count": <number>, "null_when_optional_count": <number>, "empty_when_required_count": <number>, "present_but_undefined_count": <number>, "overall_pass": <boolean> }, "field_results": [ { "field_path": "<string using dot notation for nested fields>", "status": "<PRESENT_AND_VALID | MISSING_REQUIRED | NULL_WHEN_REQUIRED | NULL_WHEN_OPTIONAL | EMPTY_WHEN_REQUIRED | PRESENT_BUT_UNDEFINED>", "schema_definition": { "required": <boolean>, "nullable": <boolean>, "allow_empty": <boolean> }, "observed_value_preview": "<truncated string representation of the value, max 100 chars>" } ] } ## CONSTRAINTS - Do not add commentary outside the JSON output. - Use dot notation for nested field paths (e.g., "address.city" not "address['city']"). - If the [PAYLOAD] is not parseable as [INPUT_FORMAT], return a single error object: {"error": "UNPARSEABLE_PAYLOAD", "detail": "<reason>"}. - Treat missing fields and null fields as distinct conditions per the [NULL_HANDLING_POLICY].
To adapt this template for your pipeline, replace the square-bracket placeholders with your actual inputs. The [SCHEMA_REGISTRY] should be a JSON object mapping field paths to their definitions (required, nullable, allow_empty). The [NULL_HANDLING_POLICY] should be a short text block resolving edge cases—for example, whether a field present with a null value counts as 'missing' when the schema says non-nullable. Wire the output JSON into a downstream validator that can block malformed payloads from reaching your ingestion pipeline or trigger a repair workflow when overall_pass is false.
Prompt Variables
Required inputs for the Field Presence and Required Attribute Audit Prompt. Wire these variables into your evaluation harness before running the prompt against structured LLM outputs.
| Placeholder | Purpose | Example | Validation Notes |
|---|---|---|---|
[TARGET_OUTPUT] | The structured LLM output to audit for field presence | {"name": "Acme", "status": null, "priority": "high"} | Must be parseable JSON. If unparseable, pre-process with a repair prompt before running this audit. |
[SCHEMA_REGISTRY] | Schema definition listing all expected fields with required/optional flags | {"fields": {"name": {"required": true}, "status": {"required": false, "nullable": true}, "priority": {"required": true, "enum": ["low","medium","high"]}}} | Must include a fields map with required boolean per field. Optional: nullable, enum, type keys for richer validation. |
[FIELD_PRESENCE_RULES] | Rules defining how to classify missing vs. null vs. empty values | {"treat_null_as_present": false, "treat_empty_string_as_missing": true, "treat_empty_array_as_present": true} | Default rules should be documented. Nullable fields with null values count as present if treat_null_as_present is true for that field. |
[OUTPUT_FORMAT] | Desired structure of the audit report | json | Must be one of: json, markdown_table, csv. JSON is recommended for downstream parsing. Validate enum before sending. |
[REQUIRED_FIELDS_ONLY] | Whether to audit only required fields or all fields in the schema registry | Boolean. When true, optional fields are excluded from the report. When false, all fields are audited with their required/optional status noted. | |
[INCLUDE_FIX_SUGGESTIONS] | Whether the audit report should include remediation guidance for missing fields | Boolean. When true, each violation includes a suggestion field. When false, only pass/fail and field status are returned. | |
[CONFIDENCE_THRESHOLD] | Minimum confidence score for field presence classification before flagging for human review | 0.95 | Float between 0.0 and 1.0. Fields classified below this threshold should be marked uncertain and routed for manual inspection. |
Implementation Harness Notes
How to wire the Field Presence and Required Attribute Audit Prompt into an ingestion pipeline with validation, retries, and logging.
This prompt is designed to sit directly after structured output generation and before any downstream database write or API dispatch. In a typical ingestion pipeline, the LLM generates a JSON payload, and this audit prompt receives both the raw output and the expected schema registry (a mapping of field names to their required/optional/nullable status). The harness should call this prompt synchronously as a validation gate: if the audit report shows any missing required fields, the pipeline must not proceed. Treat the audit prompt's output as a structured decision, not a suggestion.
To implement, wrap the prompt in a function that accepts generated_output (the raw JSON string from the primary LLM) and schema_registry (a JSON object defining each field's constraints). The function should inject these into the [OUTPUT_TO_AUDIT] and [SCHEMA_REGISTRY] placeholders. On return, parse the audit report and check for a has_violations boolean or scan the field_results array for any entry where status is missing and required is true. If violations exist, log the full audit report, increment a field_presence_failure metric, and route the record to a dead-letter queue for human review. For high-throughput systems, consider batching multiple outputs into a single audit call with a clear delimiter to reduce API overhead, but ensure each record's report is independently parseable.
Model choice matters here. This is a classification and comparison task, not a generative one, so prioritize models with strong instruction-following and low hallucination rates on structured analysis. A smaller, faster model (e.g., Claude Haiku or GPT-4o-mini) is often sufficient and keeps latency low for this synchronous gate. Do not use a creative or general-purpose model that might invent field statuses. Implement a simple retry with exponential backoff (max 3 attempts) if the audit prompt itself returns malformed JSON, but if the audit report is valid and shows violations, do not retry the audit—retry the primary generation step instead, or escalate. Always log the full prompt input and output for every audit failure to enable later analysis of schema drift or model behavior changes.
Avoid wiring this prompt as an asynchronous, fire-and-forget check. The value is in blocking bad data before it lands in your database or triggers downstream workflows. If your pipeline uses a streaming architecture, buffer the generated output until the audit verdict returns. For high-risk domains like finance or healthcare, add a human-in-the-loop step: if a required field is missing, surface the record in a review queue with the audit report pre-filled, rather than auto-discarding or auto-repairing. Finally, maintain your schema registry as a versioned artifact in the same repository as your prompts. When the schema changes, re-run your eval suite (see the Regression Testing pillar) to ensure the audit prompt's false-positive and false-negative rates haven't drifted.
Expected Output Contract
The judge's response must conform to this contract. Use these fields, types, and validation rules to parse the output programmatically and trigger retries or human review on failure.
| Field or Element | Type or Format | Required | Validation Rule |
|---|---|---|---|
audit_id | string | Must match the [AUDIT_ID] provided in the prompt input. Non-matching or missing value triggers a retry. | |
schema_version | string | Must be a valid semantic version string matching the [SCHEMA_VERSION] input. Parse check: regex ^\d+.\d+.\d+$. | |
overall_status | string | Must be exactly 'pass' or 'fail'. Any other value triggers a schema violation. | |
field_results | array of objects | Must be a non-empty array. Each element must conform to the field_result object schema defined in the prompt. | |
field_results[].field_name | string | Must exactly match a field name from the [REQUIRED_FIELDS] list. Unknown field names trigger a warning log. | |
field_results[].presence | string | Must be one of: 'present', 'missing', 'null', 'empty_string'. Enum check required. | |
field_results[].expected_required | boolean | Must be true or false. Parse check: strict boolean, not string 'true'/'false'. | |
field_results[].conforms | boolean | Must be true if presence matches the required expectation, false otherwise. Cross-field consistency check: if expected_required is true and presence is not 'present', conforms must be false. |
Common Failure Modes
Field presence audits fail in predictable ways. Here's what breaks first and how to guard against it.
Null vs. Missing Confusion
What to watch: The LLM treats a missing field and an explicit null as equivalent, causing false passes when a required field is absent. Guardrail: Define a three-state check in your schema registry (present, null, missing) and test the prompt against payloads where required fields are completely omitted, not just set to null.
Empty String Pass-Through
What to watch: A required field containing an empty string passes presence checks but fails downstream business logic. Guardrail: Add a semantic emptiness check that flags zero-length strings, whitespace-only values, and placeholder text like 'N/A' or 'TBD' as distinct from valid populated fields.
Schema Drift Between Registry and Prompt
What to watch: The prompt references an outdated schema version, so the audit marks newly required fields as optional or ignores deprecated fields that should now be absent. Guardrail: Version-lock the schema reference in the prompt with a hash or timestamp, and add a pre-audit check that the schema version matches the expected registry state.
Nested Field Blindness
What to watch: The audit checks top-level fields but misses required attributes nested inside objects or arrays, producing a false-clean report. Guardrail: Require recursive traversal in the prompt instructions and include test payloads with missing nested required fields at depth 2 and 3 to verify coverage.
False Negative on Optional Fields
What to watch: The prompt flags optional fields as missing when they are legitimately absent, flooding the report with noise and eroding trust in the audit. Guardrail: Explicitly pass the optional/required distinction from the schema registry into the prompt context, and include a confidence or severity tier so optional absences are noted but not treated as failures.
Large Payload Truncation
What to watch: The audit prompt receives a truncated or incomplete output, so it only checks the fields it can see and misses missing fields in the cut-off portion. Guardrail: Add a pre-audit completeness check that verifies the payload ends with a valid closing token (brace, bracket, or tag) before running the field presence audit, and abort with an explicit truncation error if incomplete.
Evaluation Rubric
Use this rubric to evaluate the quality of the Field Presence and Required Attribute Audit output before integrating it into a production pipeline. Each criterion targets a specific failure mode common in schema compliance checks.
| Criterion | Pass Standard | Failure Signal | Test Method |
|---|---|---|---|
Field Presence Accuracy | All fields from [SCHEMA_REGISTRY] are listed in the report with a correct presence status (present, missing, null, empty). | A required field is incorrectly marked as 'present' when it is missing from the [OUTPUT_PAYLOAD]. | Diff the report's field list against the schema registry's required and optional field definitions. Verify a random sample of 5 fields against the raw payload. |
Null vs. Missing Distinction | The report correctly distinguishes between a key that is absent from the payload ('missing') and a key present with a null value ('null'). | A field with a null value is reported as 'missing', or a truly absent key is reported as 'null'. | Provide a test payload where [REQUIRED_FIELD] is set to null and another where it is omitted entirely. Check the report's status for each case. |
Empty Value Detection | Fields with empty strings (''), empty arrays ([]), or empty objects ({}) are flagged as 'empty' and not confused with 'null' or 'missing'. | An empty string is reported as 'present' without an 'empty' flag, or is misclassified as 'null'. | Inject a test payload with [OPTIONAL_FIELD] set to '' and [REQUIRED_ARRAY] set to []. Verify the report flags both as 'empty'. |
Required Field Violation Flagging | Every field marked as 'required: true' in the [SCHEMA_REGISTRY] that is missing, null, or empty in the payload triggers a 'VIOLATION' status. | A required field is missing from the payload, but the report shows a 'COMPLIANT' status for that field. | Use a test payload that omits a known required field. Assert that the report's status for that field is 'VIOLATION' and the overall pass/fail verdict is 'FAIL'. |
Optional Field Handling | Optional fields that are missing from the payload are reported as 'missing' with a 'COMPLIANT' status and do not trigger a violation. | A missing optional field is flagged as a 'VIOLATION', causing a false negative in the overall pass/fail verdict. | Provide a payload that omits several optional fields. Assert that the report marks them as 'COMPLIANT' and the overall verdict is 'PASS' if no other violations exist. |
Schema Registry Alignment | The report uses the exact field names and required/optional designations from the provided [SCHEMA_REGISTRY]. | The report audits a field not present in the schema, or misattributes a field's required/optional status. | Cross-reference the field names in the report against the keys in the [SCHEMA_REGISTRY]. Verify the required/optional flag for each matches the source definition. |
Overall Verdict Correctness | The final 'pass' or 'fail' verdict is a logical AND of all per-field compliance statuses. Any single 'VIOLATION' results in a 'FAIL'. | The report returns a 'PASS' verdict despite one or more fields having a 'VIOLATION' status. | Run a test suite of 10 payloads with a known mix of passing and failing cases. Assert the overall verdict matches the expected outcome for each. |
Report Structure Validity | The output is a valid JSON object matching the [OUTPUT_SCHEMA] with all required fields present. | The report is missing the 'overall_verdict' or 'field_report' keys, or contains malformed JSON. | Parse the output with a JSON validator. Assert it conforms to the expected [OUTPUT_SCHEMA] using a schema validation tool. |
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 hardcoded schema list. Replace [SCHEMA_REGISTRY] with a simple JSON object defining required vs. optional fields. Use [INPUT] as a single JSON payload. Skip the eval harness initially—just run 5-10 examples manually and check the presence report for obvious misses.
Watch for
- The model treating empty strings as 'present' when your schema considers them absent
- Null vs. missing key confusion—test both cases explicitly
- Overly verbose explanations when you only need the structured report

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