Spec 007: the answer cascade - #210
Merged
Merged
Conversation
Analysis branch first, then embeddings, then the Reactome Search API, then Tavily. Half of it already exists. The completeness grader already decides whether an answer was good enough and already gates the Tavily call, so the skeleton -- retrieve, judge, fall back -- is real. What is being asked for is one step inserted in the middle and one branch at the top. The order is the easy part; the signal at each arrow is not. The Search API turns out to be the cheapest step in the cascade: measured, PALB2 returns 39 entries and a nonsense string returns 0, so the result count is the signal. No model call, no threshold, no judgement. The embeddings step is the hard one, and the specification is careful not to pretend otherwise. Similarity search has no empty result -- it always returns its k nearest documents, so "does not find a match" describes an intent rather than a mechanism. D1 is that choice: reuse the completeness grader, which already does this job for Tavily and judges the answer rather than a distance, or add a distance threshold that is free but arbitrary and drifts silently with the model and the release. Analysis detection is classification, and intent_classifier already classifies. It should gain the destination rather than acquire a sibling, which is #142's mistake. Measured rather than assumed: analysis through reactome-mcp is 0.2s for eight genes, so the two new steps are both cheap. Recorded as unverified: nobody knows how often a question would actually fall through to the Search API, and the Release 98 rebuild may change that number a lot. Worth measuring before building. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
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.
Analysis branch first, then embeddings → Reactome Search API → Tavily.
Half of it already exists
The
completeness_graderalready decides whether an answer was good enough and already gates the Tavily call. So the skeleton — retrieve, judge, fall back — is real. What you are asking for is one step inserted in the middle and one branch at the top.intent_classifiercompleteness_gradertavily_wrapperThe order is easy; the signal is not
Search API — free and unambiguous. Measured:
PALB2→ 39 entries,Impaired BRCA2 binding to PALB2→ 89,zzzznotathing→ 0. The result count is the signal. No model call, no threshold to tune. Cheapest step in the cascade.Embeddings — the genuinely hard one. This spec is careful not to pretend otherwise: similarity search has no empty result. It always returns its k nearest documents, so "does not find a match" describes an intent, not a mechanism. That is D1, and it is the only non-obvious decision here.
Analysis — a classifier, and there is one.
intent_classifiershould gain the destination rather than acquire a sibling, which is #142's mistake: a second classification call in a pipeline where cutting calls from 21 to one was the point of spec 001.Cost
Both new steps are cheap — the Search API well under a second, and analysis measured at 0.2s through
reactome-mcp(eight genes, 108 pathways).Recorded as unverified: nobody knows how often a question would actually fall through to the Search API. That number decides whether this cascade is worth building or whether the bundle is simply stale — and the Release 98 rebuild may change it a lot. Worth measuring before building.
🤖 Generated with Claude Code