Diagnose a weak retrieval result, choose a specific repair, and stop before retries turn into unsupported answer fishing.
Corrective retrieval: retry only when evidence is insufficient
Separate absence from weak ranking
Corrective retrieval is a controlled second search after a first result fails an evidence check. It is not a request to regenerate an answer until one sounds convincing. A missing exact case ID suggests indexing or filter trouble; a correct passage outside the reranker window suggests candidate-window trouble; a passage in context that does not support the claim suggests answer validation trouble. Stage traces reveal which repair has a chance to work.
Define a sufficiency test
For a question asking whether order OR-47 qualified for a refund on a stated date, require evidence for the order state, applicable policy revision and date condition. A high similarity score alone does not satisfy those slots. Use deterministic checks for exact IDs, active revisions and permission scope; use a judged support check where meaning cannot be reduced to a field match. Record the missing slot and the retrieved passage IDs before another search begins.
Pick one bounded repair
If vocabulary differs, run a constrained query expansion. If the required passage was cut before reranking, enlarge that stage's candidate window within its latency budget. If the corpus lacks the source, ask for clarification or abstain; searching unrelated collections is not a repair. Keep the original constraints on every attempt, including tenant, negation, identifier and date. Maximum attempts should be part of the application contract, not left to a model's willingness to continue.
Compare attempts against the same target
Log route, corpus generation, repair reason, new candidate IDs and sufficiency outcome per attempt. A retry counts as useful only if it introduces eligible support that the first attempt lacked. Repeated retrieval of the same passages is an exhaustion signal. If two eligible sources contradict one another, stop and present the conflict with dates; another paraphrase may merely hide it. Abstention remains an acceptable final result.
Evaluate repair yield
Build a set with first-pass successes, fixable vocabulary misses, candidate-window misses, truly missing evidence and contradictions. Measure recovered supported answers, extra retrieval calls, p95 latency and false-answer rate. A policy that retries every request can raise latency with no quality gain. The target is recovery on the fixable slice while keeping no-answer cases unanswered.
Worked contract
from dataclasses import dataclass
@dataclass(frozen=True)
class Attempt:
passage_ids: frozenset[str]
covered_slots: frozenset[str]
route: str
def decide_repair(attempts: list[Attempt], required_slots: frozenset[str],
max_attempts: int = 2) -> str:
latest = attempts[-1]
if required_slots <= latest.covered_slots:
return "answer with evidence"
if len(attempts) >= max_attempts:
return "abstain: budget exhausted"
if any(latest.passage_ids == prior.passage_ids for prior in attempts[:-1]):
return "abstain: repeated candidates"
if latest.route == "literal":
return "retry with constrained synonyms"
return "abstain: no justified repair"
needed = frozenset({"order", "policy", "date"})
first = Attempt(frozenset({"order-47-r2"}), frozenset({"order"}), "literal")
second = Attempt(frozenset({"order-47-r2", "policy-83-r4"}), needed, "synonym")
assert decide_repair([first], needed) == "retry with constrained synonyms"
assert decide_repair([first, second], needed) == "answer with evidence"
assert decide_repair([first, first], needed) == "abstain: budget exhausted"Performance and operating cost
The decision function scans prior attempts in O(AK) time in the worst case for A attempts and K passage IDs per attempt; the deliberately small attempt cap keeps that bounded. The real cost is another retrieval and possible rerank call, so track added p95 latency and recovered answers together. Slot coverage must be derived from verified evidence rather than a model's untested self-rating.
Common Mistakes
- Retrying because the answer sounded uncertain, without identifying a missing evidence slot.
- Dropping an exact identifier or authorization filter in a rewrite.
- Calling a second search successful when it returns the same unsupported passages.
- Continuing after two eligible sources contradict each other.
Validation drill
Label 55 requests by first-loss stage and whether a repair exists. Allow one corrective attempt; count supported recoveries, unchanged candidates and false answers separately.
