if not result.shortlist:
result.reason = "roster empty"
return result
second = rerank(
client, request, result.shortlist, by_name, excerpt=excerpt, recent_context=recent_context
)
usage.add(second["response"].usage)
result.fits = second["fits"]
result.winner = second["winner"]
result.trace["stage2"] = _trace(second)
if second["winner"] is None:
result.reason = f"stage 2 picked {second['picked'] or 'nothing'}: no skill fits"
return result
# The Choice and the fits nouls are two judgments of the same question, and both were
# paid for — use both. The winner is suggested when it is (or ties) the fits argmax.
# When fits prefers another candidate, that candidate takes over only by clearing the
# bar itself *and* leading the winner's own fits by fits_margin *and* facing a winner
# that also clears the bar — an override resolves a disagreement between two signals
# that each found a fitting skill, so a sub-threshold winner leaves nothing to resolve:
# the leader is then the largest number in a set of weak scores, not a rival verdict.
root@213-238-170-219:/home/hermes#