UnieAI Studio

Guardrail Rules and Intercepts

Use an LLM judge to inspect custom-model inputs and outputs, configure refusal behavior, and review blocks and misfires.

Guardrails use another model as an LLM judge. An input judge can run before the request reaches the base model, and an output judge can run before the response is delivered. The judge returns an allow-or-deny decision, rationale, and policy categories.

AI review is probabilistic, and local rules only check configured patterns. Neither guarantees complete detection or compliance. Review the original data and recorded actions, and use permissions and human review appropriate to the task.

Open Guardrail rules

Open an agent from Agent Builder → My Agents.
Open the top Guardrails tab, or use Guardrails in the Behavior card on its Setup page.

Custom-model owners and co-editors can configure rules; read-only users cannot open this page. Platform administrators can configure defaults under Admin Panel → System Models → Safety & evaluation.

 Review protection scope under Guardrails, then configure blocked topics and the refusal reply; these are separate from generation parameters.
Review protection scope under Guardrails, then configure blocked topics and the refusal reply; these are separate from generation parameters. Click to enlarge

Configure a guardrail

SettingPurpose
Enable guardrailControls input, output and tool-content inspection, subject to the effective platform and model policy
Tool guardrailRuns only when enabled with a configured mode, detectors and actions
Apply to inputEvaluates user content before calling the base model
Apply to outputEvaluates model content before delivering it
Judge modelSelects the judging model from Model Zoo
Input/output promptsDefine policy and categories for each stage
Refusal messageText returned to the API consumer after a block
Fail-openAllows content to continue if the judge errors, is unavailable, or times out
Output check charactersAmount of accumulated streaming output that triggers a check
Minimum output-check delayMinimum interval between checks during streaming output

The current Studio configuration selects a judge from connected Model Zoo base models. The model must reliably produce the structured decision required by the prompt. Studio warns when a selected model may not support the necessary tool or structured-call behavior.

Topics and AI-generated rules

Apply a built-in topic preset, create a custom topic, or describe allowed or prohibited behavior in natural language and ask AI to draft a policy. Always review the resulting input prompt, output prompt, categories, and refusal message before saving and testing it.

Judge output format

Both prompts must require JSON in this shape:

{
  "allowed": false,
  "reason": "The request asks for prohibited instructions.",
  "categories": ["unsafe_instructions"]
}
  • allowed controls whether content proceeds.
  • reason explains the decision.
  • categories contains matched policy categories and can be empty.

The runtime appends JSON-only and conservative-decision instructions, but explicit, testable policy language is still important for reducing misfires.

Tool guardrail

The input guardrail sees what the user said and the output guardrail sees what the model said. Neither sees a third kind of content: what tools and knowledge bases bring back — web search results, API and MCP server responses, database rows, retrieved document passages.

That content goes straight into the model's conversation history, and models treat history as trustworthy. So anyone who can influence those sources — a sentence hidden in a web page, a shared document, an API response — can steer the model. This is indirect prompt injection, and the tool guardrail exists for it.

What it looks for

DetectorCovers
Prompt injectionInstruction-override phrasing (EN/ZH/DE/ES), declarations that the standing instructions are void, probes for the system prompt or preceding text, coercion for confidential data ("or I will expose your records"), demands for credentials and medical records, jailbreak persona substitution (the DAN family), forged chat control tokens, directives hidden in HTML comments
Personal dataTaiwan national ID (checksum-verified), credit cards (Luhn-verified), email, mobile numbers
Secret leakageOpenAI / GitHub / AWS / Slack credentials, JWTs, PEM private keys, and high-entropy secret assignments

Checksum validation reduces look-alike matches, but a valid checksum does not prove that a value is a real ID or credit card. Order numbers and other data can still match. Review the source, the action taken and any false-positive report before changing a rule.

The rule list, and adding your own

There are 33 built-in rules (22 prompt injection, 7 secret, 4 personal data), listed one per row in the settings screen with their category, severity, and a sample string the rule fires on. Showing an example rather than a regular expression is deliberate: deciding whether to switch a rule off means knowing what it catches, and a regex answers that badly. Review each example before choosing whether to enable its rule.

Built-in rules can be changed within the platform permissions. Unset model values inherit the platform configuration. A model cannot disable a rule required by a minimum or locked setting; an unrestricted setting can be overridden.

