Sub topic 13
Trust Layer and guardrails
This chapter assumes you know what topics, instructions, and actions are, and that you have a general idea of what a large language model (LLM) does. It explains the two mechanisms that limit what an agent can say and do: the Einstein Trust Layer and the guardrails you write yourself.
Two kinds of limits
An agent is constrained at two levels.
- The Einstein Trust Layer is a set of platform controls that sit between Salesforce and the LLM. You don't write it. It applies to the prompts the reasoning engine sends and the responses it gets back.
- Guardrails are limits you configure: topic scope, instructions, action design, and user permissions.
The Trust Layer protects data as it travels to and from the model. Your guardrails decide what the agent is allowed to attempt in the first place. You need both.
What the Trust Layer does
Each request to the model passes through a series of steps. The exact feature set depends on your org's configuration, so check current Salesforce documentation for details. The main steps are:
- Prompt assembly. The prompt is built from the conversation, the selected topic, its instructions, and any grounding data.
- Masking. Sensitive values, such as names or email addresses, can be replaced with placeholders before the prompt leaves Salesforce.
- Model call. The masked prompt goes to the LLM. Salesforce's agreements with model providers restrict how the provider may retain or train on this data.
- Unmasking and checks. The response comes back, placeholders are restored, and the response is screened for harmful or toxic content.
- Audit. Activity is recorded so you can review it later.
Guardrails you control
The Trust Layer does not know your business rules. These controls do.
| Guardrail | What it limits | Example |
|---|---|---|
| Topic scope | Which requests the agent will handle | Order Support does not process refunds |
| Instructions | How the agent behaves inside a topic | "If the order cannot be found, say so and do not guess" |
| Action set | What the agent can actually do | Only "Get Order Status" is available, so the agent cannot change an order |
| Permissions | What data an action can read or change | A `with sharing` Apex class respects record access for the running user |
The last row matters for custom code. The OrderStatusAction class from the topic spine is declared public with sharing, so its query respects sharing rules. Without that keyword, an action could return records the user should not see.
Common mistakes
- Treating instructions as security. Instructions steer the LLM, but the model can still misread them. Enforce hard rules in the action itself, in Flow or Apex, and in permissions.
- Over-broad actions. An action that can update any field is a larger risk than one that reads a status. Give each action the smallest job that works.
- Assuming masking covers everything. Masking detects known data patterns. Free-text fields can hold sensitive values that go unrecognized, so limit what you pass in as grounding data.
- Skipping review of the audit trail. Logs help only if someone checks them while testing and after deployment.
Checking your work
Use the testing tools covered later in this tutorial to confirm that out-of-scope requests are declined. Try a request your scope excludes, such as "refund my order" in Order Support, and confirm the agent does not call an action.
Exercise
An Order Support agent has only a read-only "Get Order Status" action, and a customer asks it to cancel an order. Which controls stop the cancellation, and why shouldn't you rely on the instruction "Do not cancel orders" alone?
Show answer
The scope excludes changes to orders, and the action set contains no action that can cancel, so the agent has no way to perform it. An instruction only steers the LLM, which can misinterpret it. The missing action and the permissions behind it enforce the limit regardless of what the model decides.
Exercise
What is the difference between what the Trust Layer protects and what guardrails protect?
Show answer
The Trust Layer protects data moving to and from the LLM, through masking, toxicity checks, and auditing. Guardrails limit what the agent attempts and can do, through topic scope, instructions, the available actions, and permissions.