Sub topic 2
Permissions and Sharing in Retrieval
This chapter assumes you understand Salesforce objects, fields, user permissions, and sharing. You should also know that a prompt is the text sent to a large language model (LLM).
Permissions and Sharing in Retrieval
Agentforce retrieves Salesforce data before it creates a grounded prompt. Retrieval is the process of finding records and fields relevant to the user's request. The retrieval step uses the running user's access rights, including object permissions, field-level security, and sharing rules.
A user should receive only data that user could access directly in Salesforce. If a user cannot read a field or record, the Trust Layer should not add it to the prompt. This prevents the LLM from receiving information that the user was never allowed to see.
Permissions are not a replacement for good data design. An incorrect sharing rule or overly broad permission can still expose data.
Grounding Prompts in CRM Data
Grounding adds trusted, relevant CRM data to a prompt. For example, an agent answering “What is the status of this case?” can retrieve the case record, recent activity, and permitted knowledge articles. The model then uses that context instead of relying only on general training.
Dynamic grounding means the context is retrieved for the current request. It can change with the record, the user, and the user's permissions.
Masking Sensitive Data Before It Leaves Salesforce
Data masking replaces detected sensitive values with placeholders before the prompt leaves Salesforce. Personally identifiable information (PII), such as a person's email address, may become EMAIL_0. The LLM processes the placeholder rather than the original value.
After the response returns, demasking can restore the original value when appropriate. Masking reduces exposure, but it does not decide whether a user should access a record. Permissions and sharing must make that decision first.
> callout note > Masking protects values in transit to the model. It does not fix incorrect Salesforce permissions, inaccurate data, or an unsafe agent action.
Prompt Defense and System Policies
Prompt defense adds policies that help prevent misuse. It can reduce attempts to override the agent's instructions, reveal hidden prompts, or ignore safety rules. System policies define the agent's allowed behavior and its boundaries.
Prompt defense is different from masking. Masking protects sensitive values. Prompt defense protects the instructions and operating rules.
The LLM Gateway
The LLM gateway controls communication between Salesforce and the selected model provider. It applies the configured protections, sends the prepared prompt, and receives the response. Zero data retention policies can require the provider not to store the prompt or response for model training.
| Control | Primary purpose |
|---|---|
| Permissions | Limit which data is retrieved |
| Masking | Hide sensitive values from the model |
| Prompt defense | Protect instructions and policies |
| Gateway | Manage the model connection and provider boundary |
Exercise
A user asks for a record they cannot access, but the record contains no PII. Should grounding add it to the prompt?
Show answer
No. Permission checks apply to all protected CRM data, not only to sensitive values.