A custom rule is a phrase, not a regular expression. * stands for an intervening gap of up to 60 characters, as in internal only*forward. The restriction is deliberate: these rules run on every tool result, and one badly written regex ((a+)+$) backtracks catastrophically enough to stall the service, whereas a phrase with a bounded gap cannot. Platform and model custom rules are additive — the platform's apply everywhere, and a model adds its own on top.

Coverage

Every tool: web search, web fetch, API tools, MCP servers, SQL queries, knowledge-base retrieval, BI and data map. Non-agent RAG is covered too — its retrieved passages are inspected before they enter the prompt.

What runs at each stage

The same pattern means different things depending on who wrote the text, so rule detection is scoped per stage:

StageDetectors appliedWhy
Tool and retrieved contentPrompt injection, personal data, secretsThis content comes from documents, web pages and APIs — exactly what the rules were written for
Model outputSecrets onlyThe model must never emit a credential; PII rules on output would break legitimate answers about the user's own records
User inputNoneA regex cannot stop an attacker who rephrases, but it will block a user pasting their own ID number. Input goes to the judge, which understands context

The deeper layer: tell the model it is data

Rule matching only catches known patterns. So the system prompt carries a standing rule stating that tool results and retrieved content are always data: only the system prompt and the user's own messages can direct the model, and content asking it to ignore instructions, change persona, reveal configuration, or call a tool must be refused and reported.

That rule does not depend on recognising the attack, so it also covers techniques no pattern knows about — and it is the cheapest layer here, costing one prompt fragment per turn.

What happens on a hit

ActionBehavior
AnnotateKeeps all content and prepends a notice telling the model this is data, not instructions
RedactReplaces only the matched spans with [redacted]
BlockWithholds the content entirely

Use the effective action shown in the settings. Annotation preserves content with a notice, redaction changes matched values, and blocking withholds content. An unset action means inheritance, not automatic annotation.

Relationship to the guardrail switch

When the effective guardrail switch is off, input, output and tool-content scanning do not run and do not create new hit records. Unset fields do not silently activate local detection.

  1. Check the effective switch first. A platform minimum or lock may require it to remain on; the interface shows that restriction.
  2. To inspect tool content, also select rule detection or AI review, the detectors, and their actions. Tool scanning does not run when its mode is off or required configuration is absent.
  3. Following the platform default inherits the administrator's configured value. If neither level supplies a value, the field does not silently become detection or annotation.
  4. AI review needs a usable judge. Check configuration and request records when the judge is missing or unavailable; absence of a decision is not a successful check or a promise to switch modes.

Blocked sites and sensitive-data routing have separate settings. Check them directly rather than inferring their state from the content-scanning switch.

Action on a hit: set per detector kind

Prompt injection, personal data and secrets get their own action, because they deserve different handling. With a secret or an ID number the value IS the risk: blank it and the rest of the passage still answers the question. An injection is not like that — delete a few words and the sentence is still a command.

When one passage trips several kinds, the actions compose, and there are only two rules:

  1. Any kind set to block withholds the whole passage. There is no "block and also annotate" — once it is withheld there is nothing left to mark up.
  2. Otherwise the kinds asking for redaction get blanked, and the banner is added if any kind asked to annotate or an injection was redacted. That second clause matters: redacting an injection silently hands the model a mangled command with no warning.

The settings screen offers three scenarios, each spelling out what it sets:

ScenarioCombinationWhen
General useInjection annotated · personal data redacted · secrets redactedThe most complete answers: values are removed but the content stays, and the injection is called out so the model does not follow it
High sensitivityInjection blocked · personal data redacted · secrets redactedA poisoned source is withheld entirely. The cost is that the retrieval may have nothing left to use and the answer goes empty
Observe firstAll three annotatedNothing is altered; hits are only recorded and flagged. For when the guardrail has just been switched on and you are still learning what it catches

Each row stays adjustable after picking a scenario. A kind with no explicit action falls back to the single action setting, so every model configured before this existed behaves exactly as it did.

Blocking sites

The tool guardrail can block specific sites: listed domains never appear in web search results, and the model cannot read their pages. Listing example.com covers its subdomains, because whoever owns the domain owns those too — while notexample.com is not caught by it.

