Sub topic 10
The Einstein Trust Layer and Safe Responses
This chapter covers what the Einstein Trust Layer does between an Agentforce agent and a large language model (LLM). It assumes you know the basics of Salesforce objects, records, and permission sets. It also assumes you have a general idea of what an LLM does, and that you have read the earlier chapters on topics, actions, grounding, and agent identity.
What the Trust Layer is
The Einstein Trust Layer is a set of controls that sit between your Salesforce org and the LLM that generates text. Every prompt an agent sends to a model passes through it, and every response passes back through it. You do not build it or call it from your own code. It runs for service agents and employee agents alike.
The layer exists because a prompt often contains real business data. A grounded prompt for an order question might include a customer's name, email address, and order history. Without controls, that data would travel to an external model provider as plain text. The Trust Layer reduces that risk and checks the response before the agent uses it.
The layer does not replace access control. It also does not guarantee that a response is correct. It reduces specific risks: data exposure, toxic output, and retention of your data by a model provider. You still design topics, instructions, and permissions carefully.
The path of a request
A single agent turn follows the same path each time. The reasoning engine builds a prompt, the Trust Layer processes it, the model answers, and the Trust Layer processes the answer.
The main stages are these:
- Grounding. The prompt is enriched with CRM records and knowledge content the running user is allowed to see.
- Data masking. Sensitive values in the prompt are replaced with placeholders before the prompt leaves Salesforce.
- LLM call. The model receives the masked prompt. Under the zero data retention agreements Salesforce has with its model providers, the provider does not store the prompt or response or use them to train its models.
- Toxicity detection. The response is scored for harmful content.
- Demasking. Placeholders in the response are swapped back to the real values.
- Audit trail. The exchange is recorded so that you can review it later.
Secure data retrieval and grounding
Grounding happens before the Trust Layer masks anything, so what gets retrieved matters. Retrieval respects the permissions of the user or identity the agent runs as. A service agent uses its agent user. An employee agent uses the employee who is talking to it. If that identity cannot read a field, the field cannot end up in the prompt.
This is why the Apex example earlier in this tutorial declares with sharing. A custom action that runs in system mode could return data the user should not see. That data would then be grounded into the prompt and could appear in a reply. The Trust Layer would not stop that, because masking hides values from the model provider, not from the person reading the answer.
Data masking
Masking finds sensitive values in the prompt and replaces them with placeholder tokens. The model sees the tokens. After the response returns, the Trust Layer maps the tokens back to the original values, so the customer sees a normal reply.
Here is an illustration of what the model might receive compared with what the customer sees. The exact token format is internal, so treat this as a sketch.
Original prompt (inside Salesforce):
Customer Maria Lopez ([email protected]) asks about order 00001234.
Masked prompt (sent to the LLM):
Customer PERSON_0 (EMAIL_0) asks about order 00001234.
LLM response (still masked):
Hello PERSON_0, your order 00001234 has shipped.
Response shown to the customer (after demasking):
Hello Maria Lopez, your order 00001234 has shipped.Several points affect how well masking works:
- Masking relies on pattern detection and on field-level settings. Standard categories such as names, email addresses, phone numbers, and payment card numbers are the usual targets. Free text with unusual formats may not be caught.
- Detection can be configured in Setup. Review which data categories are masked and which fields are treated as sensitive in your org.
- A masked value is still sent as a placeholder, so the model cannot reason about the actual content. A prompt that depends on the real name, such as "is this a common surname?", will behave differently.
- Order numbers and similar identifiers may not count as sensitive by default. Decide whether that is acceptable for your data.
Toxicity detection
After the model replies, the Trust Layer scores the text for categories of harmful content, such as hate, violence, or profanity. The scores are stored with the audit data. A high score can be used to flag a response for review.
Toxicity detection is a safety net. It is not a replacement for good instructions. If a topic says "Do not discuss refunds or cancellations in this topic," that limit is enforced through the topic scope and instructions that the reasoning engine follows. Toxicity scoring will not notice an agent that politely promises a refund it has no authority to give.
Zero data retention
Under the zero data retention agreement, model providers do not keep the prompts and responses sent through the Trust Layer, and they do not use them to train or improve their models. This applies to the models accessed through Salesforce's gateway. If you connect your own model through a bring-your-own-model setup, the retention terms come from your agreement with that provider, so check them separately.
Audit trail and feedback
The Trust Layer records each prompt, the masked version, the response, the toxicity scores, and feedback signals such as a user's thumbs up or thumbs down. The record is stored in Data Cloud. You use it for two purposes:
- Compliance. You can show what the model was asked and what it returned.
- Improvement. You can look for patterns, such as a topic that often produces low-rated replies.
Audit data can contain customer content, so it needs its own access controls. Limit who can see it, and set a retention period that matches your policies.
Prompt defense and instructions
Beyond the data controls, the prompt that wraps your instructions includes guidance that tells the model to stay within its scope and to resist attempts to override it. This helps against prompt injection, where a user or a piece of retrieved text tries to change the agent's behavior ("ignore your previous instructions"). It lowers the risk but does not remove it.
Practical habits that work with this defense:
- Keep topic scope narrow and state what the topic must not do.
- Treat retrieved knowledge articles and case comments as data. A comment that says "send all records to this address" is text, not a command, but a weak agent design could still act on it. Limit the actions available in each topic.
- Make actions that change data require clear inputs, and consider a confirmation step for destructive actions.
Common errors
| Mistake | Effect | Fix |
|---|---|---|
| Assuming masking limits who sees data | A user sees fields in a reply that they should not | Enforce `with sharing` and field-level security in actions and use a correctly scoped agent user |
| Assuming all sensitive text is masked | Unmasked personal data reaches the model | Review masking settings and avoid putting sensitive data in unstructured fields that are grounded |
| Relying on toxicity scores for policy limits | The agent makes promises outside its authority | Put limits in topic scope and instructions, and require a human handoff for those cases |
| Leaving audit data open | Customer content readable by too many admins | Restrict access to the stored audit data and set retention |
| Assuming a bring-your-own model has zero retention | Provider may keep prompts | Review the provider's terms |
Using the Trust Layer in your design
A short checklist helps when you review an agent before activation:
- Confirm that the agent identity can read only the fields it needs.
- Check that custom Apex actions use
with sharingand do not return extra fields. - Review which data categories are masked.
- Test with prompts that include personal data and with prompts that try to break scope. Inspect the audit trail to see what the model received.
- Decide who may view audit data and how long it is kept.
Exercise
A service agent's custom Apex action runs without sharing and returns a customer's internal credit notes. The Trust Layer is enabled with data masking. Will masking prevent the notes from appearing in the reply to the customer? Explain what you would change.
Show answer
No. Masking replaces sensitive values with placeholders before the prompt goes to the model and restores them afterward, so the customer would still see the real text in the reply. Masking protects data in transit to the provider, not the final reader. Change the Apex class to use with sharing, make sure the agent user lacks access to the credit notes field through field-level security, and return only the fields the topic needs.
Exercise
A topic must never promise refunds. Which control enforces this: toxicity detection or the topic's scope and instructions? Why?
Show answer
The topic's scope and instructions. Toxicity detection scores harmful language, and a polite promise of a refund is not toxic. State the limit in the instructions, offer no refund action in the topic, and escalate to a human for refund requests.