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

@@ -221,6 +221,48 @@ describe("memory search config", () => {
});
});
it("preserves SecretRef remote apiKey when merging defaults with agent overrides", () => {
const cfg = asConfig({
agents: {
defaults: {
memorySearch: {
provider: "openai",
remote: {
apiKey: { source: "env", provider: "default", id: "OPENAI_API_KEY" },
headers: { "X-Default": "on" },
},
},
},
list: [
{
id: "main",
default: true,
memorySearch: {
remote: {
baseUrl: "https://agent.example/v1",
},
},
},
],
},
});
const resolved = resolveMemorySearchConfig(cfg, "main");
expect(resolved?.remote).toEqual({
baseUrl: "https://agent.example/v1",
apiKey: { source: "env", provider: "default", id: "OPENAI_API_KEY" },
headers: { "X-Default": "on" },
batch: {
enabled: false,
wait: true,
concurrency: 2,
pollIntervalMs: 2000,
timeoutMinutes: 60,
},
});
});
it("gates session sources behind experimental flag", () => {
const cfg = asConfig({
agents: {

View File

@@ -2,6 +2,7 @@ import os from "node:os";
import path from "node:path";
import type { OpenClawConfig, MemorySearchConfig } from "../config/config.js";
import { resolveStateDir } from "../config/paths.js";
import type { SecretInput } from "../config/types.secrets.js";
import { clampInt, clampNumber, resolveUserPath } from "../utils.js";
import { resolveAgentConfig } from "./agent-scope.js";
@@ -12,7 +13,7 @@ export type ResolvedMemorySearchConfig = {
provider: "openai" | "local" | "gemini" | "voyage" | "mistral" | "ollama" | "auto";
remote?: {
baseUrl?: string;
apiKey?: string;
apiKey?: SecretInput;
headers?: Record<string, string>;
batch?: {
enabled: boolean;