Sub topic 2
Agent types and who the agent runs as
This chapter assumes you know how profiles and permission sets grant access, and what object permissions, field-level security, and record sharing control. It also assumes you know what an Agentforce agent, a topic, and an action are.
Why the run-as identity matters
Every query an agent runs, every record it updates, and every field it reads is checked against one Salesforce user. That user is the agent's run-as context. Salesforce decides what the agent can see and change from that user's permissions, not from the agent's instructions. Instructions shape behavior, but permissions set the hard limit.
Agentforce agents use one of two run-as models:
- Dedicated agent user. The agent always runs as one fixed user that you choose when you configure it.
- Logged-in user. The agent runs as whoever is using it.
Which model applies depends on the agent type.
The two main agent types
| Agent type | Typical audience | Runs as | Who sets the access |
|---|---|---|---|
| Service agent | Customers and other external users | The dedicated agent user | You, through that user's permission sets |
| Employee agent | Your own staff inside Salesforce | The logged-in user | Each employee's existing profile and permission sets |
Agent type names and setup screens change between releases. Check the current Setup pages for the exact labels in your org.
Dedicated agent user
A service agent talks to people who usually have no Salesforce license. A customer on a web chat has no user record whose access could be used. So the agent needs an identity of its own. You assign it a user, and every customer who chats with the agent gets exactly that user's access.
This has two consequences:
- Every customer conversation has the same data access. The agent does not narrow it for each customer.
- Any narrowing, such as "only this customer's orders", must come from the action design and the queries behind it.
The next chapters cover how to create and restrict this user.
Logged-in user
An employee agent works for someone who already has a Salesforce user. The agent inherits that person's access. A sales rep's agent sees what the rep sees. An admin's agent sees what the admin sees.
This model needs little extra setup, but it has a limit. The agent can never do more than the person can, and it can do everything the person can. If an employee has broad edit rights, the agent has them too.
How the choice plays out
The same request gets different results under each model.
Request: "Show me the status of order 00001234."
Service agent (agent user has no access to Order):
The query returns nothing. The agent says it cannot find the order.
Employee agent (rep has read access to Order and owns the account):
The query returns the order. The agent reports the status.The diagram below shows where the access decision happens.
Other effects of the run-as user
The run-as user affects more than reads and writes.
- Ownership and audit. Records the agent creates or edits show the run-as user in fields such as Created By and Last Modified By. With a dedicated agent user, you can filter reports on that user to find everything the agent changed. With the logged-in model, agent changes look like the employee's own changes.
- Licensing. A dedicated agent user is a real user record with its own license and permission set assignments. You manage it like any other user.
- Failure behavior. Missing access normally does not raise a visible error to the end user. A query that respects permissions returns an empty result, and the agent may report that it found nothing. Keep this in mind when you test.
Choosing between them
Choose by audience. If the people using the agent have no Salesforce user, you need a dedicated agent user. If they are employees who already have users, the logged-in model keeps the agent inside the access you already manage.
Exercise
A customer-facing web chat agent can read order status. A support employee uses a separate internal agent that also reads order status. Which run-as user does each agent use, and why can the two give different answers for the same order?
Show answer
The customer-facing service agent runs as its dedicated agent user. The internal employee agent runs as the logged-in support employee. Each is checked against that user's object permissions, field-level security, and sharing, so an order visible to the employee may be invisible to the agent user, and the service agent returns an empty result.