Skip to content

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

Fix missed and false wake-ups, duplicate promise answers and the idle pause in groups

Fei2411dbf4c4b4f806
diff --git a/docs/plans/2026-10-07-group-chat.md b/docs/plans/2026-10-07-group-chat.md
index 4c1abe6d..b1c345de 100644
--- a/docs/plans/2026-10-07-group-chat.md
+++ b/docs/plans/2026-10-07-group-chat.md
@@ -26,8 +26,8 @@
- 一轮进行中用户发的话立刻写进群,交给它该叫的人(管理员模式下是管理员),不排在正在回答的成员后面。
- 一个成员同一时间只回答一个叫它的消息;前一个回答完(或转去后台干活)才开始下一个。
- 全员轮流的普通消息(不带 `@`)仍按顺序:上一个人发完(或跳过)下一个人才开始,每个人看到本轮之前所有人的发言和自己的位置。
-- 回复里 `@` 了别人,被点的人接着说(接力)。有实质进展(调了工具、产出新内容)的接力不设次数上限;只有 Bot 之间连续 6 轮 0 工具调用且只是重复或客套确认时,才会暂停并在群里提示,等用户发言后继续。要主动停下群里的工作,用户在群详情里点「全部停止」或逐个停。
-- 每个成员可以跳过(`[PASS]`),不必每轮都说话。被点名干活的成员如果只回复「收到 / 现在去查」却没调任何工具就结束回合,宿主会自动把这句作为进度发到群里并在同一调用上续推一次,让它真正调用工具把活做完(#469)。
+- 回复里 `@` 了别人,被点的人接着说(接力)。有实质进展(调了工具、产出新内容)的接力不设次数上限;只有 Bot 之间连续 6 轮 0 工具调用且只是重复或客套确认时,才会暂停,群里提示「谁和谁来回 6 次没有进展,先停下了」;停下的叫人只在用户发言后继续,Bot 的帖或迟到的回复不会放行。要主动停下群里的工作,用户在群详情里点「全部停止」或逐个停。
+- 每个成员可以跳过(`[PASS]`),不必每轮都说话。被点名干活的成员如果只回复「收到 / 现在去查」却没调任何工具就结束回合,宿主会自动把这句作为进度发到群里并在同一调用上续推一次,让它真正调用工具把活做完(#469);如果那句其实已经是完整的回答,它回 `[PASS]`,群里不会出现两遍。只看整条话是不是只有承诺:后面跟着结论或列表的回复不续推。
### 提及
@@ -47,7 +47,7 @@
- 成员在群里接到需要干活的任务时,第一次调用工具后 15 秒仍在干活,本轮就继续往下走,不再等它。
- 干活过程中,它说的第一句话和带 `@` 的话立刻发到群里;间隔不到 30 秒的几句合并成一条发。轮次进行中进来的 Bot 群帖、进度和完成消息直接并入当前轮次处理,不再额外塞进群 Session 的待发队列(#663)。
-- 派活按批次收回:不管被点名的成员是在 15 秒内干完还是 15 秒后干完,也不管回复里有没有手写 `@派活人`,只要调了工具干完活(或明确提出需要管理员拍板),都算作该批次的子项完成;同一条消息并行点名多个人时,各自完成的话立刻发到群里,等这一批全部落地后再统一唤醒派活的 Bot 一次(#619)。
+- 派活按批次收回:不管被点名的成员是在 15 秒内干完还是 15 秒后干完,也不管回复里有没有手写 `@派活人`,只要调了工具干完活,都算作该批次的子项完成;同一条消息并行点名多个人时,各自完成的话立刻发到群里,等这一批全部落地后再统一唤醒派活的 Bot 一次(#619)。派活的 Bot 还在自己这一回合里时,等这回合结束再叫它。用户直接叫的成员,结果是给用户的,不另叫管理员;成员需要管理员拍板时写 `@管理员`。
- 本轮结束后才完成的回复照样发进群,它叫的人照样接着说。
- 回答超时只在成员的会话完全没有动静时计时(4 分钟)。没及时回应、需要审批的成员各在群里留一行淡色事件,让用户知道发生了什么。
@@ -100,3 +100,4 @@
- 2026-10-30:同一条消息点到的成员同时开工,`@` 一发出来就生效,一轮中用户的话和 Bot 的帖马上交给该叫的人;只有全员轮流的普通消息还按顺序(#726)。
- 2026-10-31:派活按批次收回并等同一批全部落地后统一叫醒派活 Bot(#619);只回「收到/开工」未调工具的回合自动续推一次(#469);连续 6 轮 0 工具重复或客套空转自动暂停;运行中已吸收的群帖不再塞进群 Session 待发队列(#663);群成员派出的 DSH 子代理并入群忙碌状态与停止控制(#701)。
- 2026-11-01:群自己的 Session 也按段换,换群文件夹时换到群文件夹里的新一段;成员在群里换的文件夹只作用于这个群(#277)。
+- 2026-11-03:派活的 Bot 还在自己回合里时,批次落地后等它这回合结束再叫它;去掉按「需要拍板」字样叫管理员;续推可以回 `[PASS]`,后面带结论的回复不再续推;空转守卫停下的叫人只在用户发言后继续,提示说清是来回没有进展(#872)。
diff --git a/ds-bot/client.js b/ds-bot/client.js
index 631a4875..e90808b2 100644
--- a/ds-bot/client.js
+++ b/ds-bot/client.js
@@ -697,6 +697,7 @@ var ZH = {
"{name} did not answer or call anyone; call a member with @Name": "{name} 没有回答,也没有叫谁;用 @名字 叫一个成员来回答",
"The group replies could not be shown": "群里的回复显示不出来",
"Paused after {count} Bot relays. Waiting: {names}": "Bot 之间已接力 {count} 次,先停下了。还在等:{names}",
+ "{names} went back and forth {count} times without progress and paused. Write here to go on": "{names} 来回 {count} 次没有进展,先停下了。你发言后继续",
"{name} paused for your approval": "{name} 停下来等你批准",
"{name} started on it": "{name} 开始做了",
"You stopped {name}'s work": "你停下了 {name} 的工作",
@@ -9387,11 +9388,7 @@ function RelayEvent({ reply, bot, sessionId, actions }) {
);
}
if (reply.kind === "paused") {
- return (0, import_react19.createElement)(
- "div",
- { className: "bt-event" },
- t("Paused after {count} Bot relays. Waiting: {names}", { count: reply.count, names: (reply.names ?? []).join(t(" and ")) })
- );
+ return (0, import_react19.createElement)("div", { className: "bt-event" }, reply.idle ? t("{names} went back and forth {count} times without progress and paused. Write here to go on", { count: reply.count, names: [bot.name, ...reply.names ?? []].join(t(" and ")) }) : t("Paused after {count} Bot relays. Waiting: {names}", { count: reply.count, names: (reply.names ?? []).join(t(" and ")) }));
}
if (reply.kind === "resumed") {
return (0, import_react19.createElement)("div", { className: "bt-event" }, t("{name} was cut off by a restart and picked its work back up", { name: bot.name }));
diff --git a/ds-bot/src/client/cells.js b/ds-bot/src/client/cells.js
index 0c899c78..a8a9a700 100644
--- a/ds-bot/src/client/cells.js
+++ b/ds-bot/src/client/cells.js
@@ -919,10 +919,12 @@ function RelayEvent({ reply, bot, sessionId, actions }) {
return h('div', { className: 'bt-event' },
t('{name} did not answer or call anyone; call a member with @Name', { name: bot.name }))
}
- // LEGACY: rounds from when groups paused at a relay limit.
+ // Bots that went back and forth without progress. LEGACY: rounds from when groups
+ // paused at a relay limit.
if (reply.kind === 'paused') {
- return h('div', { className: 'bt-event' },
- t('Paused after {count} Bot relays. Waiting: {names}', { count: reply.count, names: (reply.names ?? []).join(t(' and ')) }))
+ return h('div', { className: 'bt-event' }, reply.idle
+ ? t('{names} went back and forth {count} times without progress and paused. Write here to go on', { count: reply.count, names: [bot.name, ...(reply.names ?? [])].join(t(' and ')) })
+ : t('Paused after {count} Bot relays. Waiting: {names}', { count: reply.count, names: (reply.names ?? []).join(t(' and ')) }))
}
if (reply.kind === 'resumed') {
return h('div', { className: 'bt-event' }, t('{name} was cut off by a restart and picked its work back up', { name: bot.name }))
diff --git a/ds-bot/src/client/i18n.js b/ds-bot/src/client/i18n.js
index bb5bcd4d..d11d1ccd 100644
--- a/ds-bot/src/client/i18n.js
+++ b/ds-bot/src/client/i18n.js
@@ -643,6 +643,7 @@ const ZH = {
'{name} did not answer or call anyone; call a member with @Name': '{name} 没有回答,也没有叫谁;用 @名字 叫一个成员来回答',
'The group replies could not be shown': '群里的回复显示不出来',
'Paused after {count} Bot relays. Waiting: {names}': 'Bot 之间已接力 {count} 次,先停下了。还在等:{names}',
+ '{names} went back and forth {count} times without progress and paused. Write here to go on': '{names} 来回 {count} 次没有进展,先停下了。你发言后继续',
'{name} paused for your approval': '{name} 停下来等你批准',
'{name} started on it': '{name} 开始做了',
"You stopped {name}'s work": '你停下了 {name} 的工作',
diff --git a/ds-bot/src/host/groups.js b/ds-bot/src/host/groups.js
index df7c5e78..563fc39e 100644
--- a/ds-bot/src/host/groups.js
+++ b/ds-bot/src/host/groups.js
@@ -33,10 +33,6 @@ const ROOM_FIRST_LOOK = 12
const ROOM_DELTA_MAX = 24
const ROOM_EARLIER_MAX = 8
-// A reply that hands back an unresolved decision to the admin or caller without @Name (#619).
-const NEEDS_CALLER_DECISION = /需要.*(?:决定|拍板|确认|指示|裁决|定夺)|请.*(?:管理员|负责人|组长|拍板|决定|指示|确认)|等.*(?:管理员|负责人|决定|拍板|指示)|\b(?:need|needs|waiting\s+for|requires)\s+(?:the\s+)?(?:admin|lead|leader|chief|you)\s+to\s+(?:decide|confirm|choose|approve|pick)\b/i
-const needsCallerDecision = text => typeof text === 'string' && NEEDS_CALLER_DECISION.test(text)
-
// Short ack/thanks/closing phrases with no new content, used by the 0-tool idle loop guard.
const IDLE_ACK_BODY = /^(?:(?:收到|好的|好|明白|明白了|了解|了解了|没问题|谢谢|多谢|感谢|辛苦了|辛苦|不客气|不用谢|完毕|完成|好嘞|行|ok|okay|got\s+it|understood|noted|thanks|thank\s+you|you\s+are\s+welcome|you're\s+welcome|welcome|np|no\s+problem|roger|ack|done|all\s+good|sounds\s+good)(?:[\s,,、。.!!~~::]+|$))+$/i
const normalizeRelayBody = (text, everyone) => {
@@ -90,6 +86,7 @@ const goalNotice = (line) => {
}
const noticeText = (line) => {
if (line.reason === 'missed') return `${(line.names ?? []).join(' and ')} did not answer within ${line.minutes} minutes, so this round moved on without it. If it is still working, it posts its result later as a late reply; if it is urgent, the user can write here or the admin can follow up.`
+ if (line.reason === 'paused' && line.idle) return `Paused: ${[line.from, ...(line.names ?? [])].filter(Boolean).join(' and ')} went back and forth ${line.limit} times without progress (no tool used, only thanks or repeats). The calls to @${(line.names ?? []).join(' and @')} wait until the user writes here; do not call them again.`
if (line.reason === 'paused') return `Paused: Bots have called each other ${line.limit} times since the user last wrote here. The calls to @${(line.names ?? []).join(' and @')} wait until the user continues or writes here; do not call them again.`
if (line.reason === 'admin-passed') return `${(line.names ?? []).join(' and ') || 'The admin'} did not answer or call anyone; call a member with @Name.`
if (line.reason === 'folder') return `The group's folder ${line.path} is gone, so its members work in the team workspace; set the group's folder again in the group's settings.`
@@ -603,14 +600,19 @@ export function install(rt) {
return round.slots.every((other, index) => !other.ordered || other === slot || (other.status !== 'speaking' && !(other.status === 'waiting' && index < at)))
}
- // LEGACY: groups used to park Bot calls past a relay limit until the user went on.
- // Calls still parked from then (or by the idle ping-pong guard) run in the group's
- // next round, with its opening speakers; one already waiting in the round is not
- // called twice.
+ // Calls the idle ping-pong guard parked (`idle`) run once the user writes: in the
+ // round the user's message opens, or in the running round that takes it in.
+ // LEGACY: groups used to park Bot calls past a relay limit until the user went on;
+ // calls still parked from then run in the group's next round. Either way they join
+ // the round's speakers, and one already waiting in the round is not called twice.
const releaseParked = (room, round) => {
const parked = room.paused ?? []
- delete room.paused
- for (const entry of parked) {
+ const due = parked.filter(entry => entry.idle !== true || round.userMessage === true)
+ if (due.length === 0) return
+ const left = parked.filter(entry => !due.includes(entry))
+ if (left.length > 0) room.paused = left
+ else delete room.paused
+ for (const entry of due) {
if (round.slots.some(slot => slot.id === entry.id && slot.status === 'waiting')) continue
const peer = rt.botOf(entry.id)
const batchKey = peer && entry.by !== undefined ? registerBatch(room.id, entry.by, [peer]) : undefined
@@ -661,6 +663,7 @@ export function install(rt) {
const { speakers, ordered } = openingCall(room, { text: line.text })
callIn(round, speakers, note, undefined, { ordered })
}
+ releaseParked(room, round)
void rt.save().catch(() => {})
}
@@ -691,13 +694,13 @@ export function install(rt) {
const parked = room.paused ?? []
for (const peer of callees) {
if (!parked.some(entry => entry.id === peer.id)) {
- parked.push({ id: peer.id, name: peer.name, note: `${member.name} mentioned you`, by: member.id })
+ parked.push({ id: peer.id, name: peer.name, note: `${member.name} mentioned you`, by: member.id, idle: true })
}
}
room.paused = parked
const names = callees.map(peer => peer.name)
- appendRoom(room, { who: 'DS Bot', kind: 'notice', reason: 'paused', limit: ROOM_IDLE_RELAY_LIMIT, names })
- round.replies.push({ kind: 'paused', count: ROOM_IDLE_RELAY_LIMIT, limit: ROOM_IDLE_RELAY_LIMIT, names, time: Date.now() })
+ appendRoom(room, { who: 'DS Bot', kind: 'notice', reason: 'paused', idle: true, from: member.name, limit: ROOM_IDLE_RELAY_LIMIT, names })
+ round.replies.push({ kind: 'paused', idle: true, botId: member.id, name: member.name, color: member.color, count: ROOM_IDLE_RELAY_LIMIT, limit: ROOM_IDLE_RELAY_LIMIT, names, time: Date.now() })
void rt.save().catch(() => {})
return
}
@@ -847,22 +850,18 @@ export function install(rt) {
if (slot.status === 'posted') {
batch.done.push(member.name)
if (called.size > 0) batch.answered = true
- if (worked || needsCallerDecision(final)) batch.worked = true
+ if (worked) batch.worked = true
}
dropMemberFromBatch(room, member.id)
if (batch.pending.size === 0 && batch.done.length > 0 && batch.worked && !batch.answered && !signal.aborted) {
const caller = rt.botOf(batch.by)
+ // A caller still waiting in this round reads the results when it starts. One
+ // still in its own turn cannot see them, so it answers in a turn after that one.
if (caller !== undefined && room.members.includes(caller.id)
- && !round.slots.some(other => other.id === caller.id && (other.status === 'waiting' || other.status === 'speaking'))) {
+ && !round.slots.some(other => other.id === caller.id && other.status === 'waiting')) {
callIn(round, [caller], `${batch.done.join(' and ')} finished the work you asked for`, undefined)
}
}
- } else if (slot.status === 'posted' && called.size === 0 && needsCallerDecision(final) && room.mode === 'admin' && room.admin && room.admin !== member.id) {
- const admin = rt.botOf(room.admin)
- if (admin !== undefined && room.members.includes(admin.id)
- && !round.slots.some(other => other.id === admin.id && (other.status === 'waiting' || other.status === 'speaking'))) {
- callIn(round, [admin], `${member.name} finished the work and needs your decision`, undefined)
- }
}
}
}
@@ -1131,13 +1130,7 @@ export function install(rt) {
const { all, found: named } = mentionsOf(opener, everyone) ?? mentionsIn(opener.text, everyone, opener.references)
const found = named.filter(bot => bot.id !== opener.botId)
if (opener.progress) return at(found)
- if (opener.late) {
- if (found.length > 0) return at(found)
- const asked = members.filter(bot => bot.id === opener.askedBy)
- if (asked.length > 0) return at(asked)
- if (needsCallerDecision(opener.text) && room.mode === 'admin' && admin) return at([admin])
- return at([])
- }
+ if (opener.late) return at(found.length > 0 ? found : members.filter(bot => bot.id === opener.askedBy))
if (opener.member) return at(found)
if (found.length > 0 && !all) return at(found)
if (!all && room.mode === 'admin' && admin) return at([admin])
diff --git a/ds-bot/src/host/turns.js b/ds-bot/src/host/turns.js
index 04e1dbe3..fa286f0b 100644
--- a/ds-bot/src/host/turns.js
+++ b/ds-bot/src/host/turns.js
@@ -108,12 +108,20 @@ const subEndText = (data) => {
}
const RETRY_TEXT = 'Your last reply wrote a tool call as plain text (<tool_call>…), so it did not run and nothing happened. Call the tool through the tool interface now, then reply as you meant to.'
-const RETRY_PROMISE_TEXT = 'Your last reply said you would start working, but you ended the turn without calling any tool, so nothing ran. Call the tools you need and complete the task now, or state your final answer if no tool is needed.'
+const RETRY_PROMISE_TEXT = 'Your last reply said you would start working, but you ended the turn without calling any tool, so nothing ran. Call the tools you need and do the work now. If your last reply already was your whole answer, reply [PASS]; it stays posted.'
// A reply that only promises to start investigating/checking/running tools now without
-// actually calling a tool or handing off with @Name (#469).
-const PROMISED_WORK = /(?:^(?:收到|好的|明白|好|行|没问题|了解)[,,、。.!!:\s]*(?:我(?:现在|这就|先|马上|立刻|去|来)?(?:开始|着手|去|来|准备)?(?:排查|检查|调查|查看|看看|搜索|搜一下|分析|处理|执行|运行|跑一下|修改|修复|实现|编写|整理|验证|测试|读一下|翻一下)|(?:现在|马上|立刻)?(?:开始|着手)(?:执行|处理|排查|检查|调查|干活|开工)|开工(?:[。!!,,\s]|$))|^(?:开工(?:[。!!,,\s]|$)|我(?:现在|这就|先|马上|立刻)(?:开始|着手|去)(?:排查|检查|调查|查看|搜索|分析|处理|执行|运行|修改|修复|实现|编写|整理|验证|测试))|\b(?:(?:i\s+will|i'll|let\s+me|going\s+to)\s+(?:start|begin|check|look\s+into|investigate|search|run|inspect|read|fix|implement|work\s+on)\b|(?:starting|beginning)\s+(?:the\s+)?(?:investigation|check|search|work|execution|analysis)\b|^on\s+it[,.\s!]+(?:i'll|i\s+will|let\s+me|starting|checking)\b))/i
-export const promisesWork = text => typeof text === 'string' && text.trim().length <= 240 && PROMISED_WORK.test(text.trim())
+// actually calling a tool or handing off with @Name (#469). A verb followed by 过, 完
+// or 好了 reports work that is done.
+const PROMISED_WORK = /(?:^(?:收到|好的|明白|好|行|没问题|了解)[,,、。.!!:\s]*(?:我(?:现在|这就|先|马上|立刻|去|来)?(?:开始|着手|去|来|准备)?(?:排查|检查|调查|查看|看看|搜索|搜一下|分析|处理|执行|运行|跑一下|修改|修复|实现|编写|整理|验证|测试|读一下|翻一下)(?!过|完|好了)|(?:现在|马上|立刻)?(?:开始|着手)(?:执行|处理|排查|检查|调查|干活|开工)(?!过|完|好了)|开工(?:[。!!,,\s]|$))|^(?:开工(?:[。!!,,\s]|$)|我(?:现在|这就|先|马上|立刻)(?:开始|着手|去)(?:排查|检查|调查|查看|搜索|分析|处理|执行|运行|修改|修复|实现|编写|整理|验证|测试)(?!过|完|好了))|\b(?:(?:i\s+will|i'll|let\s+me|going\s+to)\s+(?:start|begin|check|look\s+into|investigate|search|run|inspect|read|fix|implement|work\s+on)\b|(?:starting|beginning)\s+(?:the\s+)?(?:investigation|check|search|work|execution|analysis)\b|^on\s+it[,.\s!]+(?:i'll|i\s+will|let\s+me|starting|checking)\b))/i
+// Only a promise that closes the reply counts: a second sentence or a list after it
+// ("好,我分析一下:…", "Let me check: …") is the answer itself.
+const PROMISE_ANSWERED = /[。!?;:\n]|[.!?;:](?=\s)/
+export const promisesWork = (text) => {
+ const said = typeof text === 'string' ? text.trim() : ''
+ const promise = said.length <= 240 ? PROMISED_WORK.exec(said) : null
+ return promise !== null && !PROMISE_ANSWERED.test(said.slice(promise.index + promise[0].length).replace(/[\s。.!!~~]+$/u, ''))
+}
export function install(rt) {
const { ctx, state } = rt
@@ -161,6 +169,9 @@ export function install(rt) {
// late settlement notices from these stopped children must not wake the parent (#701).
const stoppedSubagents = new Set()
const stoppedSubagentParents = new Set()
+ // Exchanges whose promise-only opening the group already got before the retry: the
+ // retried turn counts it as shown, so a [PASS] there still hands the result back.
+ const promisedOpenings = new Set()
const STOPPED_KEPT = 200
const rememberStopped = (set, value) => {
@@ -879,7 +890,7 @@ export function install(rt) {
const joined = entry.joined ?? []
// What the group already saw of the turn is not posted again.
const texts = entry.texts.slice(entry.shown)
- const shown = entry.shown > 0
+ const shown = entry.shown > 0 || (info?.retried === true && promisedOpenings.delete(info.exchangeId))
const { lastText, lastCalled } = entry
const toolCount = entry.toolCount ?? 0
const suppressedSubagent = entry.suppressedSubagent === true
@@ -948,7 +959,10 @@ export function install(rt) {
if (retry) {
if (promisedOnly) {
const opening = stripWrittenCalls(lastText ?? '')
- if (opening !== '') void rt.roomStepText?.(id, info, opening, !shown)?.catch(() => {})
+ if (opening !== '') {
+ rememberStopped(promisedOpenings, info.exchangeId)
+ void rt.roomStepText?.(id, info, opening, !shown)?.catch(() => {})
+ }
roomWaiters.get(info.exchangeId)?.touch()
void retryPromisedWork(id, info).catch(error => rt.warn('ds-bot: asking %s to run its promised work failed: %s', id, error))
} else {
diff --git a/ds-bot/test/group-work.test.js b/ds-bot/test/group-work.test.js
index 099c57d0..a8728897 100644
--- a/ds-bot/test/group-work.test.js
+++ b/ds-bot/test/group-work.test.js
@@ -6,6 +6,7 @@ import { test } from 'node:test'
import { createRuntime } from '../index.js'
import { fakeAttachments, fakeContext } from './fake-ctx.js'
import { LONG_HEAD, MESSAGE_INLINE_MAX, ROOM_STEP_GAP_MS, ROOM_WORK_GRACE_MS } from '../src/host/constants.js'
+import { promisesWork } from '../src/host/turns.js'
let rt
@@ -1344,6 +1345,48 @@ test('in-round tool work that finishes before the grace without @Caller still wa
])
})
+// #872: Chief calls Writer in a step line and goes on with its own part. Writer's
+// result lands while Chief is still in that turn, which cannot see it, so Chief
+// answers it in a turn of its own once the first one ends.
+test('a caller still in its own turn answers the batch result after that turn (#872)', async (t) => {
+ const host = await start(t)
+ const first = host.round('c1', host.say('全面检查一下构建'))
+ await settle(() => host.agentOf('ga').calls.length === 1)
+ host.begin('ga')
+ step(host, 'ga', '@Writer 去读构建日志,我先看配置。', 'k0', 'read')
+ await settle(() => host.agentOf('gb').calls.length === 1)
+ host.begin('gb')
+ host.emit('gb', 'tool/call', { callId: 'k1', name: 'read', arguments: '{}' })
+ host.emit('gb', 'tool/result', { callId: 'k1' })
+ host.finish('gb', '日志看完了:缺环境变量 FOO。')
+ await settle(() => true)
+ assert.equal(host.agentOf('ga').calls.length, 1, 'not steered into the running turn')
+ host.emit('ga', 'tool/result', { callId: 'k0' })
+ host.finish('ga', '配置看完了,没问题。')
+ await settle(() => host.agentOf('ga').calls.length === 2)
+ const follow = host.begin('ga')
+ assert.match(text(follow), /Writer finished the work you asked for/)
+ assert.match(text(follow), /Writer: 日志看完了:缺环境变量 FOO。/)
+ host.finish('ga', '缺 FOO,补上就好。')
+ await settle(() => first() !== undefined)
+ assert.deepEqual(first().replies.map(reply => reply.name), ['Chief', 'Writer', 'Chief', 'Chief'])
+})
+
+// #872: a member the user called answers the user; asking the user to confirm does
+// not call the admin in.
+test('a member\'s reply to the user that asks for a confirmation does not call the admin (#872)', async (t) => {
+ const host = await start(t)
+ const first = host.round('c1', host.say('@Writer 把首页标题改成春季上新'))
+ await settle(() => host.agentOf('gb').calls.length === 1)
+ host.begin('gb')
+ host.emit('gb', 'tool/call', { callId: 'k1', name: 'edit', arguments: '{}' })
+ host.emit('gb', 'tool/result', { callId: 'k1' })
+ host.finish('gb', '改好了,标题换成了「春季上新」,需要你确认一下是否满意。')
+ await settle(() => first() !== undefined)
+ assert.deepEqual(host.agentOf('ga').calls, [])
+ assert.deepEqual(first().replies.map(reply => reply.name), ['Writer'])
+})
+
// Parallel fan-in barrier: when Chief calls @Writer @Tester in one message and both go
// past the 15s grace, Writer's early result posts at once without waking Chief, and
// Tester's final result wakes Chief once with both results.
@@ -1420,9 +1463,54 @@ test('a member that only promises to start working without calling a tool gets o
])
})
+// #872: a reply whose opening sounds like a promise but goes on with the answer is
+// the answer; a verb with 过/完/好了 reports done work.
+test('only a reply that is nothing but a promise counts as one (#872)', () => {
+ for (const said of ['收到,我现在开始排查构建日志。', '明白,我先排查一下日志,然后跑测试。', '我现在开始排查', '开工!', "I'll check the logs now.", 'Let me look into it.']) {
+ assert.equal(promisesWork(said), true, said)
+ }
+ for (const said of ['好的,我检查过了,配置没问题。', '好,我分析一下:方案 A 更稳,B 改动太大,建议选 A。', '收到,我来整理结论:1. 接口没变 2. 测试要补。', '好的,我处理好了。', 'OK, let me check: the config already has retries=3, so nothing to change.', '查完了,原因是端口冲突。']) {
+ assert.equal(promisesWork(said), false, said)
+ }
+})
+
+// #872: the opening already was the answer; the member passes on the retry and the
+// group sees it once.
+test('a member that passes on the promise retry is posted once (#872)', async (t) => {
+ const host = await start(t)
+ const first = host.round('c1', host.say('@Writer 方案 A 和 B 哪个好?'))
+ await settle(() => host.agentOf('gb').calls.length === 1)
+ host.begin('gb')
+ host.finish('gb', '好的,我看看。')
+ await settle(() => host.agentOf('gb').calls.length === 2)
+ const retry = host.begin('gb')
+ assert.match(text(retry), /reply \[PASS\]; it stays posted/)
+ host.finish('gb', '[PASS]')
+ await settle(() => first() !== undefined)
+ assert.deepEqual(first().replies.map(reply => [reply.name, reply.text]), [['Writer', '好的,我看看。']])
+})
+
+// #872: a retried promise that a late turn passes on still tells the member that asked
+// the work is done, as a result that went out as a step line does.
+test('a late member that passes on the promise retry still hands the work back (#872)', async (t) => {
+ const host = await start(t)
+ // A call the member reads after the round moved on: no round waits for this turn.
+ host.agentOf('gb').followup({ content: [{ type: 'text', text: '[Group chat "Ops" · Chief mentioned you]\n看一下文档' }], source: { kind: 'bot', role: 'room', roomId: 'r1', exchangeId: 'x1', askedBy: 'a' } })
+ host.begin('gb')
+ host.finish('gb', '收到,我去看看文档。')
+ await settle(() => host.agentOf('gb').calls.length === 2 && host.agentOf('r1').calls.length === 1)
+ assert.equal(host.takePost().source.progress, true, 'the opening goes to the group')
+ host.begin('gb')
+ host.finish('gb', '[PASS]')
+ await settle(() => host.agentOf('r1').calls.length === 1)
+ const post = host.takePost()
+ assert.deepEqual([post.source.done, post.source.askedBy], [true, 'a'])
+})
+
// Progress-based loop guard: consecutive 0-tool ack/repetitive relays pause after 6
// turns and park the next call in room.paused, whereas tool calls reset the counter.
-test('consecutive 0-tool ack ping-pong relays pause after 6 turns and resume when the user writes', async (t) => {
+// #872: the parked calls wait for the user, not for the next round of any kind.
+test('consecutive 0-tool ack ping-pong relays pause after 6 turns and go on only when the user writes', async (t) => {
const host = await start(t)
const first = host.round('c1', host.say('@Chief 开始'))
await settle(() => host.agentOf('ga').calls.length === 1)
@@ -1441,10 +1529,27 @@ test('consecutive 0-tool ack ping-pong relays pause after 6 turns and resume whe
await settle(() => first() !== undefined)
const pausedReplies = first().replies.filter(reply => reply.kind === 'paused')
assert.equal(pausedReplies.length, 1)
- assert.deepEqual(pausedReplies[0].names, ['Writer'])
- const saved = JSON.parse(readFileSync(join(host.home, 'state.json'), 'utf8')).rooms.r1
- assert.equal(saved.paused?.length, 1)
- assert.equal(saved.paused[0].id, 'b')
+ assert.deepEqual([pausedReplies[0].idle, pausedReplies[0].botId, pausedReplies[0].names], [true, 'a', ['Writer']])
+ const saved = () => JSON.parse(readFileSync(join(host.home, 'state.json'), 'utf8')).rooms.r1
+ assert.deepEqual(saved().paused.map(entry => [entry.id, entry.idle]), [['b', true]])
+ assert.match(await host.tool('read_group_chat', { group: 'Ops' }, 'a'),
+ /\[Paused: Chief and Writer went back and forth 6 times without progress \(no tool used, only thanks or repeats\)\. The calls to @Writer wait until the user writes here; do not call them again\.\]/)
+
+ // A Bot's quiet late result opens a round, which leaves the parked call alone.
+ const second = host.round('c2', { content: [{ type: 'text', text: '[Group post from Tester]\n测试跑完了' }], source: { kind: 'bot', form: 'relay', role: 'post', exchangeId: 'x2', senderSessionId: 'c', senderName: 'Tester', roomId: 'r1', late: true, quiet: true } })
+ await settle(() => second() !== undefined)
+ assert.equal(host.agentOf('gb').calls.length, 3)
+ assert.equal(saved().paused.length, 1)
+
+ // The user's message brings the parked call back with the admin.
+ const third = host.round('c3', host.say('好了,说正事'))
+ await settle(() => host.agentOf('gb').calls.length === 4 && host.agentOf('ga').calls.length === 5)
+ assert.match(text(host.begin('gb')), /Chief mentioned you/)
+ host.finish('gb', '[PASS]')
+ host.begin('ga')
+ host.finish('ga', '[PASS]')
+ await settle(() => third() !== undefined)
+ assert.equal(saved().paused, undefined)
})
// #701: when a group member spawns a DSH subagent and ends its own turn, the member
diff --git a/ds-bot/test/rounds.test.js b/ds-bot/test/rounds.test.js
index 34f38935..9fe8ae1b 100644
--- a/ds-bot/test/rounds.test.js
+++ b/ds-bot/test/rounds.test.js
@@ -704,6 +704,36 @@ test('calls parked under the old relay limit run in the group\'s next round', as
assert.equal(saved.paused, undefined)
})
+// #872: calls the idle guard parked wait for the user. A round a Bot's post opens
+// leaves them; the user's message that joins that round brings them in.
+test('calls the idle guard parked wait for the user\'s message, also one that joins a running round', async (t) => {
+ const { call, emit, compose, relay, answer, stop, sent, rt } = start()
+ t.after(stop)
+ const room = await team(call, sent)
+ await call('update-room', { id: room.id, mode: 'admin' })
+ const chief = rt.state.mainBotIds[0]
+ const writer = Object.values(rt.state.bots).find(bot => bot.name === 'Writer')
+ const state = () => rt.state.rooms[room.id]
+ state().paused = [{ id: writer.id, name: 'Writer', note: 'Chief mentioned you', by: chief, idle: true }]
+ await rt.save()
+
+ await emit(room.id, { type: 'user/message', data: { source: { kind: 'bot', form: 'relay', role: 'post', exchangeId: 'p1', senderSessionId: writer.id, senderName: 'Writer', roomId: room.id }, content: [{ type: 'text', text: '[Group post from Writer]\n@Chief the draft is up' }] } })
+ const running = relay(room.id, 'relay')
+ const first = await turnFor(sent)
+ assert.equal(first.sessionId, state().sessions[chief])
+ assert.equal(state().paused.length, 1, 'a Bot\'s post does not bring the parked call in')
+
+ await compose(room.id, 'Go on, both of you')
+ await answer(first.sessionId, first.message.source.exchangeId, 'Thanks.', 1)
+ const parked = await waitFor(() => sent.find(entry => entry !== first && entry.message.source.role === 'room' && /Chief mentioned you/.test(entry.message.content[0].text)))
+ assert.ok(parked, 'the user\'s message brings the parked call in')
+ assert.equal(state().paused, undefined)
+ const again = await waitFor(() => sent.find(entry => entry !== first && entry !== parked && entry.message.source.role === 'room'))
+ await answer(parked.sessionId, parked.message.source.exchangeId, 'On it.', 1)
+ await answer(again.sessionId, again.message.source.exchangeId, 'Fine.', 2)
+ await running
+})
+
test('a member the reply timeout cut short is told to the group, not left as silence', async (t) => {
const { call, emit, userMessage, relay, stop, sent, rt } = start()
t.after(stop)
diff --git a/ds-bot/test/tool-cells.test.js b/ds-bot/test/tool-cells.test.js
index eeb2f468..88ccf350 100644
--- a/ds-bot/test/tool-cells.test.js
+++ b/ds-bot/test/tool-cells.test.js
@@ -182,6 +182,15 @@ test('an old paused round shows the pause as a plain line', () => {
assert.equal(find(out, node => node.type === 'button'), undefined)
})
+// #872: Bots that went back and forth without progress paused; the line names both
+// and says what lets them go on.
+test('a round the idle guard paused names the Bots and how they go on', () => {
+ const replies = [{ kind: 'paused', idle: true, botId: 'chief', name: 'Chief', names: ['Writer'], count: 6, limit: 6, time: at(0, 14, 5) }]
+ const out = show(call('group_relay', 'direct', { content: { replies } }), { sessionId: 'room' })
+ const events = findAll(out, node => node.props?.className === 'bt-event').map(text)
+ assert.deepEqual(events, ['Chief and Writer went back and forth 6 times without progress and paused. Write here to go on'])
+})
+
// The admin was alone with the user's message and passed: the round shows the
// notice, so the user sees why nothing was answered.
test('a group whose admin passed alone shows the notice', () => {