feat(im): add ambient mention mode for group chats#300
Merged
Conversation
a0670b7 to
6460c4d
Compare
在 always/topic/never 之外新增第 4 档 ambient:免 @ 也应答,但当消息 @ 了其他具体成员(人或 bot)而未 @ 本 bot 时让位(@所有人不算)。复用 mentionsAnotherMember 判定;never 保持原有无条件语义不变(非破坏性)。 全链路接好:路由门 3 处 + 配置读写 + dashboard 下拉 + 中英文案 + 单测。 Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
6460c4d to
00dfb90
Compare
mentionsAnotherMember 的 predicate 已有单测;本提交补全走完整 dispatch 流程的 集成用例,证明「@别人则让位」carve-out 接到了所有会放宽 @ 要求的决策点: 顶层 gate、shared-topic seeding、shared alias fold-back。每个 gate 都有 正例(ambient 照常回)+ carve-out(@ 别人则静默让位);@所有人 不算让位仍回。 经变异测试验证:把 mentionsAnotherMember 强制 return false 后,三条 carve-out 用例如期 fail,正例不受影响——确认用例非空跑。
deepcoldy
approved these changes
Jun 28, 2026
deepcoldy
left a comment
Owner
There was a problem hiding this comment.
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。
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
中文说明
背景
这个改动主要解决「一个群里有多个 AI,但默认聊天对象通常是主 AI」时的误响应问题。
现在如果主 AI 配置成
never(不需要 @ 也响应),它会把群里的已经明确 at 其他机器人的消息都当成自己该接的消息。这个模式解决这个问题:默认情况下有单主 AI 的群,这个群里如果临时需要多个 AI 协作时,避免主 AI 接收大量噪声的问题:用户或者某个 AI 明明已经@了另一个 AI / 成员,主 AI 仍然会跟着响应,导致委托关系不清晰,也会打断 AI 之间的接力协作。新增模式
新增第 4 种群聊 @ 策略:
ambient。它的语义是:默认像
never一样,不需要 @ 也可以响应;但如果这条消息明确@了其他具体成员(人或 bot),并且没有@当前 bot,则当前 bot 主动让位、保持沉默。具体行为:
never语义不变,仍然是无条件免 @ 响应改动范围
ambientmentionsAnotherMember()判定ambient的核心路由行为验证
pnpm buildpnpm 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
ambientregular group mention mode alongside the existingalways,topic, andnevermodes.ambientis 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:
never@allis not treated as a redirect, so it still answersneverbehavior is unchanged and remains unconditionalWhy
In a group with multiple AI bots, the current
nevermode 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 becausenevertreats every non-self-mentioned group message as eligible. That creates noisy duplicate responses and makes delegation harder.ambientpreserves the default-oncall style experience while adding a small redirect carve-out when the user has clearly addressed someone else.Changes
ambientto bot config parsing and card preference persistence.mentionsAnotherMember()and apply it to the top-level gate and shared-topic fold-back paths.Validation
pnpm buildpnpm vitest run test/event-dispatcher.test.ts test/card-prefs-store.test.ts test/bot-registry-grant.test.tsLocal validation passed with 162 focused tests.