DSH / Atlas
2026-10-28implementedarchitecture

`<fallback>` alternatives replaced the IM capability layer

`<fallback>` 备选内容取代了 IM 能力层

The vendored IM runtime answered "can this platform do X in this chat" before doing it. `plugin-im-core` owned a capability layer — `ChatFacts`, a per-bot `FactCache`, `LearnedFact`, `Support`, the `element.*` / `message.*` / `limit.*` key vocabulary, `evaluateCapabilities` and `mergeCapabilities` — that every adapter fed from three sides: a mode's declared operations, the adapter hooks, and a per-chat probe. The Lar

Source compatibility: Chinese title uses a compatible non-canonical header

English

Problem

The vendored IM runtime answered "can this platform do X in this chat" before doing it. plugin-im-core owned a capability layer — ChatFacts, a per-bot FactCache, LearnedFact, Support, the element.* / message.* / limit.* key vocabulary, evaluateCapabilities and mergeCapabilities — that every adapter fed from three sides: a mode's declared operations, the adapter hooks, and a per-chat probe. The Lark adapter added a getChat probe plus five learned facts, and the QQ adapter published passive-reply windows through the same channel.

Every consumer then had to branch on the answer. @deepseek-ai/dsh-experimental-im exposed caps on the message event, on the service and on each turn's output IO; the summary and trace renderers asked five or six keys before deciding what to publish; a stop button existed only where element.button.action and interaction.button both answered native. The layer was also wrong in both directions: unknown had to mean "attempt it" for operations and "do not render it" for elements, so a probe that could not read a chat silently downgraded work, and a probe that answered unknown made the pipeline learn the same thing again from the failure. Nothing about a chat is knowable before the platform answers.

Decision

The capability layer is deleted, not deprecated, and content itself carries the alternatives.

@deepseek-ai/satori-element gains the <fallback> element: each direct child is one ranked candidate, and a JSX fragment counts as one candidate, so <fallback><title>…</title><h3>…</h3><text>…</text></fallback> names three spellings of one message. normalize rewrites each candidate into an internal <case> normalized as content of the element the <fallback> stands in, which lets a fallback of phrasing content join the surrounding inline run. RenderEngine renders the first candidate whose whole subtree its registry renders natively — tag registered, variants declared, structural children standing — and otherwise the last candidate with the usual lowering; a nested fallback counts as native when one of its own candidates is. The choice lands in RenderReport.fallbacks and degradationScore charges a later candidate, so a mode that renders the author's first choice wins the per-publication mode resolution. Nothing in the engine consults per-chat state.

Removed with it: capabilities.ts, Bot.supports / support / capabilities, Adapter.facts, Mode.operations, HandlerOptions.available, PlatformError.facts, RenderContext.caps / supports, the Lark facts.ts chat probe and its learned facts, and the QQ passive-window facts. LimitKey moved to mode.ts and gained limit.delete.window; what a mode can do is now a registry fact (does it register the tag and declare the variant), an adapter-hook fact (editPayload, deletePart, streamDriver) or a declared limit. Bot.edit and Bot.delete decide from those, and a refusal is the classified PlatformError the platform answered — never a prediction.

MessageStream.abort() now reports whether a recall removed the published message, which is the one question a renderer cannot answer from its own content.

The IM consumers stop querying capabilities. ImOutputIO, ImMessageEvent and ImApi lost caps; the summary renderer resolves its plan from the strategy of the stream it opened (patch / edit publish provisional content, final / append do not) and writes its stop control as a <fallback> of an action button and a reply /stop line; the trace renderer writes each reasoning and tool item as a <fallback> of a collapsible panel and a one-line summary, and leaves the element budget to the mode that has one.

Alternatives considered

Keep the layer and add <fallback> beside it. Two mechanisms would answer the same question and disagree: a renderer could ask whether a mode supports <details> while the mode's own registry is the only thing that decides it.

Keep a small synchronous capability description for the consumers. The renderers only need three answers (which stream strategy was opened, whether a recall succeeded, whether a button is actionable), and each of those is already reported by the event, the call, or the content itself. A description of "what this platform can do" would reintroduce the guessing that made the layer wrong.

Probe the chat lazily and cache the answers per chat. TTLs move the guess, they do not remove it: a mute, a whitelist refusal or an edit policy can change between two sends, and a stale false then blocks a working call.

Consequences

A refusal costs one round trip and surfaces as an error, where the layer used to pre-empt it. Content that must degrade gracefully now says so in its own tree, which puts the decision in the renderer that knows what it is rendering rather than in a key table. Modes own their element budgets in assemble and check; the trace renderer no longer pre-folds panels. Adapters no longer cache anything about a chat, so a bot needs no probe, no TTL and no invalidation, and the QQ passive bookkeeping answers only the one question the stream driver asks (remaining()).

The corpus gained a fallback case, and conformance's text-conservation check ignores a <fallback>: which candidate renders is a property of the mode, so no single text is conserved. What was given up is any way to answer "can this chat do X" without trying, which the QQ and Lark 230075 paths previously used to choose a buffered stream up front; they now rely on the classified limit error to recall and resend.

