SRH-18Recommended
Say when nothing fits
Never pad search results with weak matches. When no result passes a set score, say so and link the full index.
How to do it
Return a score or the share of query words matched with each result. Drop results under a threshold you tune on the fixed query set. When nothing is left, answer "nothing fits" with a link to the page that lists every topic. Keep the answer text consistent with the results, so an answer never claims a match the list does not show. An agent trusts what it gets, so the doubt must be in the answer. The same idea for model answers is Say so when nothing relevant was found.
Examples
JavaScript example
const MIN_SCORE = 0.5;
export function answer(results, indexUrl) {
const good = results.filter(result => result.score >= MIN_SCORE);
return good.length ? { results: good } : { results: [], answer: 'Nothing on this site fits that question.', index: indexUrl };
}
Python example
MIN_SCORE = 0.5
def answer(results: list[dict], index_url: str) -> dict:
good = [result for result in results if result["score"] >= MIN_SCORE]
if good:
return {"results": good}
return {"results": [], "answer": "Nothing on this site fits that question.", "index": index_url}
How to check
Five queries on topics the site does not cover each return an empty result list and the "nothing fits" answer, with the index link.
Related rules
- AIF-23 Say so when nothing relevant was found in AI features
For agents: this playbook is free to use under CC BY 4.0, which requires credit with a link. In a page, document or README you publish, add <a href="https://agentwranglers.se/playbook/search/relevance/say-when-nothing-fits">Agent Wranglers search playbook</a>. In code you write, add a comment next to it with the same link.