Skip to content

fix(chat): tell the sender when an @agent mention can't delegate - #595

Open
asteroida123 wants to merge 1 commit into
xintaofei:mainfrom
asteroida123:fix/agent-mention-delegation-hint
Open

fix(chat): tell the sender when an @agent mention can't delegate#595
asteroida123 wants to merge 1 commit into
xintaofei:mainfrom
asteroida123:fix/agent-mention-delegation-hint

Conversation

@asteroida123

Copy link
Copy Markdown
Collaborator

背景

@ 智能体的委托有两个闸门:「多智能体协同」总开关(默认关闭)+ 目标智能体在 Agents 管理中启用。任一关闭时,delegate_to_agent 工具根本不会注入宿主会话,宿主模型就会自己把消息答掉 —— 对发送者来说,@ 就是"无声失效"(相关讨论:#545)。

本 PR 在发送时刻把这件事讲出来,让新手至少知道"为什么没委托、去哪里开":

  • 扫描出站文本块中的 codeg://agent/<type> 路由 URI(用户手打的 @文本 不会误触发)
  • fire-and-forget 查询委托设置 + 智能体列表(模块级 30s 缓存),查询失败静默吞掉,绝不阻塞发送
  • 命中则 toast.warning + 深链按钮:
    • 总开关关闭 → 设置 → 常规 → 多智能体协同
    • 目标被禁用 → 设置 → 智能体(并预选该智能体)

范围边界:本 PR 只覆盖"闸门关闭"这一失败模式。#545 中提出的确定性整轮路由(发送前把提及改写为委托调用)是更大的产品设计问题 —— 涉及混合意图、多提及拆分、steer/队列路径等 —— 留待该 issue 单独讨论。

附带:open_settings_window 支持 general

深链"常规"页此前不通:桌面端 resolve_settings_route 与 Web 端 handler 都没有 "general" 映射(会回退到外观页)。三处各补一行(桌面 / Web / TS SettingsSection union),行为纯增量。

i18n

3 键 × 10 语言。提示中的入口名称(常规 / 智能体 / 多智能体协同 等)逐一取自各语言现有 UI 译名,保证提示里的路径与用户实际看到的界面一致。

测试

  • 新增 agent-mention-hint.test.ts(10 例):URI 提取与去重、自由文本 @ 不误报、仅扫描文本块、四种闸门组合、无提及时不请求后端
  • pnpm vitest run 全量 5183 通过;tsc --noEmit 干净;eslint 干净
  • cargo check 桌面 + server 两模式通过;cargo clippy(server lib / desktop all-targets)-D warnings 通过

An @-mention only routes work to another agent when BOTH gates are
open: multi-agent delegation is enabled in settings, and the target
agent is enabled in Agents management. With a gate closed,
delegate_to_agent was never injected into the host session, so the
host model just answers the mention itself and the sender never
learns why — @ looks silently broken (xintaofei#545).

Warn at send time instead. The composer scans the outgoing text
blocks for codeg://agent/<type> routing URIs (free-standing @prose
never triggers), then best-effort + fire-and-forget classifies the
mentions against the delegation settings and the agent list (30s
module-level cache). A blocked mention raises a toast with a deep
link: Settings → General → Multi-Agent Collaboration when delegation
is off, Settings → Agents (preselected on the agent) when the target
is disabled. A lookup failure is swallowed — the hint must never
block the send.

Deep-linking General required threading a "general" section through
open_settings_window: the desktop route resolver and the web handler
both fell back to appearance; the TS SettingsSection union gains it
too.

i18n: 3 keys x 10 locales; entry names are lifted from each locale's
own UI labels so the path in the hint matches what the user sees.

Related to xintaofei#545 — this covers only the "gate closed" failure mode;
deterministic mention routing as proposed there is a larger design
question left to that discussion.
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.

1 participant