- Most AI “guardrails” in production are cosmetic — they catch obvious failures but miss subtle ones that actually damage trust and cause real harm.
- Effective guardrails operate at four layers: input validation, retrieval filtering, output verification, and action gating. Skipping any layer creates exploitable gaps.
- Guardrails must be tested adversarially, monitored continuously, and updated as attack patterns evolve — they are not a deploy-and-forget feature.
Context
Every enterprise AI product claims to have guardrails. In practice, most have a system prompt that says “do not discuss topics outside your domain” and perhaps a toxicity filter on outputs. This is guardrails theater — it looks like safety without providing it. A moderately sophisticated user can bypass these controls in minutes, and the subtle failure modes (confident misinformation, data leakage across tenant boundaries, actions taken without proper authorisation) are not caught at all.
At Logicbric, we handle sensitive data across every product: tenant personal information in PMS, legal case details in WyseAgent, employee screening records in Yezda, financial data in Downstream ERP. Our guardrails are not decorative — they are load-bearing safety infrastructure. This playbook documents the patterns that actually work.
Input validation and sanitisation
The first layer of defence is ensuring that inputs to your AI system are valid, safe, and within scope. This goes far beyond content moderation. You need to validate that the user has permission to ask the question they are asking, that the query does not attempt prompt injection, and that any referenced entities are within the user’s access scope.
- Implement prompt injection detection using a classifier trained on known attack patterns
- Validate entity references against the user’s access control list before processing
- Sanitise inputs to remove embedded instructions, encoded payloads, and indirect injection attempts
- Rate-limit AI interactions per user to prevent automated probing
- Log all rejected inputs for analysis — attack patterns evolve and your detection must evolve with them
Retrieval-level access control
In multi-tenant systems, RAG creates a data leakage risk that most teams underestimate. If your vector store contains documents from multiple tenants and your retrieval does not enforce tenant isolation, a carefully crafted query might surface documents the user should not see. We enforce tenant isolation at the retrieval layer using metadata filters that are applied before similarity search, not after — ensuring that cross-tenant data never enters the model’s context.
- Apply tenant and role-based access filters at the vector store query level, not post-retrieval
- Verify that retrieved documents belong to the querying user’s authorised scope
- Implement document-level access controls that propagate from your source systems to your vector store
- Test cross-tenant data isolation with automated red-team queries
- Audit retrieval results regularly to detect any access control drift
Output verification and grounding
Every AI output should be verified before it reaches the user. This means checking that factual claims are grounded in retrieved sources, that numerical outputs fall within plausible ranges, that the response does not contain information from outside the user’s access scope, and that the format and tone comply with your product’s standards. We use a lightweight verification model that scores outputs on grounding, relevance, and safety before delivery.
- Implement citation checking — every factual claim should reference a source document
- Add range validation for numerical outputs using domain-specific plausibility checks
- Scan outputs for PII or sensitive data that should not be disclosed
- Check for hallucinated entity names, dates, and figures against your ground truth data
- Implement a confidence score and surface low-confidence responses with appropriate caveats
Action gating and audit trails
For agentic systems that take actions (creating records, sending emails, modifying data), the guardrail layer must include explicit action gating. Every action the agent proposes should be validated against the user’s permissions, the action’s reversibility, and the potential impact. High-impact or irreversible actions should require explicit human approval. Every action — approved, rejected, or auto-executed — must be logged in an immutable audit trail.
- Classify actions by impact level: read-only, low-impact write, high-impact write, irreversible
- Require human approval for any action above your organisation’s risk threshold
- Log every proposed action, its context, the decision (auto/approved/rejected), and the outcome
- Implement action rollback for reversible operations
- Generate audit reports that compliance teams can review for regulatory purposes
Continuous adversarial testing
Guardrails degrade over time. New attack patterns emerge. Model updates change behaviour. Data distributions shift. Your guardrails must be continuously tested using adversarial inputs that attempt to bypass each layer. We run automated red-team evaluations weekly and manual red-team sessions monthly, updating our detection and prevention rules based on the results.
- Build an adversarial test suite covering known prompt injection techniques
- Test cross-tenant data access attempts monthly
- Attempt to extract system prompts and internal instructions
- Test for jailbreaking across all supported languages and encodings
- Update guardrails within 48 hours of discovering a new bypass technique