Memory/QMD: add limit arg to search command

This commit is contained in:
Vignesh Natarajan
2026-02-14 14:56:57 -08:00
parent 19df928e7f
commit 62aae7f69d
3 changed files with 27 additions and 4 deletions

View File

@@ -70,6 +70,7 @@ Docs: https://docs.openclaw.ai
- Memory/QMD: cap QMD command output buffering to prevent memory exhaustion from pathological `qmd` command output. - Memory/QMD: cap QMD command output buffering to prevent memory exhaustion from pathological `qmd` command output.
- Memory/QMD: query QMD index using exact docid matches before falling back to prefix lookup for better recall correctness and index efficiency. - Memory/QMD: query QMD index using exact docid matches before falling back to prefix lookup for better recall correctness and index efficiency.
- Memory/QMD: make QMD result JSON parsing resilient to noisy command output by extracting the first JSON array from noisy `stdout`. - Memory/QMD: make QMD result JSON parsing resilient to noisy command output by extracting the first JSON array from noisy `stdout`.
- Memory/QMD: pass result limits to `search`/`vsearch` commands so QMD can cap results earlier.
- Models/CLI: guard `models status` string trimming paths to prevent crashes from malformed non-string config values. (#16395) Thanks @BinHPdev. - Models/CLI: guard `models status` string trimming paths to prevent crashes from malformed non-string config values. (#16395) Thanks @BinHPdev.
## 2026.2.14 ## 2026.2.14

View File

@@ -340,7 +340,15 @@ describe("QmdMemoryManager", () => {
).resolves.toEqual([]); ).resolves.toEqual([]);
const searchCall = spawnMock.mock.calls.find((call) => call[1]?.[0] === "search"); const searchCall = spawnMock.mock.calls.find((call) => call[1]?.[0] === "search");
expect(searchCall?.[1]).toEqual(["search", "test", "--json", "-c", "workspace"]); expect(searchCall?.[1]).toEqual([
"search",
"test",
"--json",
"-n",
String(resolved.qmd?.limits.maxResults),
"-c",
"workspace",
]);
expect(spawnMock.mock.calls.some((call) => call[1]?.[0] === "query")).toBe(false); expect(spawnMock.mock.calls.some((call) => call[1]?.[0] === "query")).toBe(false);
expect(maxResults).toBeGreaterThan(0); expect(maxResults).toBeGreaterThan(0);
await manager.close(); await manager.close();
@@ -394,7 +402,7 @@ describe("QmdMemoryManager", () => {
(args): args is string[] => Array.isArray(args) && ["search", "query"].includes(args[0]), (args): args is string[] => Array.isArray(args) && ["search", "query"].includes(args[0]),
); );
expect(searchAndQueryCalls).toEqual([ expect(searchAndQueryCalls).toEqual([
["search", "test", "--json", "-c", "workspace"], ["search", "test", "--json", "-n", String(maxResults), "-c", "workspace"],
["query", "test", "--json", "-n", String(maxResults), "-c", "workspace"], ["query", "test", "--json", "-n", String(maxResults), "-c", "workspace"],
]); ]);
await manager.close(); await manager.close();
@@ -558,7 +566,21 @@ describe("QmdMemoryManager", () => {
await manager.search("test", { sessionKey: "agent:main:slack:dm:u123" }); await manager.search("test", { sessionKey: "agent:main:slack:dm:u123" });
const searchCall = spawnMock.mock.calls.find((call) => call[1]?.[0] === "search"); const searchCall = spawnMock.mock.calls.find((call) => call[1]?.[0] === "search");
expect(searchCall?.[1]).toEqual(["search", "test", "--json", "-c", "workspace", "-c", "notes"]); const maxResults = resolved.qmd?.limits.maxResults;
if (!maxResults) {
throw new Error("qmd maxResults missing");
}
expect(searchCall?.[1]).toEqual([
"search",
"test",
"--json",
"-n",
String(maxResults),
"-c",
"workspace",
"-c",
"notes",
]);
await manager.close(); await manager.close();
}); });

View File

@@ -972,7 +972,7 @@ export class QmdMemoryManager implements MemorySearchManager {
if (command === "query") { if (command === "query") {
return ["query", query, "--json", "-n", String(limit)]; return ["query", query, "--json", "-n", String(limit)];
} }
return [command, query, "--json"]; return [command, query, "--json", "-n", String(limit)];
} }
} }