feat(lark): available_bots 超阈值折叠为一行指针 + 措辞统一为「沟通/协作」#400
Open
deepcoldy wants to merge 2 commits into
Open
Conversation
首条 prompt 里的 `<available_bots>` 块在协作 bot 较多时会白背一长串 open_id, 而多数话题其实是单干。改为阈值折叠: - unmentioned peers ≤ 3:照旧内联全名单(含 open_id,交棒/协作零 round-trip) - > 3:折叠成一行,只列名字做感知,open_id 转为按需 `botmux bots list`, 并加 count="N" 属性。仍是「有其它 mentionable bot 才出现 + 仅首条」。 同时把 --mention 相关 hint 的窄口径「接力干活/交棒」统一成「沟通/协作」—— --mention 的物理事实适用于任何跨 bot 收发(问一句/协作/交棒都得 --mention, 否则对方收不到),旧措辞偏窄。zh+en 同步。 改的 key:available_bots.hint、identity.short_routing、identity.mention_must、 identity.mention_when_to、shell.mention_gate;新增 available_bots.hint_collapsed、 available_bots.collapsed_line。(/relay 的「接力到本群」是会话迁移功能,语义不同,未碰。)
回应 PR #400 review: 1. Mir 看不到折叠正文(回归):`summarizeAvailableBots` 只读 `hint` 和 `<bot/>` 子节点,>3 折叠后名字在 tag body 里被丢弃。把纯 prompt 归一化逻辑从 `mir-runner.ts`(import 即跑 main(),不可测)抽到新的 side-effect-free `src/mir-prompt.ts`,并在 `summarizeAvailableBots` 里 decode 并追加非空 正文(内联变体剥掉 `<bot/>` 后为空,no-op);顺手把硬编码的「handoff」 窄口径改成 communicate/collaborate。 2. 折叠分隔符与 t() 的 locale 解析不一致:原来按裸 `locale` 判断, `setDefaultLocale('en')` 且调用方没传 locale 时会输出英文句子却用中文顿号。 改为 `locale ?? getDefaultLocale()` 解析 effective locale 再选分隔符。 3. `identity.mention_partners` 文案过期:仍说 open_id 列在「每条用户消息」里, 但新逻辑是首轮才有、>3 不列 open_id。改成「首轮上下文提示可协作 bot (少含 open_id、多只列名字);open_id 也可 botmux bots list 查」。zh+en 同步。 测试:新增 `test/available-bots-collapse.test.ts`(7 项)——内联/折叠/count、 分隔符按 default locale、Mir 两种形态均 surface 名字、空块缺省。 本文件 + i18n(487) + available-bots + session-manager-scan + mir 邻近套件 = 524 tests 全绿;`pnpm build` 绿。
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.
改了什么
首条 topic prompt 里的
<available_bots>块,在群内可协作 bot 较多时会白背一长串open_id,而多数话题其实是单干——本 PR 做两件事:1. 阈值折叠(
session-manager.ts的块构造)name+open_id),任何跨 bot 消息零 round-tripopen_id转为按需botmux bots list,并新增count="N"属性<mentions>阈值常量
AVAILABLE_BOTS_INLINE_MAX = 3。2. 措辞统一「接力干活/交棒」→「沟通/协作」
--mention的物理事实适用于任何跨 bot 收发(问一句、一起协作、整段交棒都得--mention,否则对方收不到),旧措辞「接力干活/交棒」偏窄。统一为「沟通/协作」,保留--mention物理事实说明。zh + en 同步。改动的 i18n key:
ai.available_bots.hint、ai.identity.short_routing、ai.identity.mention_must、ai.identity.mention_when_to、ai.shell.mention_gate;新增ai.available_bots.hint_collapsed、ai.available_bots.collapsed_line。为什么
<available_bots>与botmux bots list是「快路径 vs 全量查询」两层:块给零 round-trip 的预筛(getAvailableBots只放 mentionable)open_id,命令给 capability/larkAppId/role 全量。块本身有独立价值不该删,但多 bot 群的单干话题确实为一长串 open_id 白付费——折叠既保留感知,又把 bulky 的 open_id 列表推迟到按需查。影响面
buildNewTopicPrompt的<available_bots>渲染分支;follow-up 路径(buildFollowUpContent,本来就不带块)与availableBots=undefined的调用方(如待办激活session-manager.ts:1462)行为不变buildNewTopicPrompt),hint 文案由同一 i18n key 出,两族一致测试验证
pnpm build✅buildNewTopicPrompt5 组渲染全对:count="5",locale 分隔符自适应(、vs,)vitest run:available-bots+dashboard-i18n(487) +session-manager-scan= 499 tests 全绿prompt-builder.test.ts隔离下 import 期node:child_processmock 报错——移除本 PR 改动后同样失败,属预存问题(不在 CI baseline,全量套件里通过)渲染示例
≤3(zh,内联):>3(zh,折叠):