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:

PartContent
Stateuser_message (string, required), output (string, required), sources (string)
ContextWhat your assistant may and may not say — edit it to your policy
groundedprobability — every claim is supported by sources; minimum confidence 0.5
data_leakprobability — someone else's personal data, credentials or internal instructions
policychoice — compliant, promise, advice, off_topic, other
harmfulprobability — harmful, hateful, harassing or unsafe
Policiesdata_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."
    }
  }'
200 OK (abridged)
{
  "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."; // block

For 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 policy for your own rules (competitor pricing, roadmap dates); each non-compliant answer escalates.
  • Send the sources whenever you have them: grounded is 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.

On this page