Sub topic 16
Fixing poor or stale results
This chapter assumes you have a Knowledge-backed search index, a retriever, and an agent or prompt template that uses it. It also assumes you can run test questions against them. When an answer is wrong, find the stage that failed before you change the prompt.
Work through the pipeline in order
A bad answer can come from any stage between the article and the reply. Check the stages in this order.
Symptom: the article is missing
Start at the source. Run the SOQL query below to confirm the article is online and in the right language.
SELECT Id, Title, UrlName, PublishStatus, Language, LastPublishedDate
FROM Knowledge__kav
WHERE PublishStatus = 'Online'
AND Language = 'en_US'
ORDER BY LastPublishedDate DESC
LIMIT 20If the article is absent, it is a draft, archived, or in another language. Fix that in Knowledge first. If it appears, check that the data stream for Knowledge has refreshed since the publish date. Then check that the search index has processed the new records.
Symptom: stale answers
Stale answers usually mean the pipeline has not caught up with a change. Common causes:
- The article was edited but the new version is not yet published.
- The data stream has not run since the edit.
- The search index has not been rebuilt or refreshed after ingestion.
- The agent is answering from an older cached test conversation.
Compare LastPublishedDate in Salesforce with the refresh times of the data stream and the index. The oldest of the three timestamps shows where the delay is.
Symptom: irrelevant results
If the retriever returns articles, but the wrong ones, test the retriever on its own with the customer's exact wording. Then look at these settings:
| Cause | What you see | Fix |
|---|---|---|
| Result count too low | The right article ranks just below the cutoff | Raise the number of results |
| Result count too high | Unrelated excerpts dilute the answer | Lower it |
| Filter too narrow | Nothing returns, or only one article | Loosen the filter |
| Filter too broad | Excerpts from other products or audiences | Add a filter on a field such as language or category |
| Chunks too small or too large | Excerpts lack context, or bury the answer | Adjust the chunking settings and rebuild the index |
| Vocabulary mismatch | Customers use terms the article does not | Use hybrid search, or add the customer's terms to the article |
Also check the returned fields. If the title or URL is not returned, the model cannot cite the article, and the answer may look ungrounded even when retrieval worked.
Symptom: the agent ignores good results
If the retriever test returns the right excerpt but the agent answers incorrectly, the problem is in the prompt or the action. Check that the template includes the retriever resource. Check also that the topic instructions send product questions to the knowledge action. Make sure the instructions say what to do when nothing is returned.
Exercise
A customer asks about a refund policy that was updated yesterday. The agent quotes the old policy. The retriever test returns the old article text. Name two places to check first.
Show answer
Check that the new version is published with a recent LastPublishedDate. Then check that the Knowledge data stream and the search index have refreshed since that publish. The retriever returns old text, so the index most likely still holds the old chunks.