fix: silence Ollama memory doctor key warning

This commit is contained in:
Peter Steinberger
2026-04-27 02:02:52 +01:00
parent 1316ca9aa8
commit c6617c3155
2 changed files with 38 additions and 3 deletions

View File

@@ -394,6 +394,37 @@ describe("noteMemorySearchHealth", () => {
expect(note).not.toHaveBeenCalled();
});
it("does not warn for ollama when gateway probe is ready without CLI API key", async () => {
resolveMemorySearchConfig.mockReturnValue({
provider: "ollama",
local: {},
remote: {},
});
await noteMemorySearchHealth(cfg, {
gatewayMemoryProbe: { checked: true, ready: true },
});
expect(note).not.toHaveBeenCalled();
expect(resolveApiKeyForProvider).not.toHaveBeenCalled();
});
it("warns for ollama when gateway probe reports embeddings are not ready", async () => {
resolveMemorySearchConfig.mockReturnValue({
provider: "ollama",
local: {},
remote: {},
});
await noteMemorySearchHealth(cfg, {
gatewayMemoryProbe: { checked: true, ready: false, error: "connection refused" },
});
const message = String(note.mock.calls[0]?.[0] ?? "");
expect(message).toContain('provider "ollama" is configured');
expect(message).toContain("embeddings are not ready");
});
it("warns when lmstudio gateway probe reports embeddings are not ready", async () => {
resolveMemorySearchConfig.mockReturnValue({
provider: "lmstudio",

View File

@@ -128,6 +128,10 @@ function resolveSuggestedRemoteMemoryProvider(): string | undefined {
)?.providerId;
}
function isKeyOptionalMemoryProvider(providerId: string): boolean {
return providerId === "local" || providerId === "ollama" || providerId === "lmstudio";
}
async function resolveRuntimeMemoryAuditContext(
cfg: OpenClawConfig,
): Promise<RuntimeMemoryAuditContext | null> {
@@ -402,7 +406,7 @@ export async function noteMemorySearchHealth(
);
return;
}
if (resolved.provider === "lmstudio") {
if (isKeyOptionalMemoryProvider(resolved.provider)) {
if (opts?.gatewayMemoryProbe?.checked && opts.gatewayMemoryProbe.ready) {
return;
}
@@ -410,8 +414,8 @@ export async function noteMemorySearchHealth(
note(
[
gatewayProbeWarning
? 'Memory search provider "lmstudio" is configured, but the gateway reports embeddings are not ready.'
: 'Memory search provider "lmstudio" is configured, but the gateway could not confirm embeddings are ready.',
? `Memory search provider "${resolved.provider}" is configured, but the gateway reports embeddings are not ready.`
: `Memory search provider "${resolved.provider}" is configured, but the gateway could not confirm embeddings are ready.`,
gatewayProbeWarning,
`Verify: ${formatCliCommand("openclaw memory status --deep")}`,
]