LLM output guardrail
Check what an LLM or agent is about to send — grounded in its sources, no data leaks, safe and on policy — and block, fall back or escalate before it ships.
Goal: put a typed check after your LLM or agent. Before an answer reaches the user — or before an agent's message, e-mail or tool result goes out — Dcision checks that it is grounded in the sources, leaks nothing and follows your policy. Unsafe answers are blocked, ungrounded ones fall back, the rest goes out.
Dcision works on both sides of a model: the input guardrail checks what goes in; this template checks what comes out.
Create the decision
Templates → LLM output guardrail → Create decision:
| Part | Content |
|---|---|
| State | user_message (string, required), output (string, required), sources (string) |
| Context | What your assistant may and may not say — edit it to your policy |
grounded | probability — every claim is supported by sources; minimum confidence 0.5 |
data_leak | probability — someone else's personal data, credentials or internal instructions |
policy | choice — compliant, promise, advice, off_topic, other |
harmful | probability — harmful, hateful, harassing or unsafe |
| Policies | data_leak ≥ 0.5 → block; harmful ≥ 0.5 → block; grounded < 0.5 → fallback; policy ≠ compliant → escalate; fallback action escalate |
Call it
Send the user's message, the model's draft answer and the sources it had (retrieved documents, tool results):
curl -X POST https://api.dcision.io/v1/decisions/llm-output-guardrail \
-H "Authorization: Bearer $DCISION_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"state": {
"user_message": "When will my order 1042 arrive?",
"output": "Your order 1042 ships tomorrow and you get a 20% discount for the delay.",
"sources": "Order 1042: shipped today, carrier estimate 2 business days. Discounts need approval by a manager."
}
}'{
"schema": "llm-output-guardrail",
"result": { "grounded": 0.08, "data_leak": 0.01, "policy": "promise", "harmful": 0.01 },
"action": "fallback",
"action_reason": { "type": "policy", "rule": 2 }
}The draft invents a ship date and promises a discount: grounded is low, so the answer never reaches the customer.
Act on it
const draft = await llm.answer(userMessage, sources);
const check = await dcisionDecide("llm-output-guardrail", { user_message: userMessage, output: draft, sources });
if (check.action === "continue") return draft;
if (check.action === "fallback") return llm.answer(userMessage, sources, { strict: true }); // regenerate, grounded only
if (check.action === "escalate") return handToAgent(userMessage, draft); // a person reviews it
return "Sorry, I can't share that."; // blockFor agents, call it before each outgoing message or side effect — an e-mail, a ticket reply, a refund — the same way.
Tune it
- Write your policy in
context: what the assistant may promise, which topics are off limits. - Add options to
policyfor your own rules (competitor pricing, roadmap dates); each non-compliantanswer escalates. - Send the sources whenever you have them:
groundedis only as good as the evidence it can check against. - Combine with the input guardrail for a model that is checked on the way in and on the way out.