fix(doctor): use gateway health status for memory search key check (#22327)

Merged via /review-pr -> /prepare-pr -> /merge-pr.

Prepared head SHA: 2f02ec9403
Co-authored-by: therk <901920+therk@users.noreply.github.com>
Co-authored-by: gumadeiras <5599352+gumadeiras@users.noreply.github.com>
Reviewed-by: @gumadeiras
This commit is contained in:
Ruslan Kharitonov
2026-02-23 14:07:16 -05:00
committed by GitHub
parent bf373eeb43
commit 8d69251475
11 changed files with 338 additions and 11 deletions

View File

@@ -43,7 +43,7 @@ describe("noteMemorySearchHealth", () => {
remote: { apiKey: "from-config" },
});
await noteMemorySearchHealth(cfg);
await noteMemorySearchHealth(cfg, {});
expect(note).not.toHaveBeenCalled();
expect(resolveApiKeyForProvider).not.toHaveBeenCalled();
@@ -53,9 +53,10 @@ describe("noteMemorySearchHealth", () => {
note.mockClear();
resolveDefaultAgentId.mockClear();
resolveAgentDir.mockClear();
resolveMemorySearchConfig.mockClear();
resolveApiKeyForProvider.mockClear();
resolveMemoryBackendConfig.mockClear();
resolveMemorySearchConfig.mockReset();
resolveApiKeyForProvider.mockReset();
resolveApiKeyForProvider.mockRejectedValue(new Error("missing key"));
resolveMemoryBackendConfig.mockReset();
resolveMemoryBackendConfig.mockReturnValue({ backend: "builtin", citations: "auto" });
});
@@ -70,7 +71,7 @@ describe("noteMemorySearchHealth", () => {
remote: {},
});
await noteMemorySearchHealth(cfg);
await noteMemorySearchHealth(cfg, {});
expect(note).not.toHaveBeenCalled();
});
@@ -95,7 +96,7 @@ describe("noteMemorySearchHealth", () => {
mode: "api-key",
});
await noteMemorySearchHealth(cfg);
await noteMemorySearchHealth(cfg, {});
expect(resolveApiKeyForProvider).toHaveBeenCalledWith({
provider: "google",
@@ -126,6 +127,42 @@ describe("noteMemorySearchHealth", () => {
});
expect(note).not.toHaveBeenCalled();
});
it("notes when gateway probe reports embeddings ready and CLI API key is missing", async () => {
resolveMemorySearchConfig.mockReturnValue({
provider: "gemini",
local: {},
remote: {},
});
await noteMemorySearchHealth(cfg, {
gatewayMemoryProbe: { checked: true, ready: true },
});
const message = note.mock.calls[0]?.[0] as string;
expect(message).toContain("reports memory embeddings are ready");
});
it("uses configure hint when gateway probe is unavailable and API key is missing", async () => {
resolveMemorySearchConfig.mockReturnValue({
provider: "gemini",
local: {},
remote: {},
});
await noteMemorySearchHealth(cfg, {
gatewayMemoryProbe: {
checked: true,
ready: false,
error: "gateway memory probe unavailable: timeout",
},
});
const message = note.mock.calls[0]?.[0] as string;
expect(message).toContain("Gateway memory probe for default agent is not ready");
expect(message).toContain("openclaw configure");
expect(message).not.toContain("auth add");
});
});
describe("detectLegacyWorkspaceDirs", () => {