Sub topic 12
Grounding Answers in Salesforce Data
This chapter assumes you know what topics, instructions, and actions are, and that you have a general idea of what a large language model (LLM) does. It explains how an agent uses Salesforce data so its answers rest on real records instead of guesses.
What grounding means
Grounding is the practice of giving the LLM the facts it needs as part of the prompt. An LLM has no knowledge of your orders, cases, or customers. If it is asked about them without any data, it may produce a fluent answer that is wrong.
A grounded agent works differently. It retrieves data first, then writes a response from what it retrieved. The model's job is to explain and phrase the result, not to supply the facts.
Where grounding data comes from
Grounding data enters the reasoning loop mostly through actions. Common sources are:
- Record lookups. A Flow or Apex action queries objects such as Order, Case, or Account and returns field values.
- Prompt templates. A template can merge record fields into the text sent to the LLM, so the model sees the current values.
- Knowledge and unstructured content. A retrieval action can search articles or documents and return the best matching passages.
- Conversation context. Values the customer already gave, such as an order number, are carried forward as variables.
The Get Order Status action from the Order Support topic is a typical example. The agent does not know the status of order 1042. The action queries the Order object and returns the status. The agent then uses that result in its reply.
Grounding through instructions
Topic instructions decide whether the agent grounds its answers at all. Compare these two lines from the Order Support topic:
- Use the order status action to look up the order before answering.
- If the order cannot be found, say so and do not guess.The first line forces a lookup before any answer. The second tells the agent what to do when grounding fails. Without it, the model may fill the gap with a plausible status. In the Apex action, the Not Found value is what makes the second instruction possible, because the agent has an explicit signal to react to.
Access rules still apply
Grounding data is only as complete as what the running user can see. The Apex example uses with sharing, so the query respects record sharing rules. A user who cannot see an order gets Not Found, and the agent reports that. This is intended behavior. It keeps grounding consistent with your existing security model.
Common errors
- Answering without a lookup. If no instruction requires an action call, the model may answer from general knowledge. Require the lookup in the instructions.
- No result for missing data. An action that returns nothing or throws an error gives the agent nothing to ground on. Return an explicit value such as
Not Found. - Vague output descriptions. The agent reads output descriptions to understand results. A description like "Status of the order, or Not Found" works better than "result".
- Stale or incomplete fields. The agent can only repeat what the data says. If a field is outdated, the answer will be too.
Exercise
A customer asks about an order, and the agent answers "It should arrive Friday" without calling any action. Which two changes to the topic would most directly make the answer grounded?
Show answer
Add an instruction that requires calling the order status action before answering, and add an instruction for what to say when the order is not found. Also make sure the action returns an explicit value such as Not Found when no record matches.