You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
feat: char-level degenerate-run valve for the outgoing view (session-death abort loop, real incident) | 出站视图的字符级退化阀门(会话死亡 abort 循环,真实事故) #517
Real incident (observed in the wild, adapter-side record): a 5968-char thinking block ended in 4655 consecutive 「【」 codepoints, escalating over turns until the turn aborted.
The failure is self-sustaining because of how hosts replay thinking:
pi (and likely other hosts) sends prior assistant thinking back to the provider every request (reasoning_content, or plain text under requiresThinkingAsText).
An aborted turn's partial message persists in the session log.
The degenerated tail therefore rides along every later prompt; the model sees its own previous output ending in thousands of repeated characters — a continuation bias that re-triggers the same degeneration, aborting the next turn too.
The session dies in an abort loop with no recovery path (user cannot edit persisted thinking).
repetitionGuard (#308) breaks byte-identical tool-call loops. Here the attractor is inside the generated text/thinking itself — no tool call involved, so nothing existing catches it.
A final pass over the outgoing view (persisted history is never modified):
Collapse single-codepoint runs with length ≥ minRun in assistant text/thinking, replacing the run with a short marker shorter than any detectable run.
Threshold: default 200 codepoints. Observed legitimate runs (markdown hrules, dotted leaders, comment banners) stay ≤ ~60 even during pre-degeneration drift; the incident run was 4655 — 200 gives wide margin. Values below 8 are raised to 8 (the marker must stay shorter than any detectable run).
Position-based self-limiting: while the degenerated message is the most recent assistant turn, append a one-shot recovery notice; once the model produces a fresh turn, the old message stops being last and the notice disappears — no persistent state, no accumulation (the feat: protectedLatestTools — protect only the latest instance of a tool #223 lesson).
Kill-switch config (enabled: false), never fails the session on internal errors.
Pre-degeneration drift observed max ~60 codepoints before the catastrophic run — a 200 threshold is far from legitimate content.
The aborted-loop dynamic was reproduced locally: replaying a session with a persisted 4655×「【」 tail aborted again on the next request; with the collapse pass, the same session recovered in one turn.
Happy to submit a PR implementing this as an opt-out pass in the outgoing-view pipeline (reference implementation exists and runs in production in our adapter, ~290 lines with tests). If you prefer this to live in billion-context instead (per #513), tell me and I will file there.
所以正确落点是 ranxianglei/billion-context(kernel 目录)。你在 issue 里说「tell me and I will file there」——推荐方案 A:你直接在 billion-context 立 issue(正文+参考实现链接一起带过去),我们在那边接管 triage 与 review。跨仓库提交需要你明确批准,你自己立最合规。若希望由我们代为迁移,请在评论里明确批一句,我们再动手。
Activity
FORK-NOTES: track degeneration valve upstream issue ranxianglei#517
FORK-NOTES: track degeneration valve upstream issue ranxianglei#517
ranxianglei commentedon Oct 23, 2026
查重: 不重复。 open+closed 全量检索 degenerate / repetition / abort / repetitionGuard / outgoing-view 等关键词,无相关条目。
标签: pi, scope/kernel, p1(功能请求不打 bug;p1 按 owner 修订 2026-10-19「会话无法恢复类」——此类会话一旦死亡无自恢复路径)。
先说落点:这个功能应该落 billion-context,不是本仓库
按 #513(你的 2026-10-09 指示),内核代码已并入 billion-context、版本保持独立。今天核实了两点:
kernel/源码树(与本仓库同一模块图),且带独立release-kernel.yml发版管线。所以正确落点是 ranxianglei/billion-context(kernel 目录)。你在 issue 里说「tell me and I will file there」——推荐方案 A:你直接在 billion-context 立 issue(正文+参考实现链接一起带过去),我们在那边接管 triage 与 review。跨仓库提交需要你明确批准,你自己立最合规。若希望由我们代为迁移,请在评论里明确批一句,我们再动手。
一处引用勘误:你说的「#308 repetitionGuard」在本仓库源码里不存在(grep 0 命中);这里的 #308 实际是 release v0.0.74 PR。那个 guard 应是适配器侧(pi)的编号,到 billion-context 立项时请核对一下引用号。
技术审核(功能类三步)
合理性:真实现场+本地复现了循环动力学(回放→再 abort;加折叠 pass→一轮恢复),问题为真。自持链条成立:宿主每轮回放 thinking → aborted 残缺消息持久化 → 退化尾巴随每个 prompt 出行 → 继续偏置再触发退化。现有守卫只断 tool-call 循环,接不住生成文本内部的吸引子。
系统设计:契合内核纯管线架构——内核本就管理可见上下文(hide/render-refs 节点),在出站视图加一道 opt-out 防御 pass 是自然延伸;确定性折叠意味着首次折叠后字节稳定,不会持续击穿 prefix cache(内核对此极敏感,你的机制天然满足);位置自限(仅当退化消息是最近一条 assistant 轮时附提示)对齐 #223 的教训——apply-time 从当前状态派生,不存持久标志。
耦合/边界:view-only、不动持久化历史,不破坏 lossless round-trip(内核契约 §7.3-4),不改 message-id/ref 语义;kill-switch + never-fail 符合安全网哲学。三个实现时需明确的边界点:
<acp>ref tag 或 mNNNNN 编号(render-refs 之后应用,或 tag-aware);八问(按选项列第 3/5 问)
enabled(默认 true,kill-switch)+ 阈值/minRun(默认 200,下限 8);默认值即安全值,无需迁移。决策请求:确认方案 A(你在 billion-context 立项、我们在那边接管)?若要我们代提,请明确批准。本 issue 先保持打开等你的决定。
SeniorHan commentedon Oct 24, 2026
已按方案 A 迁移:ranxianglei/billion-context#4476(三边界点答复已内联,引用勘误已修正)。感谢审核,请在那边接管 triage。