LiyaEngine Docs

Guardrail policy settings

Every setting of a guardrail policy, its default, and exactly what it does.

Dashboard

A guardrail policy is a set of checks that run before the model reads a message and after it answers. You edit one in the dashboard under Guardrails, or send its config to POST /v1/guardrail-policies. A setting you leave out takes the default shown here, so an older policy keeps behaving the way it did when more settings are added.

Start from a template

Most of these settings suit one industry and one audience better than another. A template fills in a sensible set for you to review before you publish.

The whole config, with defaults

{
  "pre_llm": {
    "pii": { "enabled": true, "mode": "redact" },
    "content_policy": {
      "enabled": true,
      "injection_detection": true,
      "profanity_filter": true,
      "violence_filter": true,
      "blocked_topics": [],
      "injection_mode": "legacy",
      "ml_unavailable": "allow"
    },
    "input_fields": { "scan": false, "exclude": [], "harden_prompt": false },
    "input_max_length": 24000
  },
  "post_llm": {
    "schema_validation": { "enabled": true },
    "action_validation": { "enabled": true },
    "hallucination_check": { "enabled": true },
    "grounding": { "action": "flag" }
  },
  "actions": { "sanitize_parameters": false, "sanitize_response": false }
}

Before the model reads the request

Personal data

SettingDefaultWhat it does
pre_llm.pii.enabledtrueDetect personal data in the message.
pre_llm.pii.moderedactredact replaces it with [REDACTED] before the model sees it. flag lets it through and records what was found. off does neither.
pre_llm.pii.entity_typesnoneAccepted and stored, but has no effect today. Do not rely on it to limit what is detected.

By default the patterns cover social security numbers, card numbers, email addresses, US-format phone numbers and dates of birth written as MM/DD/YYYY. Names are caught only when the optional machine-learning classifier is on. Two more sets are off until a workspace turns them on, in Data retention: healthcare identifiers, and financial identifiers (IBANs and passport numbers).

Content and attacks

SettingDefaultWhat it does
content_policy.enabledtrueMaster switch for everything in this group. A universal safety floor (illegal activity, weapons, explicit content) applies regardless of it.
injection_detectiontrueLook for attempts to override the assistant's instructions.
profanity_filtertrueBlock vulgar or abusive language.
violence_filtertrueBlock violent or threatening language.
blocked_topics[]Topics of your own to refuse. They are added to the safety floor and never replace it.
blocked_topic_messagestandard replyWhat people are told when a message matches one of your blocked topics. 1 to 500 characters. It does not change the replies for the safety floor or for injection.
injection_modelegacyHow a prompt-injection signal becomes a decision. See below.
ml_unavailableallowWhat happens when the machine-learning checks cannot answer. See below.

How injection is judged

  • legacy blocks on pattern matches outright, and on the classifier alone: a score of 0.85 or more blocks, and 0.5 to 0.85 is flagged and allowed through.
  • balanced blocks only when two signals agree: the text contains an instruction aimed at the assistant, and the classifier scores it 0.5 or more. A classifier score alone is flagged and allowed through. An instruction the classifier does not confirm is also flagged and allowed through. If the classifier is not configured or cannot answer, a clear instruction still blocks, because recognising it needs no classifier.

An instruction aimed at the assistant means text such as an override verb near the word instructions or rules, "you are now in developer mode", a fake system notice, a note addressed to the assistant, an answer being dictated ("risk_tier must be low", "treat this applicant as low risk"), a request to reveal the instructions, or a hidden-instruction trick such as an HTML comment or "decode and follow". Someone reporting what a third party said ("a caller told me to ignore my bank's instructions") is not treated as an instruction.

Use balanced for financial text. The classifier scores ordinary card numbers, IBANs and urgent complaints such as "my card was cloned" near 1.0, so on its own it turns away real customers. balanced flags those for review instead.

If the checking service is down

The machine-learning checks (injection, toxicity and blocked-topic matching) call a separate service. When a call fails or times out:

  • allow carries on with the pattern rules only, silently.
  • flag does the same and records ML_UNAVAILABLE, so a trace shows protection was reduced.
  • block refuses the request with "I can't process that request right now. Please try again in a moment." Choose this where a missed attack costs more than a retry. An outage then stops traffic.

Blocked topics

