feat(recall): structured per-stage scores and two-level min_scores filtering - #2422
Merged
Conversation
nicoloboschi
force-pushed
the
feat/recall-scores-min-scores
branch
from
June 26, 2026 13:48
82547ef to
093ae42
Compare
nicoloboschi
marked this pull request as ready for review
June 26, 2026 13:52
nicoloboschi
force-pushed
the
feat/recall-scores-min-scores
branch
from
June 26, 2026 14:29
093ae42 to
4ee9de6
Compare
…ltering Replace the recall result's single `score` with a `scores` object exposing the scores from each pipeline stage, and replace the `min_score` request param with `min_scores`, a per-stage filter that operates at two levels. Response — each result carries `scores`: - final : the value results are ranked by - reranker : cross-encoder normalized relevance (null for passthrough rerankers) - semantic : raw vector cosine similarity (null if not surfaced semantically) - text : raw keyword/BM25 score (null if not surfaced by keyword search) Per-arm semantic/text scores are aggregated across retrieval arms during RRF / interleave fusion (ArmScores on MergedCandidate), since fusion otherwise keeps only the first-seen arm's score per doc. Request — `min_scores` floors (inclusive, AND-ed, opt-in; default no filtering): - semantic / text : retrieval-level cutoffs pushed into the SQL arms, overriding the global similarity / BM25 minimums for the request (prune before fusion) - reranker / final: post-query filters on the scored results There is deliberately no default threshold: the cross-encoder's absolute scores are reliable for ordering but not calibrated across queries (a clearly-relevant match can score ~0.001 on one query and ~1.0 on another), so a fixed cutoff would silently drop good results. Also surfaces proof_norm in the search trace and reworks the control-plane trace view to render scores at full precision (no rounding) and show the per-stage `scores` breakdown; relabels the trace's "CE" column to "reranker score". Threaded through engine, HTTP, MCP (both recall tools), and the control-plane proxy; OpenAPI spec, Python/TS/Go/Rust clients, and the docs-skill mirror regenerated; docs updated.
nicoloboschi
force-pushed
the
feat/recall-scores-min-scores
branch
from
June 26, 2026 14:47
4ee9de6 to
6655561
Compare
nicoloboschi
pushed a commit
that referenced
this pull request
Jun 30, 2026
…SDK wrapper (#2446) #2422 added the public RecallRequest.min_scores (per-stage score floors) to the HTTP/MCP API and the generated clients, but the hand-maintained high-level Python wrapper (hindsight_client.recall/arecall) never got it, so high-level SDK users can't use the feature without dropping to the raw generated client. Thread an optional min_scores dict through recall()/arecall() into RecallRequest, mirroring the existing tag_groups dict->from_dict pattern. Unknown keys raise ValueError so a misspelled floor fails loud instead of silently applying no filter. Parity test mirrors tests/test_recall_prefer_observations.py. Follow-up to #2422.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Replaces recall's single
scorefield with a structuredscoresobject (one score per pipeline stage) and replaces themin_scorerequest param withmin_scores, a per-stage filter that operates at two levels of the pipeline.Response —
scoreson every resultfinalrerankersemantickeywordPer-arm
semantic/textscores are aggregated across retrieval arms during RRF / interleave fusion (ArmScoresonMergedCandidate) — fusion otherwise keeps only the first-seen arm's score per doc.Request —
min_scores(opt-in, inclusive, AND-ed; default = no filtering)semantickeywordrerankerfinal{ "query": "...", "min_scores": { "reranker": 0.5 } }Why
The recall pipeline computes several scores but only exposed the final one, and only via
trace. Exposing them lets callers inspect ranking and threshold on the stage they care about.There is deliberately no default threshold. The cross-encoder's absolute scores are reliable for ordering but not calibrated across queries — e.g. for query
software, the correctly-#1-ranked "Alice prefers Python over Java" scores~0.001, while a natural-question phrasing of the same intent scores~1.0. A fixed default cutoff would silently drop good results, somin_scoresis fully opt-in.Also in this PR
proof_normin the search trace so the scoring breakdown reconciles.0.001hid real differences) and shows the per-stagescoresbreakdown; relabels the trace's "CE" → "reranker score".Surfaces touched
Engine (
response_models,fusion,retrieval,reranking,tracer,types,memory_engine), HTTP (http.py), MCP (bothrecalltools), control-plane proxy (recall/route.ts,lib/api.ts,search-debug-view.tsx). OpenAPI + Python/TS/Go/Rust clients + docs-skill mirror regenerated;recall.mdx+mcp-server.mdupdated.Tests
tests/test_recall_min_score.py(9 tests):scorespresent, post-queryfinal/rerankerfloors, retrieval-levelsemanticfloor (SQL pruning), defaultNoneno-op. Fusion/scoring/trace suites pass (53). Lint +tyclean.Notes for review
score→scores.final,min_score→min_scores.final; retrieval-arm score fields aresemantic+keyword. The old fields were unreleased, so no compatibility shim.main— will rebase before marking ready.🤖 Draft generated with Claude Code.