דלגו לתוכן

Actions Run Past Sharing Unless You Say So

תוכן זה אינו זמין עדיין בשפה שלך.

Module 4 of 6 in the chapter Beyond the Record: Agents, chapter 20 of Securing Salesforce: Sharing and Visibility. Each module stands on its own.

The question this module answers: An agent runs as a user, but it does its work through actions. When does an action read more than that user can see?

An agent doesn’t open records the way a person does. It does its work through actions: flows, Apex and prompt templates. Salesforce’s agent user page lists exactly those three: the agent user needs object permissions “for each object that the agent interacts with via flows, Apex, or prompt templates” (Configure Service Agent Access (opens in a new tab), Salesforce Help, checked 2026-11-26).

Salesforce also tells you to keep that list short: “You can (and should) limit an agent to only execute pre-defined, approved actions, such as specific Salesforce Flows, Apex classes, or API calls” (Agentforce Security and the Shared Responsibility Model (opens in a new tab), Salesforce Help knowledge article 005315874, published 2026-02-25, checked 2026-11-26).

Here’s why the list matters for sharing. Modules 1 to 3 set up the agent’s user. But an action is code, and chapter 17 taught you that code decides who sees what. Each action has a run context of its own. It can stay inside the agent user’s access, or it can read straight past it. The agent will repeat whatever the action hands back.

So every action is an entry point, and every entry point gets the same question: whose access does this read with?

For flows, Salesforce says it directly: “When an agent action runs a flow, both the flow’s run context and the agent’s execution context apply” (Agent Execution Context and Data Access by Type (opens in a new tab), Salesforce Help, checked 2026-11-26). Its table, on the same page:

The flow’s run contextObject and field accessRecords
UserThe running user’s permissions and field-level accessThe running user’s sharing
System context with sharingAll objects and fieldsThe running user’s sharing
System context without sharingAll objects and fieldsAll records

And a note to remember for service agents: when one runs as its agent user, “the running user of the flow is the agent user (EinsteinServiceAgent User), not the customer or end user” (same page). So a flow in user context limits the agent to the agent user’s access, which you designed in module 2. A flow in system context without sharing ignores it.

Chapter 17 module 6 covers the four run options in full. For agents, one stands out: User Context—Enforces User Permissions, new in Winter ‘27 at API version 68.0. A flow set that way “always runs with the running user’s access level, even if its caller runs in system context.” For a flow built as an agent action, start there. Elevate only the one step that needs it, in a subflow that returns an answer.

An Apex action is a class the agent calls, and two settings decide what it reads (chapter 17 modules 1 to 3):

  • The sharing keyword decides which records: with sharing, without sharing or inherited sharing. Give every class an agent calls an explicit keyword. Never leave it to the default (chapter 17 module 2).
  • The mode decides which objects and fields: user mode checks them, system mode doesn’t. Query in user mode unless you can write down why not (chapter 17 module 3).

If an action truly must see past the user, say to check whether any appointment is free across every region, make it a narrow elevation: the method looks with full access and returns an answer, yes or no, a count, a date. Never the records. An agent will happily put into words every record a without sharing method hands back.

A prompt template pulls Salesforce data into the prompt, which is called grounding. Salesforce says the Einstein Trust Layer does “secure data retrieval of Salesforce data for grounding the prompt based on the permissions of the user executing the prompt,” and that it “preserves in place all standard Salesforce role-based controls for user permissions and field-level security when merging grounding data from your CRM instance or Data 360” (Einstein Trust Layer (opens in a new tab), Salesforce Help, checked 2026-11-26).

That’s good news, and it has one limit. A template can also ground with a flow or Apex. Then that flow’s or class’s run context comes with it, so everything in the two sections above applies to the template too.

Put the three together, and the review question for every agent is short. Find the action that reads past its user.

The actionStays inside the user’s accessReads past it
FlowUser Context—Enforces User Permissions; user contextSystem context without sharing; system context with sharing for fields
Apexwith sharing, user modewithout sharing, system mode, no keyword
Prompt templateRecord merge fields, grounded as the userGrounding through a system-context flow or a without sharing class

Then keep an inventory: every action each agent can call, its run context, and, for every one that reads past its user, a sentence on why. It’s chapter 17 module 7’s system-mode inventory, with one more column: which agents call it.

Actions run past sharing unless you say so Actions run past sharing unless you say so. An agent's user calls three kinds of action. A flow: in User Context, Enforces User Permissions, it stays inside the user's access; in system context without sharing, it reads every record. Apex: with sharing and user mode, it stays inside; without sharing, system mode, or no keyword, it reads past the user. A prompt template: record merge fields ground as the user; grounding through a system-context flow or a without sharing class brings that context with it. Footnote: the agent repeats whatever the action hands back. {"author": "Steve Simpson", "blueprint": "1.0.0", "builder": "standard 1.59.0", "built": "2026-11-23", "id": "DGM-SVA-AG-05", "rights": "\u00a9 2026 Twinshark LLC. All rights reserved.", "template": "cells 0.5.0", "theme": "stevetecharc 1.5.0"} THE AGENT ITS ACTIONS WHAT EACH ONE READS The agent's user the person, or the agent user A flow user or system context Inside its user's access User Context, Enforces User Permissions Every record system context without sharing Apex a sharing keyword and a mode Inside its user's access with sharing, user mode Past its user without sharing, system mode, no keyword A prompt template grounds the prompt with data Inside its user's access record merge fields, as the user Whatever it calls a system-context flow, a without sharing class calls calls calls as the user past it as the user past it as the user brings its context The agent repeats whatever the action hands back. HOW TO READ IT stays inside the agent's user's access reads past the agent's user © 2026 Twinshark LLC · stevetecharc.com
Click to enlarge

Test knowledge. Know that Apex runs in system mode by default; that with sharing, without sharing and inherited sharing decide which records a class sees; that user mode enforces object permissions and field-level security; and that flows run in user context or system context, with or without sharing, depending on how they start and how they’re set. For agents, beyond the exam: an agent action’s run context decides what the agent can read, whoever the agent runs as. A likely area, not a known question.

  • The approved actions for each agent, and nothing else.
  • Each action’s run context: flows in User Context—Enforces User Permissions where they can be, Apex with an explicit keyword and user mode.
  • For every action that must read past its user, a narrow elevation that returns an answer, and a written reason.
  • How prompt templates ground: record merge fields as the user, and which flows or classes they call.
  • An inventory of every action, its context, and which agents call it, kept with the system-mode inventory.

Beyond the exam: what AI changes. Code always decided who sees what. What’s new is that an agent turns whatever code returns into a fluent answer, at once, to whoever asked. A leak that used to need a person to notice a field on a screen now arrives as a sentence.