mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-04 21:00:20 +00:00
feat(memory): add per-agent QMD extra collections for cross-agent session search (#58211)
* feat(memory): add per-agent qmd extra collections * test(config): cover qmd extra collections schema outputs * docs(config): refresh qmd extra collections baseline * docs(config): regenerate qmd extra collections baselines * docs(config): clarify qmd extra collection naming
This commit is contained in:
@@ -113,6 +113,55 @@ describe("resolveMemoryBackendConfig", () => {
|
||||
expect(devNames.has("workspace-dev")).toBe(true);
|
||||
});
|
||||
|
||||
it("merges default and per-agent qmd extra collections", () => {
|
||||
const cfg = {
|
||||
agents: {
|
||||
defaults: {
|
||||
workspace: "/workspace/root",
|
||||
memorySearch: {
|
||||
qmd: {
|
||||
extraCollections: [
|
||||
{
|
||||
path: "/shared/team-notes",
|
||||
name: "team-notes",
|
||||
pattern: "**/*.md",
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
},
|
||||
list: [
|
||||
{
|
||||
id: "main",
|
||||
default: true,
|
||||
workspace: "/workspace/root",
|
||||
memorySearch: {
|
||||
qmd: {
|
||||
extraCollections: [
|
||||
{
|
||||
path: "notes",
|
||||
name: "notes",
|
||||
pattern: "**/*.md",
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
memory: {
|
||||
backend: "qmd",
|
||||
qmd: {
|
||||
includeDefaultMemory: false,
|
||||
},
|
||||
},
|
||||
} as OpenClawConfig;
|
||||
const resolved = resolveMemoryBackendConfig({ cfg, agentId: "main" });
|
||||
const names = new Set((resolved.qmd?.collections ?? []).map((collection) => collection.name));
|
||||
expect(names.has("team-notes")).toBe(true);
|
||||
expect(names.has("notes-main")).toBe(true);
|
||||
});
|
||||
|
||||
it("preserves explicit custom collection names for paths outside the workspace", () => {
|
||||
const cfg = {
|
||||
agents: {
|
||||
|
||||
@@ -368,9 +368,19 @@ export function resolveMemoryBackendConfig(params: {
|
||||
const searchExtraPaths = dedupedExtraPaths.map(
|
||||
(pathValue): { path: string; pattern?: string; name?: string } => ({ path: pathValue }),
|
||||
);
|
||||
const mergedExtraCollections = [
|
||||
...(params.cfg.agents?.defaults?.memorySearch?.qmd?.extraCollections ?? []),
|
||||
...(agentEntry?.memorySearch?.qmd?.extraCollections ?? []),
|
||||
].filter((value): value is MemoryQmdIndexPath =>
|
||||
Boolean(value && typeof value === "object" && typeof value.path === "string"),
|
||||
);
|
||||
|
||||
// Combine QMD-specific paths with memorySearch extraPaths
|
||||
const allQmdPaths: MemoryQmdIndexPath[] = [...(qmdCfg?.paths ?? []), ...searchExtraPaths];
|
||||
// Combine QMD-specific paths with extraPaths and per-agent cross-agent collections.
|
||||
const allQmdPaths: MemoryQmdIndexPath[] = [
|
||||
...(qmdCfg?.paths ?? []),
|
||||
...searchExtraPaths,
|
||||
...mergedExtraCollections,
|
||||
];
|
||||
|
||||
const collections = [
|
||||
...resolveDefaultCollections(includeDefaultMemory, workspaceDir, nameSet, normalizedAgentId),
|
||||
|
||||
Reference in New Issue
Block a user