Every Agentforce action runs as a Salesforce user. The model decides which action to call, but the running user decides what that action can read and change. When an agent is tricked by text in a record, or simply misreads a request, the running user's access is the limit on the damage.
That makes the agent user the most important permission decision in an Agentforce rollout, and one that tends to drift: someone adds a permission set to fix a failing action in a demo, and it never comes off. This post covers who the agent runs as, what a new agent user starts with, how to audit it with SOQL, and how to keep it small.
Two kinds of running user
Salesforce documents two execution contexts, and the difference decides where your review effort goes.
| Agent type | Runs as | Access ceiling |
|---|---|---|
| Employee agent (inside Salesforce, logged-in channels) | The signed-in user | That user's profile, permission sets, role and sharing |
| Service agent (web chat, messaging, channels not restricted to logged-in users) | A dedicated agent user | The agent user's access, for every person who talks to it |
For employee agents, Salesforce's access guidance is that the agent works under the logged-in user's context. The risk there is mostly in actions that escape that context: Apex declared without sharing, or flows running in system context.
For service agents, one user stands behind every conversation. Whatever that user can see, any customer who talks to the agent can try to get the agent to repeat.
What a new agent user starts with
When you configure service agent access, Salesforce suggests the Einstein Agent user license and the Einstein Agent User profile. The agent user is created with minimal access, Salesforce recommends expanding it gradually, and only admins can view or edit agent users. Extra access usually goes into the agent's own permission set, typically named after the agent.
The Salesforce CLI command sf org create agent-user shows the baseline explicitly. It assigns the Einstein Agent User profile and three permission sets, AgentforceServiceAgentBase, AgentforceServiceAgentUser and EinsteinGPTPromptTemplateUser. The user has no password, and in Agent Script the agent names it with default_agent_user in the config block.
So the starting point is small. The problem is everything added afterwards.
Audit the agent users you have
Start with the users:
SELECT Id, Username, IsActive, CreatedDate, LastModifiedBy.Name
FROM User
WHERE Profile.Name = 'Einstein Agent User'Then everything assigned to them, flagging the org-wide grants:
SELECT Assignee.Username, PermissionSet.Name, PermissionSet.IsOwnedByProfile,
PermissionSetGroup.DeveloperName,
PermissionSet.PermissionsModifyAllData, PermissionSet.PermissionsViewAllData,
PermissionSet.PermissionsAuthorApex, PermissionSet.PermissionsApiEnabled
FROM PermissionSetAssignment
WHERE Assignee.Profile.Name = 'Einstein Agent User'Then the object access those assignments add up to:
SELECT Parent.Name, SobjectType, PermissionsRead, PermissionsCreate, PermissionsEdit,
PermissionsDelete, PermissionsViewAllRecords, PermissionsModifyAllRecords
FROM ObjectPermissions
WHERE ParentId IN (SELECT PermissionSetId FROM PermissionSetAssignment
WHERE AssigneeId = '005XXXXXXXXXXXXXXX')
ORDER BY SobjectTypeRead the result against the agent's actions. Each object should be there because a named action needs it, at the lowest level that action needs. View All Records, Modify All Records, View All Data and Modify All Data on an agent user are almost never justified: they override sharing, so the agent can reach every record of that object whatever the customer is entitled to.
If you run more than one service agent, give each its own agent user. A shared user means the agent with the widest job sets the access for all of them.
Build the permission set from the actions
The reliable way to size the agent user is to work backwards from the action list:
- List every action the agent can call, including standard actions you enabled.
- For each, write down the objects and fields it reads and writes, and whether it needs one record or many.
- Grant exactly that in one agent-specific permission set, with field permissions rather than object-wide edit where the action only touches two fields.
- Remove the permission sets and groups that were added while testing.
- Test every action as the agent user in a sandbox, and treat a failure as a missing grant to add deliberately, not a reason to add a broad set.
The action code still has to scope records
Least privilege on the agent user bounds the damage. It does not separate one customer from another, because every customer shares the same running user. That job belongs to the action.
public with sharing class GetOrderStatus {
public class Request {
@InvocableVariable(required=true) public String orderNumber;
@InvocableVariable(required=true) public Id verifiedContactId;
}
@InvocableMethod(label='Get order status')
public static List<String> run(List<Request> requests) {
List<String> out = new List<String>();
for (Request r : requests) {
List<Order> rows = [
SELECT Status FROM Order
WHERE OrderNumber = :r.orderNumber
AND BillToContactId = :r.verifiedContactId
WITH USER_MODE LIMIT 1
];
out.add(rows.isEmpty() ? 'Order not found' : rows[0].Status);
}
return out;
}
}Three things carry the weight: with sharing and WITH USER_MODE keep the query inside the agent user's access, the filter on the verified contact keeps it inside one customer's records, and the action returns one field rather than the whole record. The model can repeat anything an action returns.
Note the platform change in Summer '26: Apex compiled at API version 67.0 or later enforces sharing by default and runs database operations in user mode by default. Older action classes keep the old behaviour, so a mixed codebase needs the explicit keywords until every class is upgraded.
Keep it from drifting
- Watch Setup Audit Trail for permission set assignments to agent users and for changes to their permission sets.
- Give every agent a named, active human owner who reviews its running user each quarter.
- Re-run the three queries above after every agent release, and diff the output.
- Do not treat topic instructions as access control. "Only discuss the customer's own orders" is guidance to a model. The query filter is the control.
Where Vulkro for Salesforce fits
On a live org, vulkro-sf org governance -t prod reads each agent's running user from its Bot metadata and reports SF-AI-AGENT-002 when that user holds Modify All Data or View All Data, and SF-AI-AGENT-001 when nobody active owns the agent. vulkro-sf org effective-perms -t prod lists View All and Modify All grants per permission set with their active holders, and vulkro-sf org least-privilege -t prod suggests a smaller permission set for review. Nothing is changed in the org.
In source, vulkro-sf scan follows each agent action to its Apex and flags agentforce-action-without-sharing-class, agentforce-agent-reachable-overprivileged, sf-agent-guard-god-permission, sf-agent-fls-query-no-fls and sf-agent-isv-private-action-unverified (a service agent action that never scopes to the verified customer).
FAQ
Does an employee agent need its own agent user?
No. Employee agents run as the signed-in user. Review the actions instead: anything without sharing or in system context gives the agent more than the user has.
Can the agent user be the same as our integration user?
It should not be. Integration users usually hold broad API access for back-office jobs, and an agent user's access is exposed to everyone who talks to the agent. Keep them separate and small.
Is the Einstein Agent User profile enough on its own?
It is the minimal starting point. Most agents need an agent-specific permission set on top, sized to their actions. The risk is extra sets added later, so audit what is assigned, not just the profile.
See the agent guardrail checks and the Salesforce platform teams use case, or start a 14-day trial. Related: Web-to-Lead and Web-to-Case as prompt-injection channels and Salesforce integration users and least privilege.