Sub topic 2
Where Agentforce Agents Send Prompts
This chapter assumes you know Salesforce objects, fields, and user permissions. It also assumes you know what a large language model (LLM) and a prompt are. You don't need to have built an agent. The goal is to locate the points where an Agentforce agent produces a prompt, so the later chapters on the Trust Layer have a concrete place to attach.
Why this matters for data protection
The previous chapter described the data risks of LLMs. Those risks only apply where data actually leaves your org. An agent is one of the main sources of such data. If you know when an agent builds a prompt and what goes into it, you can predict what the Trust Layer has to protect.
The building blocks of an agent
An Agentforce agent is made of a few parts. Each part affects what ends up in a prompt.
- Agent. The configured assistant. It has a role, instructions, and a channel where users reach it, such as a chat window in the Salesforce app or on a website.
- Topic. A category of work the agent can handle, for example "Order Support" or "Case Triage". A topic has a description, instructions, and a set of actions.
- Action. Something the agent can do. An action can run a Flow, call an Apex method, invoke a prompt template, or call an API.
- Reasoning engine. The component that reads the user's request, decides which topic fits, and picks the actions to run. It uses an LLM to make these decisions.
The reasoning engine does not work from the user's message alone. It receives the user's message, the agent's instructions, the descriptions of the topics, and the descriptions of the available actions. These are assembled into a prompt.
The places where a prompt is built
An agent turn can produce more than one LLM call. Each call has its own prompt. The common ones are below.
| Step | What the LLM is asked to do | What the prompt typically contains |
|---|---|---|
| Topic selection | Choose which topic fits the request | User message, conversation history, topic names and descriptions |
| Action selection | Choose which action to run within the topic | Topic instructions, action names and descriptions, input requirements |
| Action execution with a prompt template | Generate text from CRM data | A template with merge fields filled in from records |
| Response generation | Write the reply to the user | Instructions, results returned by actions, conversation history |
The exact steps and their order depend on the agent's design and on the release. Treat this table as a working model, not a specification.
The third row matters most for data protection. A prompt template is a reusable text with placeholders, called merge fields, such as the case subject or the account name. When the action runs, Salesforce replaces each merge field with a value from a record. That is where CRM data enters a prompt. The fourth row matters too, because action results are fed back into the prompt that writes the final reply.
What "grounding" means here
Grounding is the practice of adding trusted, specific data to a prompt so the LLM answers from facts and not from guesses. In Agentforce, grounding data comes from:
- Merge fields in prompt templates that read record fields.
- Results returned from Flows or Apex actions.
- Knowledge articles or other content retrieved for the request.
- Conversation history and context variables.
Later chapters cover grounding in detail. For now, keep one point in mind. Grounding is the step that turns a generic prompt into one that contains your customer data.
A worked example
Consider an agent with a topic called "Order Support". A support rep asks: "What happened with the order for Maria Lopez?"
The agent handles this in several steps:
- The reasoning engine builds a prompt with the rep's message and the topic descriptions. It asks the LLM which topic applies. The LLM chooses "Order Support".
- The engine builds a second prompt listing the topic's actions. It asks the LLM which action fits. The LLM chooses "Get Order Details".
- The action runs a Flow. The Flow queries the order record. This query runs in the context of the user, so the result depends on what that user can see.
- The result goes into a third prompt that asks the LLM to write a reply.
- The LLM returns text, and the agent shows it to the rep.
The prompts in steps 1 and 2 contain the rep's wording, which may include a customer name. The prompt in step 4 contains record data. All three prompts leave Salesforce for the model, so all three need protection.
Other places prompts originate
Agents are not the only source of prompts in Salesforce. Prompt Builder templates can be used outside an agent, for example to draft an email in a record page or to summarize a record. Developers can also call a prompt template from Apex or a Flow. These calls follow the same general path to the LLM, so the same protections are intended to apply. When you review an org, look at all of these entry points, not just the agents.
What this means for each kind of content
Not everything in a prompt is equally sensitive. A useful way to sort the content is by where it came from.
| Content | Source | Main concern |
|---|---|---|
| User message | Typed by the user | May include personal data the user chose to type, and may contain attempts to manipulate the agent |
| Instructions and descriptions | Written by the admin or developer | Should not contain secrets or customer data |
| Record values | CRM queries and merge fields | Personal data, access rights, accuracy |
| Action results | Flows, Apex, APIs | Whatever the action returns, which may be more than needed |
Two of these rows are your responsibility as the builder. Instructions are text you write, so do not paste credentials or real customer details into them. Action results are whatever your Flow or Apex returns, so return only the fields the task needs.
Common errors
- Assuming only the user's message is sent. The prompt also carries instructions, topic text, history, and action results.
- Assuming one LLM call per turn. A single turn can make several calls, each with its own content.
- Putting sensitive text in instructions. Topic and agent instructions are included in prompts. Treat them as visible to the model.
- Overly broad actions. A Flow that queries many fields or related records adds data that the LLM then sees.
- Forgetting non-agent entry points. Templates run from record pages or Apex also build prompts.
Where the Trust Layer fits
Each prompt in the example is a point where data moves from Salesforce toward a model provider. The Einstein Trust Layer is the set of controls applied around those calls. The next chapter defines it. Later chapters then follow a single prompt through retrieval, masking, the gateway, and back.
Exercise
A rep asks an agent about a customer's open case. List three separate LLM prompts the agent might send during this one turn, and say which one is most likely to contain record data from a Flow or merge field.
Show answer
Likely prompts are (1) topic selection, containing the user message and topic descriptions, (2) action selection, containing topic instructions and action descriptions, and (3) response generation, containing the action results. The response generation prompt, or a prompt template used inside an action, is most likely to contain record data, because it carries the values returned from the case record.
Exercise
A Flow used as an agent action returns every field on the Contact record. Why is that a data protection concern even if the user is allowed to see all those fields, and what should you change?
Show answer
The returned values become part of a prompt sent to the LLM. Fields the task does not need still leave Salesforce and increase exposure. Change the Flow so it returns only the fields the response requires.