Sub topic 6
Permissions and Sharing in Retrieval
This chapter assumes you know Salesforce objects, fields, profiles, permission sets, and sharing rules. It also assumes you have read the previous chapter on secure data retrieval. Here we look at how the user's access limits what data can reach a prompt.
The core rule: the running user decides
When an agent grounds a prompt, it retrieves CRM data. The retrieval runs with the access of the running user, the person whose session triggered the request. If that user cannot see a record or field in Salesforce, that data should not appear in the grounded prompt.
This matters because the LLM cannot enforce access rules. It sees only the text it is given. The check must happen before the text is built.
Some agents run as a dedicated service identity, not as the person chatting. In that case, the access of the configured agent user applies. Always confirm which user an agent runs as.
What gets checked
Retrieval respects the same layers of access you already manage:
| Layer | What it controls | Effect on a prompt |
|---|---|---|
| Object permissions | Whether the user can read an object | Records of that object are not retrieved |
| Field-level security | Which fields the user can see | Hidden fields are left out of the prompt |
| Sharing model | Which records the user can see | Records outside the user's sharing access are not retrieved |
A worked example
Two users ask an agent the same question: "Summarize account Acme."
- A sales rep has access to Acme and can see the
Annual_Revenue__cfield. The prompt includes revenue. - A support rep has access to Acme but field-level security hides
Annual_Revenue__c. The prompt leaves revenue out.
The same agent, topic, and question produce different prompts. The support rep's summary cannot mention revenue, because the model never received it.
Common errors
- Assuming the layer fixes broad access. If a profile gives a user "View All Data", the user's prompts can include everything that permission exposes. The Trust Layer follows your permissions. It does not correct them.
- Granting the agent user too much. A service-style agent user with wide access can surface data to people who could not see it themselves.
- Confusing masking with permissions. Masking hides sensitive values in data the user is allowed to see. Permissions decide whether the data is retrieved at all.
- Skipping tests. Testing only as an admin hides gaps. Test as users with different profiles and permission sets.
Checking your setup
- Identify the user the agent runs as.
- Review that user's profile, permission sets, and sharing access.
- Test the agent as several representative users and compare the results.
- Audit custom actions for sharing and field-level security handling.
Exercise
A support rep asks an agent about a case. The rep cannot see the Contact's Date_of_Birth__c field because of field-level security. Will the field value appear in the grounded prompt, and what should you check if it does?
Show answer
It should not appear, because retrieval respects field-level security for the running user. If it does appear, check whether the agent runs as a different user with broader access, and whether a custom action uses Apex that ignores sharing or field security.