Sub topic 1
Why agents need grounding
Prerequisites
This chapter assumes you have the following background:
- Basic Salesforce administration: objects, fields, and permission sets.
- Familiarity with Salesforce Knowledge articles and how they are published.
- A general idea of what a large language model (LLM) is.
- Awareness of Agentforce agents, topics, and actions.
You do not need to know Data Cloud yet. Later chapters introduce it as it becomes relevant.
What you will learn
By the end of this chapter you can explain why ungrounded LLM answers are risky, and how retrieval-augmented generation (RAG) reduces that risk. You can also name the parts of a grounded answer path, which the rest of the tutorial builds one piece at a time.
The problem with ungrounded answers
An LLM generates text by predicting likely next words. It learned those patterns from a large body of public text during training. It does not look up facts at answer time, and it knows nothing about your company's products, policies, or prices unless that information happened to be in its training data.
An answer that is not tied to a source is called an ungrounded answer. The model produces fluent text whether or not it has the facts. This leads to several common failure modes:
- Hallucination. The model states something that sounds right but is false, such as an invented return window or a feature your product does not have.
- Stale information. The model's training data has a cutoff date. A policy you changed last month is not in it.
- Generic answers. The model answers from general knowledge about an industry, not from your specific terms. The answer may be correct for another company and wrong for yours.
- No traceability. You cannot point to the source of a claim, so a reviewer cannot check it.
For a customer-facing agent, each of these has a cost. A wrong refund policy can create a commitment your company must honor or a complaint it must resolve. Fluent wording makes the error harder for a customer to spot.
What grounding means
Grounding is the practice of giving the model the relevant facts at request time and instructing it to answer from those facts. The facts come from sources you control, such as published Salesforce Knowledge articles, instead of from the model's memory.
Grounding does not retrain the model. The model is unchanged. What changes is the prompt: it now contains your content as context, and the instructions tell the model to rely on it.
Retrieval-augmented generation
Retrieval-augmented generation (RAG) is the most common way to ground an LLM on a large body of content. The name describes the order of work:
- Retrieve. Search your content for the passages most relevant to the user's question.
- Augment. Insert those passages into the prompt, next to the question and your instructions.
- Generate. The LLM writes the answer using the supplied passages.
Retrieval matters because you cannot place all of your Knowledge articles in every prompt. A prompt has a size limit, and extra irrelevant text lowers answer quality and raises cost. Retrieval selects a small number of relevant passages for each question.
A worked comparison
Suppose a customer asks: "Can I return a opened headset after 30 days?" Your published return policy says opened audio products can be returned within 14 days of delivery.
| Row | Ungrounded | Grounded |
|---|---|---|
| Prompt contains | Only the question | Question, instructions, and the return policy excerpt |
| Source of facts | Model's training data | Your published article |
| Likely answer | "Most retailers allow returns within 30 days." | "Opened audio products can be returned within 14 days of delivery, so a return after 30 days is not covered." |
| Can be checked | No | Yes, against the article title |
The ungrounded answer is plausible and wrong for your company. The grounded answer is correct because the policy text was in the prompt.
Grounding does not guarantee correctness
Grounding lowers risk. It does not remove it. Keep these limits in mind, because later chapters address each one:
- Retrieval can miss. If the right passage is not returned, the model has nothing to ground on. Content that is unpublished, not yet indexed, or split into poor chunks causes this.
- Retrieval can return the wrong passage. A passage that looks similar to the question but answers a different one can lead the model astray.
- The model can ignore the context. If the instructions do not forbid outside knowledge, the model may mix retrieved facts with its own. Clear instructions are part of grounding.
- The source can be wrong. A grounded agent faithfully repeats an outdated or incorrect article. Content quality is your responsibility.
- An empty result needs a plan. When nothing relevant is found, the agent should say so and escalate, not guess.
The pieces of the grounded path
The tutorial follows one path from your content to a grounded answer. This table maps each stage to the chapters where you build it.
| Stage | What happens | Where it is covered |
|---|---|---|
| Source content | Knowledge articles are written and published | Preparing Knowledge articles for retrieval |
| Ingestion | Article content is brought into Data Cloud | Bringing Knowledge content into Data Cloud |
| Indexing | Content is split into chunks and converted to vector embeddings in a search index | How content becomes searchable chunks and vectors; Creating a search index |
| Retrieval | A retriever searches the index and returns passages | Creating and testing a retriever |
| Augmentation | Results are inserted into a prompt template or used by an agent action | Grounding a prompt template; Letting an agent answer from knowledge |
| Instructions | Wording tells the model to rely only on retrieved content | Writing instructions that keep answers grounded |
| Verification | You test answers and fix problems | Testing grounded answers; Fixing poor or stale results |
Two terms appear here before their full explanation. A vector embedding is a list of numbers that represents the meaning of a piece of text, so that passages with similar meaning are close together. A chunk is a short section of a larger document. Searching over chunk embeddings lets a retriever find passages by meaning, not only by exact keywords. The chapter on chunks and vectors explains both.
Where this fits in Agentforce
An Agentforce agent works through topics, which group related jobs, and actions, which are the things the agent can do. Grounding enters in two places:
- Prompt templates. A prompt template can include the output of a retriever as a resource, so the prompt sent to the LLM carries your content.
- Agent actions. An agent can use a knowledge action that retrieves content when a topic calls for it, and topic instructions control how the reply uses the result.
Both routes rely on the same retrieval layer in Data Cloud. You build it once and reuse it.
The Einstein Trust Layer also sits on the request path between Salesforce and the LLM. It handles protections such as masking and auditing, and a later chapter explains how it interacts with grounded content.
A quick check of your own content
Before building anything, confirm what content exists to ground on. Only published article versions are candidates. This SOQL query lists the most recent online English versions of Knowledge articles:
SELECT Id, Title, UrlName, PublishStatus, Language, LastPublishedDate
FROM Knowledge__kav
WHERE PublishStatus = 'Online'
AND Language = 'en_US'
ORDER BY LastPublishedDate DESC
LIMIT 20Run it in Developer Console or Workbench. If the list is short, outdated, or missing topics customers ask about, grounding cannot fix that. Improve the content first. The object name Knowledge__kav is the default. Your org may use a different Knowledge object name if it was configured differently.
The shape of a grounding instruction
Retrieval supplies the facts. The instruction tells the model how to use them. Here is the general shape of a grounding prompt. The bracketed lines stand for content that a prompt template inserts at run time.
Answer the customer's question using only the knowledge article excerpts provided below.
If the excerpts do not contain the answer, say you could not find it and offer to connect the customer with a human agent.
Do not use outside knowledge. Mention the article title when you rely on an excerpt.
Excerpts:
<retriever results inserted here by the prompt template>
Question:
<customer question inserted here>Note the three parts: a restriction to the supplied excerpts, a defined fallback for the empty case, and a request to cite the source title. You build and refine this kind of prompt in later chapters.
Exercise
A customer asks your agent about a warranty term that changed last week. The agent answers with the old term. Name two different causes in the grounded path that could explain this, and say which stage each belongs to.
Show answer
Possible causes include (1) the updated article was not published or not yet ingested and indexed, which is a source content or ingestion/indexing problem, so the retriever only has the old text; and (2) the retriever returned the old article version or an older, similar article, which is a retrieval problem. A third cause is that the instructions let the model use its own knowledge instead of the retrieved text, which is an instruction problem. Any two of these, matched to their stage, is a correct answer.
Exercise
Why is it not enough to paste your retrieved passages into a prompt without telling the model to rely only on them?
Show answer
The model may still blend the passages with its own general knowledge, or answer even when the passages do not contain the answer. Grounding needs both the right context and instructions that restrict the answer to that context and define a fallback, such as escalating to a human, when nothing relevant is found.