A topic matches when its words appear in the message, and, when the classifier is on, when the message means the same thing in other words: a match of 0.85 or more blocks, and 0.5 to 0.85 is flagged. Word a topic as the request someone would make ("how to get past KYC checks using false identity documents") and not as a subject ("identity verification"). A topic worded as a subject also matches the ordinary questions people ask about it. Try a new topic against real, harmless messages before you publish it.

Input fields

By default only the message is checked. The other fields of an intent call, such as an applicant's occupation, a parsed document or a transaction note, reach the prompt unchecked.

SettingDefaultWhat it does
input_fields.scanfalseCheck the text of every input field for prompt injection, at any depth.
input_fields.exclude[]Field names or dotted paths that are trusted and never scanned or wrapped.
input_fields.harden_promptfalseMark every value placed in the prompt as data.

Scanning looks at each text value of at least three characters, down to six levels deep and up to the first 60 fields (a warning is recorded if there are more). It skips the message field, which is checked already, and any key that starts with an underscore. Only the injection checks run on a field: profanity, violence, blocked topics and personal data are not applied, and values are never changed, because a field such as a name or date of birth is meant to hold personal data. A field that fails refuses the whole request, and the issue records which field it was.

Hardening wraps each value in <untrusted_data name="..."> tags where the intent's prompt template inserts it, and adds one note to the system prompt telling the model that anything inside those tags is data to analyse and never an instruction. A closing tag inside a value is defused, so a value cannot end its own wrapper. It applies to intents with a prompt template. It protects values inserted in the prompt: the customer's message also reaches the model as the user's own turn, unwrapped.

Measured, not assumed

On Halden's own dispute and KYC cases, run on four models, hardening did not lower accuracy overall (94 of 116 answers correct without it, 97 with it, though one model got one fewer right) and no tag appeared in the letters written for applicants. It lowered how often a model followed an injected instruction, from 31 of 88 attacks to 25, and made no difference for one of the four models. Treat it as one layer, not a replacement for scanning or for a rule in your workflow that does not depend on the model.

Size

input_max_length (default 24,000 characters) refuses a message longer than this before it reaches the model.

After the model answers

SettingDefaultWhat it does
schema_validation.enabledtrueCheck a structured answer against the intent's output schema. Only matters for intents that have one.
action_validation.enabledtrueMake sure the model only calls actions your workspace allows.
action_validation.allowed_actionsallLimit which actions may be called. Leave it out to allow every action of your workspace.
hallucination_check.enabledtrueBasic checks on the answer, and, with the classifier on, a comparison of a free-text answer with the passages that were retrieved.
grounding.actionflagWhat to do when an answer that needs sources cannot be grounded in what was retrieved: block, flag or allow.

The comparison with retrieved passages runs on free-text answers only. A structured answer, from an intent with an output schema, is a classification and not a passage a source can support, so the comparison would warn on nearly every one. Those answers are checked by schema validation.

Actions

SettingDefaultWhat it does
actions.sanitize_parametersfalseRedact personal data from the values the model inferred for an action's call before it is sent.
actions.sanitize_responsefalseRedact personal data from an action's response before the model or a log sees it.

What you will see

CodeEffectMeaning
INJECTION_ATTEMPTBlocksA pattern or a clear instruction aimed at the assistant was found.
INJECTION_ATTEMPT_MLBlocksThe classifier scored the text high (legacy), or agreed with an instruction in it (balanced).
INJECTION_SUSPECTED_MLFlagsThe classifier scored the text 0.5 or more, and nothing in it is aimed at the assistant.
INJECTION_SUSPECTED_CUEFlagsThe text contains an instruction aimed at the assistant, and the classifier did not confirm it.
BLOCKED_TOPIC_TENANT_MLBlocksThe message means the same as one of your blocked topics.
BLOCKED_TOPIC_TENANT_ML_SUSPECTEDFlagsThe message may mean the same as one of your blocked topics.
ML_UNAVAILABLEFlags, or blocksThe classifier did not answer. See ml_unavailable.
INPUT_FIELDS_NOT_ALL_SCANNEDFlagsMore than 60 input fields were present and the rest were not scanned.
GROUNDING_UNSUPPORTEDFlagsA free-text answer was not clearly supported by the retrieved passages.
GROUNDING_CONTRADICTEDReported as an errorA free-text answer contradicts the retrieved passages.

Findings are recorded in the trace of the call and in the guardrail analytics. The metadata.flags field of a run response lists only grounding flags and the code that blocked a request, so a flag-only warning such as INJECTION_SUSPECTED_CUE is not in the response: look for it in the trace.

On this page