中文

Problem

内置的 IM 运行时在做事之前先回答「这个平台在这个聊天里能不能做 X」。plugin-im-core 拥有一整层能力评估——ChatFacts、按 bot 的 FactCache、LearnedFact、Support、element.* / message.* / limit.* 键词汇、evaluateCapabilities 与 mergeCapabilities——每个适配器都从三个方向喂它:模式声明的操作表、适配器钩子,以及按聊天探测的结果。飞书适配器额外加了 getChat 探测和五条学习到的事实,QQ 适配器则把被动回复窗口也从同一条通道发布出去。

于是每个消费方都得对答案分支。@deepseek-ai/dsh-experimental-im 在消息事件、服务和每一轮输出的 IO 上都暴露 caps;summary 与 trace 渲染器发布前要问五六个键;只有 element.button.action 与 interaction.button 同时答 native 的地方才有停止按钮。这层评估在两个方向上都错:unknown 对操作必须表示「照做」,对元素却必须表示「不要渲染」,于是一个读不到聊天的探测会悄悄降级工作,而一个答 unknown 的探测又让管线从失败里再学一遍同样的事。平台回答之前,关于聊天的一切本来就无从得知。

Decision

能力层被删除而不是弃用,改由内容本身携带备选。

@deepseek-ai/satori-element 新增 <fallback> 元素:每个直接子元素是一个有排序的候选,JSX fragment 整体算一个候选,所以 <fallback><title>…</title><h3>…</h3><text>…</text></fallback> 是一条消息的三种写法。normalize 把每个候选改写成内部的 <case>,按 <fallback> 所在元素的内容模型归一化,因此行内内容的 fallback 可以并入周围的行内流。RenderEngine 渲染整棵子树都能被其注册表原生渲染的第一个候选(标签已注册、变体已声明、结构子节点成立),否则按常规降级渲染最后一个候选;嵌套 fallback 只要自身某个候选可原生渲染就算可原生渲染。选择结果写入 RenderReport.fallbacks,degradationScore 会为更靠后的候选计费,因此能渲染作者首选的那个模式会赢得每次发布时的模式解析。引擎中没有任何一处查询按聊天的状态。

随之移除的有:capabilities.ts、Bot.supports / support / capabilities、Adapter.facts、Mode.operations、HandlerOptions.available、PlatformError.facts、RenderContext.caps / supports、飞书的 facts.ts 聊天探测及其学习到的事实,以及 QQ 的被动窗口事实。LimitKey 移到 mode.ts 并新增 limit.delete.window;一个模式能做什么,如今是注册表事实(是否注册该标签、是否声明该变体)、适配器钩子事实(editPayload、deletePart、streamDriver)或声明的上限。Bot.edit 与 Bot.delete 据此判断,拒绝就是平台给出的、被分类过的 PlatformError,而不是预测。

MessageStream.abort() 现在会回报撤回是否真的删掉了已发布的消息——这是渲染器无法从自己的内容里得出的唯一问题。

IM 的消费方不再查询能力。ImOutputIO、ImMessageEvent 与 ImApi 去掉了 caps;summary 渲染器根据自己打开的流的策略(patch / edit 会发布临时内容,final / append 不会)算出渲染计划,并把停止控件写成一个由操作按钮与「回复 /stop 停止」一行组成的 <fallback>;trace 渲染器把每段思考与每次工具调用写成一个由可折叠面板与单行摘要组成的 <fallback>,把元素预算留给真正有预算的模式。

Alternatives considered

保留这层能力评估,另加 <fallback>。 两套机制会回答同一个问题并互相矛盾:渲染器可以问某个模式是否支持 <details>,而真正决定这一点的只有该模式自己的注册表。

为消费方保留一份精简的同步能力描述。 渲染器只需要三个答案(打开的是哪种流策略、撤回是否成功、按钮是否可点),每一个都已经由事件、调用本身或内容本身给出。「这个平台能做什么」的描述会重新引入让这层评估出错的猜测。

按聊天惰性探测并缓存答案。 TTL 只是把猜测挪了位置,并没有消除它:禁言、白名单拒绝或编辑策略都可能在两次发送之间变化,而过期的 false 会挡住一次本来能成功的调用。

Consequences

一次拒绝要付一个往返并作为错误浮出水面,而以前这层评估会提前拦下它。需要优雅降级的内容现在在自己的内容树里说明,于是决定权落在清楚自己在渲染什么的渲染器上,而不是一张键表里。各模式在 assemble 与 check 中自己负责元素预算;trace 渲染器不再预先折叠面板。适配器不再缓存任何关于聊天的东西,因此 bot 不需要探测、TTL 和失效处理,QQ 的被动记账只回答流驱动问的那一个问题(remaining())。

语料新增了 fallback 用例,而 conformance 的文本保全检查会跳过 <fallback>:渲染哪个候选是模式的属性,因此没有哪段文本是被普遍保全的。被放弃的是「不试就知道这个聊天能不能做 X」——QQ 与飞书 230075 的路径以前靠它提前选择缓冲式流,现在依靠被分类为 limit 的错误撤回并重发。