Skip to content

feat(im): add ambient mention mode for group chats#300

Merged
deepcoldy merged 2 commits into
deepcoldy:masterfrom
SBeator:feat/ambient-mention-mode
Jun 28, 2026
Merged

feat(im): add ambient mention mode for group chats#300
deepcoldy merged 2 commits into
deepcoldy:masterfrom
SBeator:feat/ambient-mention-mode

Conversation

@SBeator

@SBeator SBeator commented Jun 25, 2026

Copy link
Copy Markdown
Contributor

中文说明

背景

这个改动主要解决「一个群里有多个 AI,但默认聊天对象通常是主 AI」时的误响应问题。

现在如果主 AI 配置成 never(不需要 @ 也响应),它会把群里的已经明确 at 其他机器人的消息都当成自己该接的消息。这个模式解决这个问题:默认情况下有单主 AI 的群,这个群里如果临时需要多个 AI 协作时,避免主 AI 接收大量噪声的问题:用户或者某个 AI 明明已经 @ 了另一个 AI / 成员,主 AI 仍然会跟着响应,导致委托关系不清晰,也会打断 AI 之间的接力协作。

新增模式

新增第 4 种群聊 @ 策略:ambient

它的语义是:默认像 never 一样,不需要 @ 也可以响应;但如果这条消息明确 @ 了其他具体成员(人或 bot),并且没有 @ 当前 bot,则当前 bot 主动让位、保持沉默。

具体行为:

  • 没有 @ 任何人:响应
  • @ 当前 bot:响应
  • @ 其他具体成员、但没 @ 当前 bot:不响应,让位
  • @ 所有人:不视为交给某个具体成员,仍可响应
  • 原有 never 语义不变,仍然是无条件免 @ 响应

改动范围

  • 配置类型与解析支持 ambient
  • dashboard 默认设置下拉增加新选项与中英文文案
  • daemon 路由门控在 3 处接入 mentionsAnotherMember() 判定
  • 新增/补充单测覆盖 ambient 的核心路由行为

验证

  • pnpm build
  • pnpm vitest run test/event-dispatcher.test.ts test/card-prefs-store.test.ts test/bot-registry-grant.test.ts

本地定向验证 162 条测试通过。


Summary

This adds a new ambient regular group mention mode alongside the existing always, topic, and never modes.

ambient is intended for groups with a default primary AI where most unmentioned messages should go to that primary AI, while still allowing multi-agent collaboration by explicitly @mentioning another AI or person. In that case, the primary AI should yield instead of also responding.

Behavior:

  • unmentioned message -> answer, like never
  • message @mentions this bot -> answer
  • message @mentions another specific member but not this bot -> stay quiet
  • @all is not treated as a redirect, so it still answers
  • existing never behavior is unchanged and remains unconditional

Why

In a group with multiple AI bots, the current never mode works well for making a primary AI respond by default. But during AI-to-AI collaboration, users often explicitly @mention another AI. Today the primary AI still responds because never treats every non-self-mentioned group message as eligible. That creates noisy duplicate responses and makes delegation harder.

ambient preserves the default-oncall style experience while adding a small redirect carve-out when the user has clearly addressed someone else.

Changes

  • Add ambient to bot config parsing and card preference persistence.
  • Add mentionsAnotherMember() and apply it to the top-level gate and shared-topic fold-back paths.
  • Add dashboard dropdown support and zh/en labels.
  • Add focused tests for the mention predicate and ambient routing behavior.

Validation

  • pnpm build
  • pnpm vitest run test/event-dispatcher.test.ts test/card-prefs-store.test.ts test/bot-registry-grant.test.ts

Local validation passed with 162 focused tests.

@SBeator SBeator requested a review from deepcoldy as a code owner June 25, 2026 02:34
@SBeator SBeator force-pushed the feat/ambient-mention-mode branch from a0670b7 to 6460c4d Compare June 28, 2026 01:00
在 always/topic/never 之外新增第 4 档 ambient:免 @ 也应答,但当消息
@ 了其他具体成员(人或 bot)而未 @ 本 bot 时让位(@所有人不算)。复用
mentionsAnotherMember 判定;never 保持原有无条件语义不变(非破坏性)。
全链路接好:路由门 3 处 + 配置读写 + dashboard 下拉 + 中英文案 + 单测。

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@SBeator SBeator force-pushed the feat/ambient-mention-mode branch from 6460c4d to 00dfb90 Compare June 28, 2026 16:44
mentionsAnotherMember 的 predicate 已有单测;本提交补全走完整 dispatch 流程的
集成用例,证明「@别人则让位」carve-out 接到了所有会放宽 @ 要求的决策点:
顶层 gate、shared-topic seeding、shared alias fold-back。每个 gate 都有
正例(ambient 照常回)+ carve-out(@ 别人则静默让位);@所有人 不算让位仍回。
经变异测试验证:把 mentionsAnotherMember 强制 return false 后,三条 carve-out
用例如期 fail,正例不受影响——确认用例非空跑。

@deepcoldy deepcoldy left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code-owner 审批通过。

经两轮 review(Claude)+ 一轮独立二次 review(Codex):

  • 核心修复已就位:mentionsAnotherMember 使用 mentionOpenId(m),兼容 WS 对象形态与 REST cli_ 字符串形态;
  • 测试覆盖完整:predicate 单测 + 字符串形态回归 + ambient 三处免@决策点(顶层 gate / shared seeding / alias fold-back)端到端 gating 用例(含让位 carve-out,经变异测试验证非空跑);
  • tsc 净、event-dispatcher 167 测试全过、MERGEABLE。

@deepcoldy deepcoldy merged commit 4468217 into deepcoldy:master Jun 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants