Skip to content

Commit cd31cbc

Browse files
fix(memory-core): don't run the LLM reranker in vsearch/search modes (#88887)
vsearch/search are documented as vector/lexical-only modes, but runQmdSearchViaMcporter omitted `rerank` from the query tool callArgs, so QMD's query tool (which defaults rerank:true) ran the LLM reranker anyway. Pass rerank:false for those modes; full "query" mode keeps it. Co-authored-by: Claude Opus 4.8 (1M context) <[email protected]>
1 parent be0c40b commit cd31cbc

2 files changed

Lines changed: 47 additions & 0 deletions

File tree

‎extensions/memory-core/src/memory/qmd-manager.test.ts‎

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4070,6 +4070,46 @@ describe("QmdMemoryManager", () => {
40704070
await manager.close();
40714071
});
40724072

4073+
it("disables the LLM reranker (rerank:false) for vsearch mode via mcporter", async () => {
4074+
cfg = {
4075+
...cfg,
4076+
memory: {
4077+
backend: "qmd",
4078+
qmd: {
4079+
includeDefaultMemory: false,
4080+
searchMode: "vsearch",
4081+
update: { interval: "0s", debounceMs: 60_000, onBoot: false },
4082+
paths: [{ path: workspaceDir, pattern: "**/*.md", name: "workspace" }],
4083+
mcporter: { enabled: true, serverName: "qmd", startDaemon: false },
4084+
},
4085+
},
4086+
} as OpenClawConfig;
4087+
4088+
let captured: Record<string, unknown> | null = null;
4089+
spawnMock.mockImplementation((cmd: string, args: string[]) => {
4090+
const child = createMockChild({ autoClose: false });
4091+
if (isMcporterCommand(cmd) && args[0] === "call") {
4092+
captured = JSON.parse(args[args.indexOf("--args") + 1]);
4093+
emitAndClose(child, "stdout", JSON.stringify({ results: [] }));
4094+
return child;
4095+
}
4096+
emitAndClose(child, "stdout", "[]");
4097+
return child;
4098+
});
4099+
4100+
const { manager } = await createManager();
4101+
await manager.search("hello", { sessionKey: "agent:main:slack:dm:u123" });
4102+
await manager.close();
4103+
4104+
expect(captured).not.toBeNull();
4105+
const sentArgs = captured as unknown as Record<string, unknown>;
4106+
// vsearch is a vector-only mode (see buildV2Searches) — it must NOT trigger
4107+
// QMD's LLM reranker, which the "query" tool enables by default.
4108+
expect(sentArgs.rerank).toBe(false);
4109+
const searchTypes = (sentArgs.searches as Array<{ type?: unknown }>).map((s) => s.type);
4110+
expect(searchTypes).toEqual(["vec"]);
4111+
});
4112+
40734113
it("keeps hyphenated tokens in lexical QMD searches while normalizing semantic searches", async () => {
40744114
cfg = {
40754115
...cfg,

‎extensions/memory-core/src/memory/qmd-manager.ts‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2638,6 +2638,13 @@ export class QmdMemoryManager implements MemorySearchManager {
26382638
// its own reranking pipeline and does not accept a minScore parameter.
26392639
searches: this.buildV2Searches(params.query, params.searchCommand),
26402640
limit: params.limit,
2641+
// "search"/"vsearch" are lexical/vector-only modes (see buildV2Searches):
2642+
// they must not trigger the LLM reranker. QMD's "query" tool defaults
2643+
// rerank:true, so disable it explicitly for those modes; full "query"
2644+
// mode keeps reranking.
2645+
...(params.searchCommand === "search" || params.searchCommand === "vsearch"
2646+
? { rerank: false }
2647+
: {}),
26412648
}
26422649
: {
26432650
// QMD 1.x tools accept a flat query string.

0 commit comments

Comments
 (0)