Output Format Contracts: Make Agent Responses Machine-Safe

Define strict output formats and what to do when the model breaks them.

Added October 15, 2026. Written with AI assistance and checked for clarity and placeholders; not reviewed by a lawyer, accountant, clinician or other professional. How these prompts are made

The Open buttons send the prompt text as currently shown below to that site only when you click. Fill in the placeholders first.

Design an output format contract for an agent whose responses feed into [DOWNSTREAM_SYSTEM]. The fields needed: [REQUIRED_FIELDS]. Allowed values and ranges: [ALLOWED_VALUES]. Common failure modes seen: [FAILURE_MODES].

Write: the JSON schema in words and as a block; an instruction paragraph telling the model to return only the JSON, with a separate field for notes; rules for missing data (null, not invented), enumerated values, dates in ISO format, and numbers without units in strings; a validator checklist (types, required fields, ranges, extra keys); and a repair prompt to send back when validation fails, which quotes the error and asks for corrected JSON only. Specify a maximum of two repairs before escalation to a human. Provide three valid examples and three invalid ones with the validator's error for each. Add logging guidance without storing sensitive content.

Explain in a short paragraph why prose and structured output should be separated.

Add a repair-prompt example that quotes a validator message such as 'field due must be an ISO date, got next Friday' and asks for corrected JSON only, then show the corrected output, and describe how to count and review repair rates weekly as a signal that the main prompt needs work.

Fill in before use

Optional: type your details and the prompt above updates. Nothing is saved or sent.

Replace each bracketed placeholder with your own details, then paste into Any AI or another assistant.

See an example result (fictional data)
Valid: {"status": "ok", "due": "2025-07-01", "priority": "high", "notes": "Customer asked for a call."}
Invalid: {"status": "done", "due": "next Friday", "priority": 2}
Validator errors: status must be one of ok, needs_info, failed (got 'done'); due must be an ISO date (got 'next Friday'); priority must be low, medium or high (got 2); notes is required.
Repair prompt: 'Your last output failed validation: [errors]. Return corrected JSON only.' Maximum two repairs, then hand over to a person.
Logging: record the error text and the number of repairs, not the user's content. If repairs exceed 5 percent of calls in a week, review the main prompt; the notes field holds any prose so the other fields stay machine-safe.

Illustrative only, made-up data. Your results will differ and must be reviewed.

Rate this prompt

Related prompts