Memory: handle SecretRef keys in doctor embeddings (#36835)

Merged via squash.

Prepared head SHA: c1a3d0caae
Co-authored-by: joshavant <830519+joshavant@users.noreply.github.com>
Co-authored-by: joshavant <830519+joshavant@users.noreply.github.com>
Reviewed-by: @joshavant
This commit is contained in:
Josh Avant
2026-03-05 20:05:59 -06:00
committed by GitHub
parent cec5535096
commit fb289b7a79
16 changed files with 212 additions and 11 deletions

View File

@@ -135,10 +135,40 @@ describe("noteMemorySearchHealth", () => {
await expectNoWarningWithConfiguredRemoteApiKey("openai");
});
it("treats SecretRef remote apiKey as configured for explicit provider", async () => {
resolveMemorySearchConfig.mockReturnValue({
provider: "openai",
local: {},
remote: {
apiKey: { source: "env", provider: "default", id: "OPENAI_API_KEY" },
},
});
await noteMemorySearchHealth(cfg, {});
expect(note).not.toHaveBeenCalled();
expect(resolveApiKeyForProvider).not.toHaveBeenCalled();
});
it("does not warn in auto mode when remote apiKey is configured", async () => {
await expectNoWarningWithConfiguredRemoteApiKey("auto");
});
it("treats SecretRef remote apiKey as configured in auto mode", async () => {
resolveMemorySearchConfig.mockReturnValue({
provider: "auto",
local: {},
remote: {
apiKey: { source: "env", provider: "default", id: "OPENAI_API_KEY" },
},
});
await noteMemorySearchHealth(cfg, {});
expect(note).not.toHaveBeenCalled();
expect(resolveApiKeyForProvider).not.toHaveBeenCalled();
});
it("resolves provider auth from the default agent directory", async () => {
resolveMemorySearchConfig.mockReturnValue({
provider: "gemini",

View File

@@ -6,6 +6,7 @@ import { formatCliCommand } from "../cli/command-format.js";
import type { OpenClawConfig } from "../config/config.js";
import { resolveMemoryBackendConfig } from "../memory/backend-config.js";
import { DEFAULT_LOCAL_MODEL } from "../memory/embeddings.js";
import { hasConfiguredMemorySecretInput } from "../memory/secret-input.js";
import { note } from "../terminal/note.js";
import { resolveUserPath } from "../utils.js";
@@ -26,7 +27,7 @@ export async function noteMemorySearchHealth(
const agentId = resolveDefaultAgentId(cfg);
const agentDir = resolveAgentDir(cfg, agentId);
const resolved = resolveMemorySearchConfig(cfg, agentId);
const hasRemoteApiKey = Boolean(resolved?.remote?.apiKey?.trim());
const hasRemoteApiKey = hasConfiguredMemorySecretInput(resolved?.remote?.apiKey);
if (!resolved) {
note("Memory search is explicitly disabled (enabled: false).", "Memory search");