Sub topic 2
Where grounding fits in an Agentforce agent
This chapter assumes you know basic Salesforce administration, what a large language model (LLM) is, and that an Agentforce agent is built from topics and actions. Here you will see where grounding plugs into that structure.
The pieces of an agent
An Agentforce agent has three parts that matter for grounding:
- Topics group related jobs, such as "Order questions" or "Product help". Each topic has a description and instructions that tell the agent when and how to act.
- Actions are the things the agent can do inside a topic. An action can run a flow, call Apex, invoke a prompt template, or look up knowledge.
- Instructions are plain-language rules inside a topic. They shape how the agent chooses actions and words its replies.
Grounding means giving the LLM your own content at the moment it answers. Retrieval supplies that content. The agent does not search on its own. Each topic needs an action that retrieves content, and instructions that tell the agent to use it.
Two ways to supply retrieved content
You can connect a retriever to an agent in two ways.
| Path | How it works | Use it when |
|---|---|---|
| Knowledge action backed by a Data Library | The agent calls a standard answer-questions-with-knowledge action. The library defines the search index and retriever. | You want the fastest setup for article search. |
| Prompt template with a retriever | A custom prompt template calls a retriever as a resource. An action invokes the template. | You need control over wording, fields, or filters. |
Both paths end the same way. Retrieved excerpts go into the prompt, and the LLM writes a reply from them.
What each layer controls
Problems with grounded answers usually trace to one layer, so it helps to know who owns what:
- Topic instructions decide whether the agent calls the knowledge action and how it behaves when nothing comes back.
- The action decides which retriever or library runs.
- The retriever decides which chunks, fields, and filters reach the prompt.
- The prompt text decides how strictly the model must stay within the excerpts.
Later chapters build each layer. For now, notice that the same fallback rule has to appear in two places: the topic instructions and the prompt template. A sample topic instruction looks like this:
When a customer asks a product or policy question, use the knowledge action to look up the answer.
Base your reply only on the returned articles.
If no relevant article is returned, do not guess. Tell the customer you do not have that information and offer escalation.Without the last line, an empty retrieval result leaves the model free to answer from general knowledge. That is the failure grounding exists to prevent.
Exercise
A topic has a working knowledge action, but when no article matches, the agent still gives a confident answer. Which layer should you check first, and what should you add?
Show answer
Check the topic instructions. Add a rule that tells the agent not to guess when no article is returned, and to say it lacks the information and offer escalation. Also confirm the prompt template, if one is used, has the same fallback rule.