Two implementation details decide whether this actually holds. Web search drops matching results before it formats them, so the model never sees them and only gets one line saying how many were excluded (without that line it invents an explanation for a short list). Web fetch checks every redirect hop, before the private-address guard — checking only the URL the model was given is bypassed by a single redirect, and a blocked host should not even be resolved.

The platform's list and the model's add up: blocking more is the stricter direction.

Who may change what

Guardrail authority splits into three independent questions, because they have different answers.

1. May this model configure anything? One platform policy:

PolicyMeaning
Open (default)Every custom model may configure its own guardrail, within the limits below
RestrictedOnly the listed models may; everything else applies the platform settings read-only

A model without the right still sees what it is subject to, shown read-only with a note that the platform manages it — not knowing what applies to you is worse than not being able to change it.

2. How far may it go on each setting? The platform picks one value per setting:

ValueOn the model's pageCan an exception be requested
Not enforcedFully editableNot needed
MinimumEditable, but options looser than the platform's are not offeredYes
LockedRead-onlyNo

The difference between minimum and locked is whether it is open to discussion. Choosing per setting is choosing both the strictness and whether anyone may argue with it.

3. Is there an approved exception? See below.

Whatever the policy and the level, any model may add: more blocked domains, more phrase rules. Those can only make it stricter, and refusing them buys no safety.

Requesting an exception

An owner blocked by a minimum can ask right next to the setting: what they want instead, why, and an optional expiry. An administrator answers from the admin panel, and an approval becomes an exception.

The grant covers this model, this setting, this value — approving "annotate instead of block" is only that. Other settings on the same model, and later platform changes elsewhere, are unaffected.

  • Exceptions can expire. "Just for this quarter" is the normal case, and permanent ones accumulate into holes nobody remembers agreeing to. On expiry the setting returns to the platform value.
  • Both answers are recorded, with the reason. A refusal is visible to the requester rather than being a silent failure.
  • An administrator can revoke at any time, and revocation takes effect within seconds rather than at expiry.
  • Locked settings accept no requests, and the page does not offer the affordance.
  • Approval, refusal and revocation all notify the requester, carrying the administrator's note and a link back to the setting.
  • An expired exception reads as expired: expiry is evaluated when the row is read rather than by a background job, so the screen and the engine never disagree.

Administrators work the queue under Admin panel → System models → Safety and evaluation → Exception requests, split into pending / approved / denied. A denial requires a note, because the requester reads it. Model owners see every request they filed, and its answer, on the Tool guardrail sub-page — including the administrator's note and the expiry date.

When a platform minimum applies

For each setting the platform chooses unrestricted, minimum or locked. Only a minimum prevents the model from choosing a looser value; a lock uses the platform value. An unrestricted field can be overridden within the assigned permissions, or inherited when unset.

SettingWhich way is stricter
Guardrail on / check input / check outputOn beats off — a model cannot switch off what the platform switched on
Tool guardrail modeAI review > rule matching > off
Action on a hitBlock > redact > annotate
When the guardrail itself failsStopping beats answering
DetectorsMore is stricter — a model cannot deselect the platform's
Disabled rulesFewer disabled is stricter — a model may re-enable what the platform switched off, and may not switch off what the platform kept
Blocked sitesMore is stricter — the two lists add up

The settings screen reflects this directly: options looser than the platform's are not offered, platform-required detectors render locked, and platform-required rules cannot be switched off.

Setting a platform value is different from enforcing it. An administrator must select minimum or locked for that field to restrict model changes. Unset values do not create a minimum. Review the inherited value, restrictions and approved exceptions shown in the interface.

Check frequency (every N characters, minimum delay) is not subject to the floor — checking more often is not safer, only more expensive, and the model owner pays.

Model-based guardrail stages add model usage; local rule detection does not call the judge. Review request records, historical prices and settlement for the actual cost. Model owners cannot relax minimum or locked settings without the applicable approval.

Where it is configured

Platform administrators set the platform-wide starting values under Admin panel → System models → Safety and evaluation → Tool guardrail (platform default): how it runs, what happens on a hit, and which detectors apply.

Open an agent's Guardrail rules tab, or Setup → Behaviour → Guardrail rules. The sidebar separates:

