Skip to content

Commit 2bbb3a0

Browse files
committed
记忆内容改成L2优先
1 parent 69b2b24 commit 2bbb3a0

File tree

1 file changed

+14
-11
lines changed

1 file changed

+14
-11
lines changed

examples/openclaw-plugin/index.ts

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -936,19 +936,22 @@ const contextEnginePlugin = {
936936
const memories = pickMemoriesForInjection(processed, cfg.recallLimit, queryText);
937937

938938
if (memories.length > 0) {
939-
const { lines: memoryLines, estimatedTokens } = await buildMemoryLinesWithBudget(
940-
memories,
941-
(uri) => client.read(uri, agentId),
942-
{
943-
recallPreferAbstract: cfg.recallPreferAbstract,
944-
recallMaxContentChars: cfg.recallMaxContentChars,
945-
recallTokenBudget: cfg.recallTokenBudget,
946-
},
939+
const memoryLines = await Promise.all(
940+
memories.map(async (item: FindResultItem) => {
941+
if (item.level === 2) {
942+
try {
943+
const content = await client.read(item.uri);
944+
if (content && typeof content === "string" && content.trim()) {
945+
return `- [${item.category ?? "memory"}] ${content.trim()}`;
946+
}
947+
} catch {
948+
// fallback to abstract
949+
}
950+
}
951+
return `- [${item.category ?? "memory"}] ${item.abstract ?? item.uri}`;
952+
}),
947953
);
948954
const memoryContext = memoryLines.join("\n");
949-
verboseRoutingInfo(
950-
`openviking: injecting ${memoryLines.length} memories (~${estimatedTokens} tokens, budget=${cfg.recallTokenBudget})`,
951-
);
952955
verboseRoutingInfo(
953956
`openviking: inject-detail ${toJsonLog({ count: memories.length, memories: summarizeInjectionMemories(memories) })}`,
954957
);

0 commit comments

Comments
 (0)