From 5cc25226461f6f31e84d9c74614400aecc49aed3 Mon Sep 17 00:00:00 2001 From: Mikael Hugo Date: Sat, 2 May 2026 23:39:28 +0200 Subject: [PATCH] feat(sf): /sf memory search header reports rerank state too MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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) --- src/resources/extensions/sf/commands-memory.ts | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/resources/extensions/sf/commands-memory.ts b/src/resources/extensions/sf/commands-memory.ts index a54528b36..f2f08e89f 100644 --- a/src/resources/extensions/sf/commands-memory.ts +++ b/src/resources/extensions/sf/commands-memory.ts @@ -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(