diff --git a/src/agent/subagents/graph-context.ts b/src/agent/subagents/graph-context.ts index d3cef03..c3a21ca 100644 --- a/src/agent/subagents/graph-context.ts +++ b/src/agent/subagents/graph-context.ts @@ -145,9 +145,11 @@ export async function runGraphContextJob(deps: GraphContextDeps, jobId: string): // BYOK (wave 6): fresh resolution per run; null = honestly off (the // dispatch gate already skips unconfigured sessions — this only fires // on a config change racing a respawn, and the error says exactly why). + // The resolver returns null for BOTH an unset model and a set model + // whose key vanished, so the message names both, never a false "null". const embedder = deps.embedder(); if (!embedder || embedder.model === null) { - return fail("no embedding model configured — injection skipped (graph.embeddingModel is null)"); + return fail("no embedding model available — injection skipped (graph.embeddingModel unset, or its provider key is missing)"); } const topic = topicOf(chat.messages); if (topic === null) return fail("no injectable topic (session past its start)"); diff --git a/tests/graph-context-job.test.ts b/tests/graph-context-job.test.ts index ec99a4e..a11857e 100644 --- a/tests/graph-context-job.test.ts +++ b/tests/graph-context-job.test.ts @@ -216,6 +216,21 @@ describe("runGraphContextJob — failure modes are honest errors, never phantom assert.match(got.error ?? "", /stale/); }); + it("BYOK: a null embedder (unset model or vanished key) fails honestly, never a phantom query", async () => { + const { id: chatId } = newTopicChat("injection unconfigured"); + const job = jobStore.createJob({ kind: "graph-context", chatId, toolCallId: `ctx_${chatId}` }); + trackJob(job.id); + // Wave 6: the resolver collapses BOTH unset-model and missing-key + // into null — the error must name the two honestly, never a false + // "graph.embeddingModel is null" for a key race. + const d = { ...deps(fakeGraphStore({ vectors: { n1: unit(0) } }), fakeEmbedder().embedder, async () => {}), embedder: () => null }; + await runGraphContextJob(d, job.id); + const got = jobStore.getJob(job.id)!; + assert.equal(got.status, "error"); + assert.match(got.error ?? "", /no embedding model available/); + assert.match(got.error ?? "", /unset, or its provider key is missing/); + }); + it("nothing fitting the budget errors rather than delivering an empty block", async () => { // Budget below the framing overhead: nothing can fit, ever. const { id: chatId } = newTopicChat("injection empty selection", { graphContextTokens: 10 });