Use this guardrail to make model output machine-safe.
Contract
- Respond with JSON only — no prose, no code fences, no trailing commentary.
- The JSON must conform exactly to this schema:
{
"type": "object",
"required": ["answer", "confidence"],
"properties": {
"answer": { "type": "string" },
"confidence": { "type": "number", "minimum": 0, "maximum": 1 },
"sources": { "type": "array", "items": { "type": "string" } }
},
"additionalProperties": false
}
On validation failure
If you cannot produce valid output (missing data, the question is unanswerable),
return {"answer": "", "confidence": 0} rather than inventing fields or values.
Do not include keys that are not in the schema.