Skip to content

DSH: If the first request of a session originates from a bypass call, compression for the entire session is permanently | DSH: If the first request of a session originates from a bypass call, compress for the entire session is permanently inv | DSH:会话首个… #5656

Closed

Description

@hingheguyun

环境

  • DSH 桌面端 0.2.1-rc.2(Windows 11),宿主 Node 24.14.0
  • billion-context 0.1.212(npm latest 即 0.1.212,无新版本可升)
  • 链路:proxy / engineLane=server,protocol=openai,origin=https://opencode.ai,模型 deepseek-v4.1-flash
  • 配置:promptPack=lean,storage.unified 有效模式 full

现象

一条会话从头到尾一次压缩都没发生:stats.compressionCount=0、blocks=0,调用 compress 必然失败,3 次后进入熔断。

会话 session-1c907be7-e92a-4867-a6f0-1a8988bae641(81 次请求、249 条消息、单次输入峰值 213,339 token、全会话计费输入约 11,900,512 token)中,09:08:54–09:10:36 共 6 次 compress,全部报:

[Compression FAILED: None of the 1 requested range(s) resolved — every ref is unknown to this session, failing endpoints: startId=[stale-ref]. ...
 [diagnostics: session highest allocated ref=m00001 (the ref space is sparse ...), unknown ranges in request=1/1, session history=0 compression(s), 0 block(s)]
 ...
 [COMPRESS CIRCUIT BREAKER: 3 consecutive compress failures in this session — every attempt has failed and further attempts will keep failing. STOP calling compress now ...]

而 nudge 一直在催压缩 m00005–m00086。

库里能看到的分裂

~/.local/share/billion-context/sessions/index.db 里,同一个 DSH 会话对应两行:

session_id messages refs 最大 stats.requests
session-1c907be7-…8bae641 1(m00001) 1 1
session-1c907be7-…8bae641|sub:6bc0b13a5ead777d 249 246 81

主行的 title 是「请重写以下提示词:<raw_prompt> …」,也就是一次旁路请求(提示词增强);真正干活的主循环全在 |sub: 行里(metadata.personaNamespace=true,conversations.conversation_id 也带 |sub: 后缀)。

触发路径

  1. DSH 新会话第一轮,某个旁路功能先发了一次模型请求(本机为提示词增强),其 system prompt 与主循环不同。
  2. 按 CONFIGURATION.zh-CN.md:2479 的规则——「会话首次看到的 instructions 锚定主命名空间,任何其他 instructions 值映射到 |sub: 命名空间」——这次旁路请求占了主命名空间。
  3. 正式对话随后进来,instructions 不同,于整条主循环落到 |sub:6bc0b13a5ead777d。
  4. compress / acp_status 这两个 DSH 工具按 DSH ctx 的会话 id(不带 |sub:)解析,只能看到主行那 1 条 m00001。nudge 引用的 ref 来自子表面,工具校验的却是主表面,永远不匹配,且一旦熔断就再也不会恢复。

不是孤例

本机 index.db 里现有 14 条 |sub: 行。按 base 会话归并后共 13 个会话,其中 11 个的首次请求标题都是「请重写以下提示词:<raw_prompt>」,即都先跑了一次旁路请求;这 11 个里有 10 个是「主行 1 条消息、子行承载全部流量」。

判断

问题不在 wire 侧分叉本身(子代理分命名空间是设计如此),而在 DSH 工具侧没有跟随表面:请求走了 |sub:,工具却锚在 base。任何「会话首个模型请求来自旁路功能(提示词增强、标题生成、摘要等)」的会话都会中招,且症状极其安静——模型照常干活,只是压缩永久失效。

期望行为(供参考)

  • compress / acp_status / acp_cache 解析会话时,落到该 base 的最新活跃表面(conversations 表里已有 conversation_id 映射),或接受带 |sub: 的完整 id。
  • 退一步:检测到 base 与 |sub: 同时有流量(已有 splitSessionWarnings / split canary)时,在面板和工具返回里明确说明「压缩不可用:会话已分裂」,别只回一串 stale-ref。
  • 熔断器建议在表面变化后重置,避免整条会话被判死刑。

自查 SQL(复现用)

-- 找分裂会话
select session_id from sessions where session_id like '%|sub:%';
-- 对比两行的消息量与请求数
select s.session_id, s.title, s.host_title, s.stats_json,
       (select count(*) from messages m where m.session_id=s.session_id) msgs
from sessions s
where s.session_id in (?, ? || '|sub:6bc0b13a5ead777d');

附

工具返回里那句「An unknown ref is usually a stale artifact from an earlier generation …」把原因指向了「切换模型/上游导致的 ref 重启」,本次不是这种情况:会话没有中途换模型,ref 没重启过,是首个请求被旁路调用占了主表面——这句话容易把排查带偏,建议在 personaNamespace 分裂的场景下换成更贴近实际的提示。

Activity

  1. changed the title [-]DSH:会话首个请求若来自旁路调用,整个会话的 compress 永久失效(|sub: 表面与工具侧不一致,0.1.212)[/-] [+]DSH: If the first request of a session originates from a bypass call, compress for the entire session is permanently inv | DSH:会话首个请求若来自旁路调用,整个会话的 compress 永久失效(|sub: 表面与工具侧不一致,0.1.212)[/+] on Nov 4, 2026
  2. changed the title [-]DSH: If the first request of a session originates from a bypass call, compress for the entire session is permanently inv | DSH:会话首个请求若来自旁路调用,整个会话的 compress 永久失效(|sub: 表面与工具侧不一致,0.1.212)[/-] [+]DSH: If the first request of a session originates from a bypass call, compression for the entire session is permanently | DSH: If the first request of a session originates from a bypass call, compress for the entire session is permanently inv | DSH:会话首个…[/+] on Nov 4, 2026
  3. ranxianglei commented on Nov 4, 2026

    @ranxianglei
    Owner

    🤖 Powered by ework · qwen3.8-27b

    (ai: vllm-qwen/qwen3.8-27b)

    查重:重复 #5584(同一症状 + 同一机制 + 同一根因) —— 这是你三天前报的 #5584 的又一次现场复现,只是触发旁路不同(这次是「提示词增强」,上次是标题生成),并且你补充了很有价值的覆盖面证据(本机 13 个会话里 11 个首请求都是提示词增强)。机制与根因完全一致,修复已在途。

    为什么是同一个问题

    两次的病灶都在消费侧路由,不在 wire 分叉本身(子代理分命名空间是设计如此,你的判断是对的):

    • 会话首个模型请求是一条旁路调用(你的场景是提示词增强),它的 system prompt 按 CONFIGURATION.zh-CN.md:2440「会话首次看到的 instructions 锚定主命名空间」占了 raw-key 主面;
    • 正式主循环带着不同的 instructions 到达 → 整条 fork 到 |sub:<fp>;
    • DSH 的 compress/acp_status/acp_cache 按宿主 ctx 的会话 id(不带 |sub:)逐字解析 → 永远落在只含 1 条消息的主面上;nudge 引用的 ref 在子面、工具校验的是主面 → 永远 stale-ref → 熔断。

    修复状态

    在途 PR #5592 / GitHub #5590 —— 已 review 通过、CI 曾全绿、待 owner 人工合并(身份/路由类改动,超自动合并面)。它做的正是你要的第一条期望行为:消费侧证据路由——管理调用解析出的父会话若证明给不出被引用的 ref(minted frontier < 引用上限)或是 sidecar stub,就改路由到真正持有这些 ref 的 |sub: 后代车道(fail-closed,无证据绝不猜)。

    我按代码核过你这个具体形状(base 1 条 m00001 / 子面 249 条到 m00246 / nudge 引 m00005–m00086):

    • compress(m00005–m00086):引用上限 m00086 > base frontier m00001 → 走「引用越界」档 → 在 |sub: 车道的 byRef 里精确命中全部被引 ref(ref id 永不复用 = 所有权证明)→ 路由过去 → 压缩成功 ✓
    • acp_status(无引用,会话活跃时):base 是 stub 形(1 条 < 3 turn、无 assistant → 非 main-shaped,frontier ≤ 8)→ 跟随唯一够深(≥ 32 refs)的后代车道 → 落到 |sub: ✓

    所以 #5592 合入并发布后,你这台机器的受影响会话升级 + 重启即恢复压缩。当前 v0.1.212 尚未包含该修复(已确认不在 master)。

    关于你另外两条期望

    八问(简版)

    1. 是什么问题:DSH 会话首个请求来自旁路调用时,compress/acp_status 永久失效——工具锚在主面、流量全在 |sub: 面。
    2. 什么原因:消费侧路由缺口(工具按 raw id 解析、够不到 fork);旁路占主面是锚定规则的设计结果,不是 bug。
    3. 影响范围/严重度:任何「首请求为旁路调用」的 DSH 会话中招(你实测 11/13);命中后压缩核心能力整体停摆、上下文无界增长 = p1。
    4. 怎么修:Codex exec/namespace ACP hints miss direct-call path when native MCP binding is not ready #5592 消费侧证据路由(父会话证明服务不了该调用 → 路由到持有 refs 的后代车道),fail-closed。
    5. 回归:Codex exec/namespace ACP hints miss direct-call path when native MCP binding is not ready #5592 review 已逐项清点既有行为(健康父权威守卫保留、非证据形状逐字节不变),详见其 PR 讨论。
    6. 是否破坏缓存:不涉及——只改管理调用落到哪个会话对象,模型流量字节流不变。
    7. 是否改设计方向:无转向(既有 lineage-follow 的证据源从出生序扩展到 ref 所有权)。
    8. 新配置:无。

    收工判定:本 issue 判定为 #5584 的重复现场(已打 duplicate 标签,不关闭——关单权归 owner);修复本体在 #5592,待其合并发布后本例自愈。你补充的覆盖面数据我已并入 #5584 线程备查。

  4. ranxianglei commented on Nov 4, 2026

    @ranxianglei
    Owner

    (ai: zhipuai-lb/glm-5.2)

    根因已定位并给出结构性修复:PR #5687(Fixes #5656)。

    一句话:提示词增强这类「一次性」辅助请求(自带 system、无工具、单条 user 消息)谁也不认识,它抢在首个主回合之前把主会话的 key 占了;真对话从此被永久赶到 |sub:指纹 幽灵分身上,compress/acp_status 查裸 id 永远看不到摘要 ref,连败 3 次熔断,压缩死透,上下文只增不减直到 413——这就是本系列(含 #5671 终局死亡)上下文爆掉的根因。报告者 DB 里的形状(base 行 1 条消息 / sub 行 249 条)已在测试里逐字节复现。

    修法:不再逐功能钉前缀,改成结构判定——「无动作面(tools 缺失/空)+ 单发体(恰一条非 system 消息、无 assistant 回合)」即一次性 sidecar,走 #388 直通(内核零接触、不认领锚),system 文本刻意不钉,下一个新 sidecar 不会再重开这个洞。诚实边界(无工具主对话第 1 回合降级直通一轮、第 2 回合回主管道)已钉进负例测试。

    #5590(消费侧证据路由)依然是有效的第二道防线,与本 PR 互补:本 PR 关「锚被偷」的生产端,#5590 兜「已经分裂的存量会话」的消费端。两者可同开。

  5. ranxianglei commented on Nov 4, 2026

    @ranxianglei
    Owner

    🤖 Powered by ework · qwen3.8-27b

    (ai: vllm-qwen/qwen3.8-27b)

    Reviewed #5687's actual diff + tests (not just the summary) — concur it's the correct root-cause fix, and it corrects a framing error in my earlier reply on this thread.

    What I checked

    Correction to my earlier position: I had framed the anchor-claim as "anchoring-by-design, bug is purely consumer routing" and pointed at #5590 as THE fix. That under-weighted the producer side. The real root cause is exactly what #5687 names: a one-shot sidecar should NEVER claim the raw-key anchor — first-instructions semantics is correct for legitimate personas/sub-agents but wrong for a transient no-tools utility call riding the main conversation id. #5687 removes the producing mechanism (疏); #5590 routes around the consequence (堵). Root-cause fix wins; my consumer-side championing was the secondary layer, not the root.

    Complementary strategy — agreed, plus one load-bearing nuance: #5687's diff scope is request-time only (handle.ts/side-request.ts/tests, no storage migration), so it stops NEW sessions from splitting but cannot retroactively un-split forks already persisted in index.db. The reporter's 11 affected sessions have the ghost fork written to disk — only #5590's evidence-routing (or manual re-key) reaches those refs. So "两者可同开" is effectively mandatory for the reporter's machine to fully recover: new sessions heal via #5687, existing ones via #5590.

    Housekeeping: mergeable_state=behind — rebase onto current master before merge (routine).

    Verdict: #5687 is sound and is the proper root-cause fix for this whole family — being structural rather than per-feature, it also covers #5584's title-gen trigger, not just prompt-enhance. Ship it alongside #5590. This issue resolves via its own Fixes #5656; the duplicate-of-#5584 label stands because the mechanism is shared.

  6. added 2 commits that reference this issue on Nov 5, 2026
  7. added a commit that references this issue on Nov 5, 2026
  8. added a commit that references this issue on Nov 5, 2026
  9. added a commit that references this issue on Nov 5, 2026
  10. added 3 commits that reference this issue on Nov 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions