A pre-answer RAG gate: decide whether the retrieved context is sufficient to answer, and produce a safe "I don't know" response when it isn't.
A pre-answer gate for RAG: before you spend a synthesis call, decide whether the retrieved context can actually answer the question — and when it can't, emit a safe "I don't have enough information" response instead of letting the model improvise from outside knowledge. The decision (can_answer) comes first, so it's a cheap boolean you can branch on.
This is the RAG guardrail. It is distinct from an answer-faithfulness judge: this runs before answering and gates on context sufficiency; it does not evaluate an existing answer.
| Entrypoint | Renders | Inputs |
|---|---|---|
system | The gate instructions + embedded output schema | — |
user | The delimited context + question | context, question |
Render system as the system message and user as the user message.
question (string, required) — the question the context must be able to answer.context (string, required) — the retrieved context to judge. One or more concatenated passages. Pass an empty string when retrieval returned nothing — the gate handles it (can_answer: false).parseOutput() returns:
{
"can_answer": false,
"reasoning": "The context covers shipping times but says nothing about refund eligibility, which is what was asked.",
"missing_information": ["the refund eligibility window", "whether opened items can be returned"],
"suggested_response": "I don't have enough information to answer that from the available context. I can help if you can point me to the refund policy."
}
When the context is sufficient:
{ "can_answer": true, "reasoning": "The context states the 30-day refund window directly.", "missing_information": [], "suggested_response": "" }
can_answer is first — the gate decision. Branch on it: true ⇒ proceed to synthesis; false ⇒ show suggested_response and skip answering.reasoning explains the verdict (what the context does/doesn't provide).missing_information names the specific gaps when can_answer is false — the most useful signal for debugging retrieval. Empty when true.suggested_response is a ready-to-show refusal that never speculates. Empty string when can_answer is true.can_answer leads), key order pinned in the system prompt — same shape as csat-risk-detection's boolean gate.can_answer: false with non-empty missing_information and a refusal suggested_response (specified, not left to chance).Verified against the live API: sufficient context → can_answer: true; insufficient / off-topic / empty context → can_answer: false with gaps listed and a refusal message. Suggested default claude-sonnet-4-6 at temperature: 0. The guardrail stage of the RAG Essentials pipeline: rewrite → decompose → grade → guardrail → synthesize. Put it directly in front of answer-synthesis.