Skip to content

Spec 007: the answer cascade - #210

Merged
adamjohnwright merged 1 commit into
mainfrom
spec/answer-cascade
Sep 14, 2026
Merged

adamjohnwright merged 1 commit into
mainfrom
spec/answer-cascade

Conversation

@adamjohnwright

Copy link
Copy Markdown
Contributor

Analysis branch first, then embeddings → Reactome Search API → Tavily.

                    ┌─ analysis question? ──> MCP analysis agent
question ──> detect ┤
                    └─ otherwise ──> embeddings ──> Search API ──> Tavily
                                       (no match)     (0 entries)

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 you are asking for is one step inserted in the middle and one branch at the top.

step today
classify intent_classifier
embeddings the RAG chain
"good enough?" completeness_grader
Tavily tavily_wrapper
Search API nothing
analysis routing nothing

The order is easy; the signal is not

Search API — free and unambiguous. Measured: PALB2 → 39 entries, Impaired BRCA2 binding to PALB2 → 89, zzzznotathing0. 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_classifier should 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

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>
@adamjohnwright
adamjohnwright merged commit 294d486 into main Sep 14, 2026
10 checks passed
@adamjohnwright
adamjohnwright deleted the spec/answer-cascade branch September 14, 2026 17:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant