feat(sf): /sf memory search header reports rerank state too

After aa60821ec wired the rerank pass, the search header still said
"(embedding-ranked)" even when SF_LLM_GATEWAY_RERANK_MODEL was set
and the worker was online. The user couldn't tell whether they were
seeing cosine-only or rerank-enhanced results.

Now the header has three states:
- "(embedding+rerank-ranked)" — both env vars set
- "(embedding-ranked)" — only SF_LLM_GATEWAY_KEY set
- "(static rank — set SF_LLM_GATEWAY_KEY for embeddings)" — neither

Header-only diff. The rerank can still soft-degrade silently if the
worker is offline (caller throttles the warning to once/min) — header
reports the configured state, not the realized state.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
Mikael Hugo 2026-05-02 23:39:28 +02:00
parent 54f27bd02c
commit 5cc2522646

View file

@ -226,9 +226,14 @@ async function handleSearch(
return;
}
const usingEmbeddings = !!process.env.SF_LLM_GATEWAY_KEY;
const header = usingEmbeddings
? `Top ${memories.length} memories for "${truncate(query, 60)}" (embedding-ranked):`
: `Top ${memories.length} memories for "${truncate(query, 60)}" (static rank — set SF_LLM_GATEWAY_KEY for embeddings):`;
const usingRerank =
usingEmbeddings && !!process.env.SF_LLM_GATEWAY_RERANK_MODEL;
const rankLabel = usingRerank
? "embedding+rerank-ranked"
: usingEmbeddings
? "embedding-ranked"
: "static rank — set SF_LLM_GATEWAY_KEY for embeddings";
const header = `Top ${memories.length} memories for "${truncate(query, 60)}" (${rankLabel}):`;
const lines = [header];
for (const m of memories) {
lines.push(