Skip to content

The agent that grows with you

fix(bot-mode): a distant stop word never releases the member it addresses

teknium1ae417cf099b4
diff --git a/apps/desktop/src/plugins/hermes-bots/group-rounds.test.ts b/apps/desktop/src/plugins/hermes-bots/group-rounds.test.ts
index 3819d7e0563..fc45d145f3a 100644
--- a/apps/desktop/src/plugins/hermes-bots/group-rounds.test.ts
+++ b/apps/desktop/src/plugins/hermes-bots/group-rounds.test.ts
@@ -865,13 +865,28 @@ describe('member holds (#93129)', () => {
const action = rounds.classifyGroupHoldDirective(text, ['conn::impl'], false)
expect([...action.hold]).toEqual([])
- expect([...action.release]).toEqual(['conn::impl'])
+ // Ambiguous, so neutral: the prose reading must not wake a held member either.
+ expect([...action.release]).toEqual([])
}
// Keys are roster keys, not handles: proximity must still hold on the raw @token.
expect([...rounds.classifyGroupHoldDirective('@impl please halt', ['conn::impl'], false).hold]).toEqual(['conn::impl'])
})
+ // A genuine stop whose stop word sits 3+ tokens from the mention may miss the
+ // hold, but it must never RELEASE (re-dispatch) the member it tells to stop.
+ it('never releases the addressed member on a distant genuine stop', async () => {
+ const { rounds } = await loadRoom()
+
+ for (const text of ['@impl please just stop now', 'hey @impl could you stop', '@impl, I need you to stop', '@impl you can stop']) {
+ const action = rounds.classifyGroupHoldDirective(text, ['c1::impl'], false)
+
+ expect([...action.release]).toEqual([])
+ }
+
+ expect(rounds.classifyGroupHoldDirective('@all please just stop now', [], true).releaseAll).toBe(false)
+ })
+
// #97740: a room stopped by the user went permanently silent because only
// the literal "@all resume" released the holds; "@all <task>" addresses
// every member and must re-engage them like a direct mention does.
diff --git a/apps/desktop/src/plugins/hermes-bots/group-rounds.ts b/apps/desktop/src/plugins/hermes-bots/group-rounds.ts
index 7a427e87eb9..ab6fded8c31 100644
--- a/apps/desktop/src/plugins/hermes-bots/group-rounds.ts
+++ b/apps/desktop/src/plugins/hermes-bots/group-rounds.ts
@@ -202,11 +202,15 @@ export function rotateGroupSpeakers(members: GroupMember[], round: number) {
* "don't stop @x" therefore also holds, which errs toward the bot staying
* quiet until re-addressed (a wrongly-held bot is one mention away from
* release; a wrongly-running one keeps doing work it was told to stop).
- * A stop word far from every mention is prose, not a directive: "@x go,
- * das ist halt ein Test" and "@x mach mal Pause" address the bot, so
+ * A stop word far from every mention is ambiguous — "@x go, das ist halt
+ * ein Test" and "@x mach mal Pause" are prose that addresses the bot, so
* non-English rooms whose everyday vocabulary overlaps the keyword list
- * are not silently held. A non-stop direct mention releases the mentioned
- * members — the user addressing a bot directly overrides its hold — and
+ * are not silently held — but "@x please just stop now" is a genuine stop,
+ * so the message is NEUTRAL: it neither holds nor releases. A missed hold
+ * is one adjacent "stop @x" away from repair; re-dispatching a bot the user
+ * just told to stop is the one flip this classifier must never make.
+ * A non-stop direct mention releases the mentioned members — the user
+ * addressing a bot directly overrides its hold — and
* addressing the whole room (@all / @everyone) without a stop word is the
* same intent for every member (#97740): "@all <task>" wakes a stopped
* room without the user having to know the literal "resume" incantation. */
@@ -217,9 +221,9 @@ export function classifyGroupHoldDirective(
) {
const value = String(text || '')
const mentioned = [...(mentionedKeys || [])]
- const stop = stopWordNearMention(value)
+ const stop = stopWordPlacement(value)
- if (stop) {
+ if (stop === 'adjacent') {
// "@all stop" holds every member — symmetric with "@all resume".
return {
hold: mentioned,
@@ -232,20 +236,22 @@ export function classifyGroupHoldDirective(
return {
hold: [],
holdAll: false,
- release: mentioned,
- releaseAll: Boolean(everyone)
+ release: stop === 'distant' ? [] : mentioned,
+ releaseAll: stop === null && Boolean(everyone)
}
}
-/** #103893: true when a stop/halt/pause token sits within two words of ANY
- * @token in the message. Proximity is measured against the raw @tokens,
+/** #103893: where the stop/halt/pause tokens sit relative to the @tokens —
+ * `adjacent` when one is within two words of ANY mention, `distant` when
+ * the message carries a stop word but none that close, null without one.
+ * Proximity is measured against the raw @tokens,
* not the resolved member keys the caller passes (those are roster keys
* such as `<connectionId>::<name>`, and a mention resolves through titles
* and friendly names too, so the @token text rarely equals the key). The
* ≤2 window is fitted to observed directive/filler pairs ("@x please
* halt" = 2, "@x go, das ist halt ein Test" = 4); widen only with measured
* cases, never by guessing. */
-function stopWordNearMention(value: string) {
+function stopWordPlacement(value: string): 'adjacent' | 'distant' | null {
const tokens = value.toLowerCase().match(/@[\p{L}\p{N}._-]+|[\p{L}\p{N}_-]+/gu) || []
const mentionAt: number[] = []
const stopAt: number[] = []
@@ -258,7 +264,11 @@ function stopWordNearMention(value: string) {
}
})
- return stopAt.some(stop => mentionAt.some(mention => Math.abs(stop - mention) <= 2))
+ if (stopAt.some(stop => mentionAt.some(mention => Math.abs(stop - mention) <= 2))) {
+ return 'adjacent'
+ }
+
+ return stopAt.length ? 'distant' : null
}
/** What `parseGroupChatMentions` reports for one room message. */
diff --git a/website/docs/user-guide/bot-mode.md b/website/docs/user-guide/bot-mode.md
index 1744efe3e7f..ca17f5979d6 100644
--- a/website/docs/user-guide/bot-mode.md
+++ b/website/docs/user-guide/bot-mode.md
@@ -99,8 +99,10 @@ resumed: @mention a held member, or address the whole room (`@all …` /
`@everyone …`, any wording) to release everyone — `@all resume` is not a
required incantation. `stop`, `halt` or `pause` holds a member only when the
word sits next to its @mention (`stop @bot`, `@bot please pause`); the same word
-elsewhere in the sentence is ordinary prose, so a German `halt` no longer
-silences the bot it was sent to. A quiet room watches timed-out members for another 21 minutes after the
+elsewhere in the sentence is read as ordinary prose, so a German `halt` no longer
+silences the bot it was sent to — but such a message does not release a held
+member either (`@bot please just stop now` never wakes it; repeat the stop next
+to the mention to hold it). A quiet room watches timed-out members for another 21 minutes after the
foreground wait ends; this observation window does not extend the turn itself.
Unresolved member failures remain visible in the collapsed Activity summary after
the room settles — including a turn the member's backend itself failed (bad