mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-04 08:40:22 +00:00
fix(memory/qmd): throttle embed + citations auto + restore --force
This commit is contained in:
@@ -51,7 +51,10 @@ export function createMemorySearchTool(options: {
|
||||
}
|
||||
try {
|
||||
const citationsMode = resolveMemoryCitationsMode(cfg);
|
||||
const includeCitations = citationsMode !== "off";
|
||||
const includeCitations = shouldIncludeCitations({
|
||||
mode: citationsMode,
|
||||
sessionKey: options.agentSessionKey,
|
||||
});
|
||||
const rawResults = await manager.search(query, {
|
||||
maxResults,
|
||||
minScore,
|
||||
@@ -141,3 +144,21 @@ function formatCitation(entry: MemorySearchResult): string {
|
||||
: `#L${entry.startLine}-L${entry.endLine}`;
|
||||
return `${entry.path}${lineRange}`;
|
||||
}
|
||||
|
||||
function shouldIncludeCitations(params: {
|
||||
mode: MemoryCitationsMode;
|
||||
sessionKey?: string;
|
||||
}): boolean {
|
||||
if (params.mode === "on") return true;
|
||||
if (params.mode === "off") return false;
|
||||
// auto: show citations in direct chats; suppress in groups/channels by default.
|
||||
const chatType = deriveChatTypeFromSessionKey(params.sessionKey);
|
||||
return chatType === "direct";
|
||||
}
|
||||
|
||||
function deriveChatTypeFromSessionKey(sessionKey?: string): "direct" | "group" | "channel" {
|
||||
if (!sessionKey) return "direct";
|
||||
if (sessionKey.includes(":group:")) return "group";
|
||||
if (sessionKey.includes(":channel:")) return "channel";
|
||||
return "direct";
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user