Engineering

Guardrails that work

Why a sentence in the system prompt is not a guardrail, and the four enforcement points that hold when someone tries to bypass them.

16 May 20266 min readKrip Artificial Intelligence Tech

A sentence in the system prompt is a preference, not a control. Models follow instructions most of the time, and the times they do not are the times that matter. Controls that hold under pressure sit outside the model.

Four enforcement points

  • Input filtering: reject or strip content that should never reach the model
  • Retrieval permissions: check entitlement before a passage enters the context
  • Output validation: schema, ranges, required citations, refusal patterns
  • Action gating: a separate service decides whether the action proceeds

Why outside beats inside

Prompt injection works because the model cannot reliably separate instructions from content. If a retrieved document contains "ignore previous instructions", an in-prompt guardrail is asking the model to police itself. Validation outside the model never reads the text for meaning in the first place.

  • Validate structure, not meaning, where possible
  • Require a citation for any factual claim and reject the output if it is absent
  • Deny by default on actions, allow by explicit rule
  • Log the rejected outputs; they are your best test set

The retrieval check most teams skip

Carry each document's access list as metadata on every chunk, filter at query time against the person asking, and test with a user who should not see the file. If the filter runs after the passage has entered the prompt, the model has already read it and no instruction afterwards takes that back. That single check does more for confidentiality than any amount of prompt wording.

Test the guardrails, not just the model

The evaluation set should include attempts to bypass: a document with embedded instructions, a question outside scope, a request for a prohibited action. If none of those are in the set, the controls are decorative, and the first person to try will find out for you.

A guardrail you can test

A guardrail is real only if you can write a test that fails when it is removed. "The system should not discuss competitors" is a hope. "Any response containing a competitor name is rejected before display" is a control with a test attached.

Put that test in the evaluation set. A set with no bypass attempts tests nothing, and the first person who tries will find out for you.

Where model-based guards fail

A second model checking the first helps, and it is still a model. Prompt injection works by making instructions look like content, and a checking model reads the same content. Use it as one layer, never the only one, and validate structure outside the model wherever the structure is knowable.

Citations are the strongest cheap control: if every factual claim must carry a passage identifier and the identifier must exist in the retrieved set, an invented claim fails validation without anyone judging meaning.

Evidence, not description

Ask to see the test cases behind the controls, not a description of them. A team with working guardrails has a list of rejected attempts, and the list will be longer than you expect.

Put a bypass attempt in the regression suite for every control you ship: an embedded instruction in a retrieved document, an out-of-scope question, a prohibited action. A control without a regression test is a comment.

Questions this answers

Can a second model act as a guard?
It helps, and it is another model that can be fooled. Use it as one layer, not the only one.
How do we test prompt injection?
Put instructions inside retrieved documents in your test set and check that the system ignores them.
Where this connects
KRIP Nexus
Approval gates and a ledger of tool calls.
Trust and responsibility
The commitments a guardrail implements.
AI ethics
The principles the controls answer to.

Written by the team at Krip Artificial Intelligence Tech. If something here is wrong, write to info@kripaitech.com.np and it will be corrected with the date noted.

Talk through your case
On this page
Working with KRIP

Engagements start with a written problem definition and an agreed error budget.

Engagement models