Sub-pageContents
Model guardrailThe judge model's half: the switch, input/output checking, topic policy, drafting a policy from a description (collapsed), plus the refusal message and what happens when the guardrail itself fails
Tool guardrailThe local rules' half: mode, action on a hit (set per detector kind), detectors, the 33 rules and custom entries
Blocked sitesDomains excluded from search and page fetching, editable within permissions
Sensitive-data routingA separate model-routing policy for sensitive data; distinct from content-scanning mode

The page summary shows the effective state. Open Request logs → Guardrail records to inspect hits; the advanced Operate → Guardrail records entry remains available. Platform policy determines whether a field is editable, inherited or locked.

For mode, action and detectors, following the platform default uses the inherited value shown in the interface. Later platform changes apply to fields still following that default.

Cost and limitations

Rule detection checks the enabled rules locally. AI review also calls the judge. Usage depends on the enabled stages and actual tool results, so review request usage when choosing a mode.

Both rules and model decisions can miss issues or flag benign content. A match does not prove that content is harmful, and no match does not prove it is safe. Review the original data, intended task and recorded action before changing rules or reporting a false positive.

Records

Hits are written to the guardrail intercept log with the detector category, the source tool, and the action taken. The record keeps the location and category of a hit, never its content — otherwise the log itself would become a place secrets accumulate. Clean checks are not recorded.

Platform defaults and model settings

Runtime applies platform delegation, each field's enforcement and approved exceptions before merging values the model may configure. Explicit model values override unrestricted fields; unset fields inherit. Minimum settings can only become stricter, and locked settings cannot be overridden.

A usable model-level judge is selected in preference to the platform judge; otherwise the available platform judge is used. The switch, mode and hit action are separate settings. A missing judge or unset field does not enable content scanning.

Fail-open and fail-closed

The runtime creates a judge job, a background worker evaluates it, and the runtime polls for up to approximately 15 seconds.

ModeBehavior
Fail-open (default)If the judge is unavailable, fails, or times out, content proceeds and an infrastructure-failure verdict is recorded
Fail-closedIf the judge is unavailable, fails, or times out, content is blocked

Fail-open reduces outages caused by judge failures but cannot guarantee policy enforcement during the failure. Fail-closed is more conservative, but judge failures directly affect availability.

API responses

When input is denied, the base model is not called. When output is denied, the configured refusal message replaces it. A non-streaming response can include guardrail_metadata; a blocked response also includes:

x-unieai-guardrail-blocked: true

An output decision can occur after streaming starts. Streaming clients must therefore handle guardrail_metadata SSE events instead of relying only on the HTTP header. Metadata can identify the stage, reason, categories, and refusal message.

Review Guardrail intercepts

Open Request logs → Guardrail records on the agent, or use the recent-hits link in Guardrail rules. The advanced Operate → Guardrail records entry reaches the same records. The page provides:

  • Checked, blocked, fail-open, and reported-misfire totals.
  • The most frequent policy category.
  • Decision stage, content preview, Request ID, rationale, categories, and job status.
  • A blocked-only filter.
  • Report misfire for legitimate content that was incorrectly blocked.

The content preview is not the complete prompt or answer. Use the Request ID to correlate an available request trace when deeper investigation is required. Reporting a misfire is an operational label; it does not edit the prompt or retroactively allow the original request.

A record distinguishes user input, model output, and tool or retrieved context. Data returned by kb_search is tool context, not the user's question.

OutcomeMeaning
AnnotatedContent was retained with a notice; it was not blocked
RedactedMatched values were replaced; other content may remain
BlockedContent was withheld or replaced with a refusal
DetectedCheck the actual action instead of treating a risk category as a block
Error allowed / error blockedEvaluation failed and the configured failure policy allowed or stopped processing; content did not receive a successful decision

Pre-production checklist

  1. Test allowed, prohibited, and boundary cases against both input and output rules.
  2. Confirm that refusal text does not expose judge prompts, internal policy, or sensitive data.
  3. Simulate an unavailable judge and verify the chosen fail-open or fail-closed behavior.
  4. Test both streaming and non-streaming API clients.
  5. After release, review blocks, fail-open events, and misfires before refining policy.