Merge 960b567f53dce04b12d190ec10297083be333d1e into 598f1826d8b2bc969aace2c6459824737667218c

This commit is contained in:
AstroHan 2026-03-21 09:04:41 +05:30 committed by GitHub
commit 529f1a4443
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 68 additions and 0 deletions

View File

@ -290,6 +290,52 @@ describe("noteMemorySearchHealth", () => {
const providersChecked = providerCalls.map(([arg]) => arg.provider);
expect(providersChecked).toEqual(["openai", "google", "voyage", "mistral"]);
});
it("does not warn when ollama provider is set and gateway probe is ready", async () => {
resolveMemorySearchConfig.mockReturnValue({
provider: "ollama",
local: {},
remote: {},
});
await noteMemorySearchHealth(cfg, {
gatewayMemoryProbe: { checked: true, ready: true },
});
expect(note).not.toHaveBeenCalled();
});
it("shows informational note when ollama provider is set and gateway probe is not ready", async () => {
resolveMemorySearchConfig.mockReturnValue({
provider: "ollama",
local: {},
remote: {},
});
await noteMemorySearchHealth(cfg, {
gatewayMemoryProbe: { checked: true, ready: false, error: "connection refused" },
});
expect(note).toHaveBeenCalledTimes(1);
const message = String(note.mock.calls[0]?.[0] ?? "");
expect(message).toContain("ollama");
expect(message).toContain("does not require an API key");
expect(message).toContain("Gateway probe: connection refused");
expect(message).not.toContain("API key was not found");
expect(note.mock.calls[0]?.[1]).toBe("Memory search");
});
it("does not warn when ollama provider is set and no gateway probe is available", async () => {
resolveMemorySearchConfig.mockReturnValue({
provider: "ollama",
local: {},
remote: {},
});
await noteMemorySearchHealth(cfg);
expect(note).not.toHaveBeenCalled();
});
});
describe("detectLegacyWorkspaceDirs", () => {

View File

@ -79,6 +79,28 @@ export async function noteMemorySearchHealth(
);
return;
}
if (resolved.provider === "ollama") {
// Ollama runs locally and does not require an API key.
// Only warn when the gateway probe explicitly reports not-ready;
// if no probe ran we cannot tell whether the service is up, so
// stay silent (consistent with the "local" branch above).
if (opts?.gatewayMemoryProbe?.checked && !opts.gatewayMemoryProbe.ready) {
const detail = opts.gatewayMemoryProbe.error?.trim();
note(
[
'Memory search provider is set to "ollama".',
"Ollama does not require an API key, but the ollama service must be running.",
detail ? `Gateway probe: ${detail}` : null,
"",
`Verify: ${formatCliCommand("openclaw memory status --deep")}`,
]
.filter(Boolean)
.join("\n"),
"Memory search",
);
}
return;
}
// Remote provider — check for API key
if (hasRemoteApiKey || (await hasApiKeyForProvider(resolved.provider, cfg, agentDir))) {
return;