Sub topic 16
Fixing poor or stale results
This chapter assumes you can already build the pipeline from earlier chapters: a published Knowledge article, a Data Cloud data stream, a search index, a retriever, and a prompt template or agent action that uses it. It also assumes you have tested a grounded answer and seen it fail. Here you will learn to find which stage broke and fix it.
Diagnose by stage, not by symptom
A bad answer rarely means the model is at fault. In a grounded setup the model only works with what retrieval hands it. Check the pipeline in order, from the source to the answer, and stop at the first stage that is wrong.
The order matters because each stage depends on the one before it. Changing instructions will not help if the article was never ingested.
Symptom guide
| Symptom | Likely stage | First thing to check |
|---|---|---|
| Answer is missing a fact that is in an article | Source or ingestion | Article is `Online` and the data stream has run since publishing |
| Answer quotes an old version | Ingestion or index | Last refresh time of the data stream and the index |
| Retriever returns nothing | Retriever | Filters that exclude everything, or an empty index |
| Retriever returns unrelated chunks | Index or retriever | Indexed fields, chunking, and result count |
| Right chunks returned, wrong answer | Prompt or agent | Whether the instructions restrict the model to the excerpts |
| Answer is right for one user and absent for another | Security | Sharing and permissions (see the next chapter) |
Stage 1: Confirm the source
Start in Salesforce. A draft or archived article is not a candidate for ingestion. The query below lists the English article versions that are currently published, with their publish dates.
SELECT Id, Title, UrlName, PublishStatus, Language, LastPublishedDate
FROM Knowledge__kav
WHERE PublishStatus = 'Online'
AND Language = 'en_US'
ORDER BY LastPublishedDate DESC
LIMIT 20Check three things in the result:
- The article you expect is listed, with
PublishStatusofOnline. LastPublishedDateis later than your edit. If it is not, the edit may still be in a draft version.Languagematches the language you are searching in. An article published only in another language will not match.
Also read the article text itself. Content hidden in an image, an attachment, or a field you did not index cannot be retrieved. Long articles that bury the answer under unrelated sections tend to produce chunks that are only loosely related to any single question. Splitting a broad article into focused ones often improves results more than any index setting.
Stage 2: Confirm freshness in Data Cloud
Stale answers almost always come from a gap between publishing and indexing. Two refreshes are involved, and each runs on its own schedule:
- The data stream that brings Knowledge records into Data Cloud.
- The search index that chunks and embeds the data from the mapped data model object.
If an article was published an hour ago but the data stream refreshes daily, the retriever still sees the old content. Open the data stream and check its last successful run and its status. Run it manually if you need the change now. Then open the search index and check that it processed the updated records.
Watch for these edge cases:
- Retracted or archived articles. Confirm that Data Cloud removes or marks them. If the old version stays in the data model object, it can still be retrieved. Check how your stream handles deletes.
- Multiple versions. If both an old and a new version of the same article are present, the retriever can return chunks from either. Look at the returned fields for a version or publish date.
- Failed runs. A stream that errors keeps serving the last good data. The answers look normal but go stale, so monitor run status instead of waiting for users to notice.
Stage 3: Check the index
If the data is fresh but retrieval is weak, look at how the index was built.
- Wrong fields indexed. The index only searches the fields you chose. If the answer lives in a body field and you indexed only the title, matches will be poor.
- Search type. Vector search finds meaning, so it handles paraphrases. Keyword search finds exact terms, so it handles product names, error codes, and SKUs. Hybrid search combines both. If users ask about exact identifiers and results are vague, hybrid search usually helps.
- Chunking. Chunks that are too large mix topics and dilute the match. Chunks that are too small lose context, so a chunk may say "it must be renewed within 30 days" without saying what "it" is. Adjust chunking and rebuild, then compare results on the same test questions.
- Changes need a rebuild. Changing the indexed fields or chunking settings generally means the index must reprocess the data. Do not assume the change applies to existing chunks until you see the index finish.
Stage 4: Check the retriever
Use the retriever's test view with the exact question that failed. Read the returned chunks directly, before looking at any model output.
- Nothing returned. A filter is usually the cause. A filter on language, channel, or a custom field removes every chunk if the values do not match the data exactly. Remove filters one at a time to find the culprit.
- Too much noise. A high result count passes many weak chunks to the model, and it may use the wrong one. Lower the count, tighten filters, or both.
- Too little context. A very low count can miss the one chunk that has the answer. Raise it gradually and re-test.
- Missing metadata. If the model must cite the article title or link, those fields must be in the retriever's returned fields. Otherwise they are not available to the prompt, and the model cannot cite them.
Change one setting at a time and re-run the same question. Changing several at once makes it impossible to know which one helped.
Stage 5: Check the prompt and agent
If the retriever returns the right chunks and the answer is still wrong, the problem is in how they are used.
First, confirm the retriever result actually reaches the prompt. In a prompt template, the retriever resource must be inserted where the model will read it. In an agent, the topic must use the knowledge action and not rely on the model alone.
Second, tighten the instructions. A grounding prompt should restrict the model to the excerpts and define a fallback:
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>For agents, the topic instruction does the same job:
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 a fallback rule, the model fills gaps from general knowledge. That is the failure grounding exists to prevent.
Keep a regression set
Fixes can break other answers. Keep a small list of real questions with the article each should come from. After any change to the data stream, index, retriever, or instructions, run the list again and compare. Include questions that should have no answer, so you can confirm the fallback still works.
Exercise
Users report that the agent still quotes a return policy that was updated yesterday. The article shows PublishStatus = 'Online' with yesterday's LastPublishedDate. The retriever test returns the old wording. Which stage do you check next, and what do you look for?
Show answer
Check Data Cloud freshness (Stage 2). The source is correct, so the gap is between publishing and indexing. Look at the data stream's last successful run and refresh it if it ran before the publish. Then confirm the search index processed the updated record. Also check whether the old version is still in the data model object and being returned alongside the new one.
Exercise
A retriever test returns zero chunks for a question that clearly matches an article. The index is current. What is the most likely cause, and how do you confirm it?
Show answer
A retriever filter is most likely excluding every chunk, for example a language or custom field value that does not match the data exactly. Remove the filters one at a time and re-run the same question. The filter whose removal brings results back is the cause.