Sub topic 11
Improving grounding data and knowledge
This chapter assumes you can build a simple agent in Agentforce Builder, know what an LLM prompt and grounding are, and can read a conversation and its reasoning trace. It also assumes you have already classified a failure as a grounding problem. Here you fix the data the agent relies on.
What grounding means in an improvement loop
Grounding is the practice of giving the model trusted data to answer from, so it does not rely on general knowledge. In an Agentforce agent, grounding data comes from three places:
- Knowledge articles or documents that an action retrieves, often through a retriever or a knowledge action.
- Records and fields from Salesforce objects, returned by an action such as an order lookup.
- Text written into topic instructions, which is the weakest form of grounding because it is hard to keep current.
A grounding failure is different from a routing failure. The agent picked the right topic and the right action, but the answer was wrong, stale, vague, or invented. When you read the reasoning trace, the topic and action selection look correct. The problem shows up in what the action returned, or in what it failed to return.
Recognizing a grounding failure
Check these signals in the conversation and trace before you change anything.
| Symptom in the conversation | What to check in the trace or data | Likely cause |
|---|---|---|
| Answer contradicts current policy | Which article or record the action returned | Stale or duplicate content |
| Agent says "I don't have that information" when an article exists | Whether retrieval returned any result | Article not indexed, or poor match to the query |
| Agent gives a confident answer that appears nowhere in your content | Whether the action returned nothing, then the model answered anyway | Missing content plus no fallback instruction |
| Agent quotes the wrong product or region | Which article was ranked first | Overlapping articles, missing metadata |
| Agent reports a wrong status or date | Field values in the returned record | Bad or incomplete record data |
The third row is the most important. When retrieval returns nothing, a model may still produce a fluent answer from general knowledge. That is the behavior grounding is meant to prevent, so fix both the missing content and the instruction that lets the agent answer without evidence.
Diagnosing retrieval
Retrieval is the step that finds content for a question. Most grounding problems are retrieval problems, so test it directly.
- Take the user's exact utterance from the conversation.
- Run the same query against your knowledge source, using whatever retrieval testing tool your org provides.
- Look at the top results. Is the right article present? Is it first?
- If the right article is missing, check whether it is published, whether it is in the indexed data library, and whether the agent's user can access it.
- If it is present but ranked low, compare the article's wording with the customer's wording.
Customers rarely use your internal terms. If an article is titled "RMA initiation procedure" and customers write "send back my shoes," the match is weak. Rewrite the title and opening paragraph in the customer's language.
Fixing the content
Apply the fix that matches the cause you found.
Missing content
Count how many reviewed sessions hit the same gap. A topic that appears repeatedly in escalations with "no information" answers is a good candidate for a new article. Write it from the real questions in the conversations, not from an internal document structure.
Stale or conflicting content
Search for duplicates on the same subject. When two articles disagree, the agent may use either one. Retire the old article or merge them. Add a review date to articles that describe policy, and assign an owner so someone is responsible for it.
Hard-to-retrieve content
Articles work best when each covers one question and starts with the answer. Long documents that mix returns, shipping, and warranty produce chunks that match many queries poorly. Split them by question. Keep headings specific, such as "How long do refunds take for card payments," rather than "Refunds."
Bad record data
If the action returned a wrong value, the model did not cause the failure. Trace the field back to its source: a missing validation rule, an integration that did not sync, or a field that is blank for some record types. Fix it at the source. If some values are legitimately blank, tell the agent what to say, as shown below.
Access problems
Retrieval respects the permissions of the running user. An article that exists but is not visible to the agent's user behaves like a missing article. Confirm access before you write new content that duplicates it.
Telling the agent what to do without evidence
Even good content has gaps. Add an instruction that sets the behavior when grounding is missing. Keep it specific and testable.
BEFORE (instruction)
Answer questions about the return policy.
AFTER (instruction)
Answer questions about the return policy using only the content returned by the knowledge action. If the action returns no relevant content, say you could not find the policy and offer to connect the customer to a human agent. Do not state return windows, fees, or exceptions that were not in the returned content.This pairs with the escalation work from the previous chapter in this series. A clear fallback turns a wrong answer into a handoff, which is easier to review and cheaper to recover from.
Measuring whether grounding improved
Pick a signal that reflects the fix, not only overall resolution rate. Useful measures include:
- The share of sessions in the topic that end with a "no information" answer.
- Escalations in the topic that have a knowledge-gap reason.
- Negative feedback on answers from the topic.
- The rate at which reviewers mark answers as supported by the retrieved content, from a sample you review by hand.
The following script summarizes a reviewed sample so you can compare before and after. Field names are illustrative, not an Agentforce schema.
from collections import Counter
# Hypothetical reviewed sample. Field names are illustrative.
reviews = [
{"topic": "Returns", "retrieved": True, "supported": True},
{"topic": "Returns", "retrieved": False, "supported": False},
{"topic": "Returns", "retrieved": True, "supported": False},
{"topic": "Shipping", "retrieved": True, "supported": True},
]
no_content = Counter(r["topic"] for r in reviews if not r["retrieved"])
unsupported = Counter(r["topic"] for r in reviews if not r["supported"])
totals = Counter(r["topic"] for r in reviews)
for topic, n in totals.items():
print(
f"{topic}: {n} reviewed, "
f"{no_content[topic]} with no retrieval, "
f"{unsupported[topic]} unsupported"
)Here "Returns" has one session with no retrieval and two unsupported answers out of three. That points to content work in that topic before any instruction change.
Common mistakes
- Treating every wrong answer as a model problem. Check what the action returned first.
- Editing an article but not republishing or re-indexing it, so retrieval still serves the old version.
- Fixing one phrasing of a question. Test several paraphrases of the same utterance.
- Writing articles for internal staff. Use the customer's words.
- Leaving duplicate articles in place after adding a corrected one.
After each content fix, add a test case that captures the original failure, then run your regression set, as covered in the next chapter.
Test case: Return window answered only from policy content
User utterance: How long do I have to send back my shoes?
Expected topic: Returns
Expected action: Knowledge lookup for the return policy
Expected response: States the return window from the current policy article. If no article is returned, says it could not find the policy and offers a human agent.Exercise
A customer asks about the refund time for card payments. The trace shows the agent chose the Returns topic and ran the knowledge action, which returned no results. The agent still replied "Refunds take 3 to 5 days." An article on card refunds exists in the knowledge base. List the checks you would make and the two fixes you would apply.
Show answer
Checks: confirm the article is published and in the indexed data library, confirm the agent's running user can access it, run the customer's exact wording against retrieval, and compare the article title with the customer's wording. Fixes: (1) make the article retrievable, by fixing indexing or access and rewriting its title and opening in customer language, and (2) add an instruction to answer only from returned content and to offer a human agent when nothing is returned. Then add a regression test for the utterance.
Exercise
Two articles give different refund deadlines, and the agent sometimes cites each. Which fix addresses the cause, and why is editing the topic instruction the wrong fix?
Show answer
Retire or merge the outdated article so one source of truth remains, and assign an owner and review date. Editing the instruction would add a third copy of the fact that is not tied to the knowledge source, so it would go stale and the conflict would remain.