A team of long-lived bots for DeepSeek Harness, with main bots, bot-to-bot messages and group chats.
Count a repeated recall word once before the term cap
Fei24118aaf6532db67
diff --git a/ds-bot/src/host/memory.js b/ds-bot/src/host/memory.jsindex 697bab81..8a4f4666 100644--- a/ds-bot/src/host/memory.js+++ b/ds-bot/src/host/memory.js@@ -1224,12 +1224,13 @@ export function install(rt) {].join('\n')}).join('\n\n')}- // The cap is on the user's own words, so a long phrase's pairs do not push- // its end or later words out. A run of Han characters has no spaces to- // split on: the word itself is a term, so an entry holding the whole- // phrase outranks one holding only its parts; its character pairs stand- // for the words inside it, and a Latin part of a mixed word is a term too.- const words = squash(query).split(' ').filter(Boolean).slice(0, QUERY_TERMS_MAX)+ // The cap is on the user's own words, each counted once, so a long phrase's+ // pairs do not push its end or later words out. A run of Han characters has+ // no spaces to split on: the word itself is a term, so an entry holding the+ // whole phrase outranks one holding only its parts; its character pairs+ // stand for the words inside it, and a Latin part of a mixed word is a+ // term too.+ const words = [...new Set(squash(query).split(' ').filter(Boolean))].slice(0, QUERY_TERMS_MAX)const terms = [...new Set(words.flatMap((word) => {if (!/[\u4e00-\u9fff]/.test(word)) return [word]const parts = new Set(word.match(/[a-z0-9]+/g) ?? [])diff --git a/ds-bot/test/memory.test.js b/ds-bot/test/memory.test.jsindex 8329eef4..c7e4c5dd 100644--- a/ds-bot/test/memory.test.js+++ b/ds-bot/test/memory.test.js@@ -268,6 +268,19 @@ test('recall caps the user\'s words, not their pairs, and a whole phrase outrankassert.doesNotMatch(hits, /安全事项/)})+test('a repeated word in a recall query is counted once, so a later word still reaches the cut', async (t) => {+ const { tool, stop } = start()+ t.after(() => stop())+ await tool('remember', { text: '周末上海出差安排住外滩的酒店' }, 'b2')+ await tool('remember', { text: '女友小李的生日是 10 月 22 日' }, 'b2')+ // 上海 said six times is one word: 生日 still counts, so the entry that holds+ // only 上海 is the closest, not a full match.+ const hits = await tool('recall', { query: '上海 上海 上海 上海 上海 上海 生日' }, 'b2')+ assert.match(hits, /No entry has all of "上海 上海 上海 上海 上海 上海 生日"/)+ assert.match(hits, /周末上海出差安排住外滩的酒店/)+ assert.match(hits, /女友小李的生日是 10 月 22 日/)+})+test('a mixed word keeps its Latin part in recall', async (t) => {const { tool, stop } = start()t.after(() => stop())