Skip to content

A team of long-lived bots for DeepSeek Harness, with main bots, bot-to-bot messages and group chats.

Let recall find a continuous Chinese phrase

Fei241100ae2ea3ada4
diff --git a/ds-bot/src/host/memory.js b/ds-bot/src/host/memory.js
index ea30cd13..e8f9e415 100644
--- a/ds-bot/src/host/memory.js
+++ b/ds-bot/src/host/memory.js
@@ -1224,7 +1224,13 @@ export function install(rt) {
].join('\n')
}).join('\n\n')
}
- const terms = [...new Set(squash(query).split(' ').filter(Boolean))].slice(0, QUERY_TERMS_MAX)
+ // A continuous run of Han characters has no spaces to split on: its
+ // character pairs stand for the words inside it. Other words, and
+ // space-separated terms, match as they did.
+ const terms = [...new Set(squash(query).split(' ').filter(Boolean).flatMap((word) => {
+ const words = /[\u4e00-\u9fff]/.test(word) ? [...wordsOf(word)] : []
+ return words.length > 0 ? words : [word]
+ }))].slice(0, QUERY_TERMS_MAX)
const scored = loaded.flatMap(({ tag, files }) => allEntries(files).map((entry) => {
const hay = squash(`${entry.text} ${entry.file.topic ?? ''}`)
return { entry, tag, count: terms.filter(term => hay.includes(term)).length }
diff --git a/ds-bot/test/memory.test.js b/ds-bot/test/memory.test.js
index ae8a798a..93816e4e 100644
--- a/ds-bot/test/memory.test.js
+++ b/ds-bot/test/memory.test.js
@@ -233,6 +233,22 @@ test('topics hold details, linked from MEMORY.md, and go when their last entry d
assert.equal(read('bots', 'b2', 'MEMORY.md'), '# Memory\n\n## Index\n')
})
+test('recall finds a continuous Chinese phrase, and keeps space-separated and Latin matching', async (t) => {
+ const { tool, stop } = start()
+ t.after(() => stop())
+ await tool('remember', { text: '女友小李的生日是 10 月 22 日' }, 'b2')
+ await tool('remember', { text: 'The user likes green tea' }, 'b2')
+ // The phrase is not a substring of the entry: its character pairs find it.
+ assert.match(await tool('recall', { query: '小李生日' }, 'b2'), /女友小李的生日是 10 月 22 日/)
+ // An entry holding the whole phrase still matches every term.
+ await tool('remember', { text: '小李生日会定在周六' }, 'b2')
+ assert.match(await tool('recall', { query: '小李生日' }, 'b2'), /^Entries with "小李生日" in your memory and the team memory:\n\[yours · MEMORY\.md\] 小李生日会定在周六/)
+ // Space-separated terms and Latin words match as they did.
+ assert.match(await tool('recall', { query: '小李 生日' }, 'b2'), /女友小李的生日/)
+ assert.match(await tool('recall', { query: 'green tea' }, 'b2'), /likes green tea/)
+ assert.match(await tool('recall', { query: 'green 生日' }, 'b2'), /No entry has all of "green 生日"/)
+})
+
test('Main Bots and group admins write the team memory; only Main Bots touch another Bot\'s', async (t) => {
const { tool, read, stop } = start()
t.after(() => stop())