Routing, Fallbacks, and Graceful Degradation › Abstention: Knowing When to Decline
Language AI HandbookAll chapters Abstention is a deliberate outcome for a request the service could not answer under its current policy. That is different from an unclassified exception. The caller receives a response with an outcome, suitable for offering search or a human handoff in a real product. Keep the reason visible to the operator, because a high abstention rate can reflect an outage, a stricter verification rule, or straightforward gaps in content.
For the benchmark, choose returns no tier exactly when every score is below the threshold. We can replay the fixed large-tier answer on those cases to get a diagnostic. Its denominator is the set of abstentions. A zero denominator means that there were no abstentions to analyze.
PythonIn [21]Expand
withheld = tuple(row for row in rows if choose(row, (0, 1, 2), 0.65)[0] is None)
if withheld:
alternative_correct = sum(row[2].correct for row in withheld)
print(
f"Large tier correct on withheld cases: {alternative_correct}/{len(withheld)}"
)
else:
print("No withheld cases")ConsoleOut [21]Expand
Large tier correct on withheld cases: 43/78
Separating availability and acceptance in a trace
The benchmark code has one ordered tuple for candidates and a single predicate for acceptance. The service example uses a different record at the boundary. Each option has two flags the orchestrator knows before a candidate arrives. The request can be parked until one option becomes available, or it can move immediately to the backup, depending on the deadline. In this notebook, the policy moves on immediately when it sees a false availability flag. It keeps a counter of attempted options, which means an unavailable tier skipped before execution has a different effect on the counter from an attempted tier whose call timed out.
For diagnosis, give those cases different names. “Rejected answer” implies that the router had a candidate to evaluate. “Unavailable provider” identifies a dependency that did not offer a candidate at all. If logging both as one generic “fallback” event, a dashboard might show worse traffic to the backup without giving you enough information to decide whether the acceptance threshold changed behavior or the primary lost capacity. To isolate a schoolbook example, vary a flag while keeping the candidate and threshold fixed.
Consider another pair of fixture inputs. An eligible small provider returns a low score. An available but unapproved provider returns a higher one. The execution should consume an attempt for the low-score candidate and skip the unapproved provider without using up the remaining budget. If there is an approved excerpt, returning it advertises its limited scope. If the caller supplies none, the same gate failure leaves the router without an allowed answer.
PythonIn [22]Expand
low_score = Option("Eligible, low score", True, True, ("Unverified", 0.41))
for allowed_excerpt in (excerpt, None):
outcome = serve(
(low_score, unapproved), safe_excerpt=allowed_excerpt, max_attempts=2
)
assert outcome.attempted == ("Eligible, low score",)
assert outcome.tier is None
print(outcome.outcome.value, outcome.text.splitlines()[0])ConsoleOut [22]Expand
partial Public policy excerpt only. Summary unavailable. abstain I couldn't verify an answer.
In production, the caller should give that fallback a provenance boundary too. For example, a catalog service that retains a read-only copy of the storewide return policy may expose its source and freshness when it uses an excerpt. A policy document about consumer returns may be inappropriate for a managed business account. More coverage would then be a misleading success metric, even if the fallback always returns text. A label tells readers what returned, and the eligibility check determines when that path is appropriate in the first place.
A threshold chosen on a single success rate can hide a distribution problem. On a workload dominated by frequently asked questions, an inexpensive route may pass enough easy examples to make its average look strong. Look at structured order queries and requests missing key details on their own as well. A useful evaluation records when each route was both permitted and available, so reviewers can distinguish an improvement in candidate correctness from a change to the policy that filters requests before attempts.
Comments
Add to the conversation
A question, a correction, or an example from your own work.
No comments yet. Be the first to share your thoughts!