Skip to content

[bug] dsh:side request 先到会抢走 persona 锚点,主会话被 fork 到 |sub:<fp>,原生 compress 永久失败 #2156

Closed

Description

@w1Tz3R-LW

Description *

环境:billion-context 0.1.184,dsh desktop profile(native 插件,lane=dsh),deepseek-flash(窗口 1,000,000),Windows。

现象:本会话的 compress 调用永久失败,重试无用:

compress FAILED → 0 blocks. every ref is unknown to this session.
[diagnostics: session highest ref=none, unknown ranges in request=1/1, session history=0 compression(s), 0 block(s)]

本次没有任何一次 fold 成功(这正是问题),所以没有 fold 前/后的对比可给

原因(日志 + kernel 代码可证):该会话 id 下的第一个请求是一条 side request,它先占住了 persona 锚点,14ms 后第一轮主会话就已经带上 |sub: 后缀;而宿主盖章给 compress 工具的是裸 id。

05:46:30.555  side request (max_tokens<=200) → passthrough + tag strip only, kernel state untouched
              sess=session-052c1eaf-…                                   ← 裸 id
05:46:30.569  processTurn: 3 msgs
              sess=session-052c1eaf-…|sub:d1bdbce38bf93a46            ← 第一轮已被改名

side request 的短路分支在 src/server.ts:2804,而 persona 身份解析在 src/server.ts:2194-2245,短路晚于锚定,所以它照样走了 subagentNamespace(...) 并占住了裸 key(kernel/src/wire/responses.ts 的 createSubagentNamespaces:首个 system 占住 raw key)。

与 AGENTS.md 冲突:§2 Key Design Decisions 09 的结论是
The FIRST system seen under the id keeps the raw key … so main turns never fork。
PR #1956 评审里承认过的「最坏 = 一次角色互换」是限定在代理重启竞态的,本次没有重启,是 side request 先到。

旁证:同一代理、同一时段,其它会话与两个子 agent 的压缩均正常(state 里 6 个 / 1 个活跃 block,另有历史会话 2 个 / 1 个),只有这一条落在 |sub: 一侧。

期望:修复该会话(以及同类时序)永久无法压缩的问题。我不打算提 PR,只报告;如需补充日志请告知。

bili version *

0.1.184

Usage mode *

Plugin native (bili plugin install …, runs inside the host process)

Client and version *

dsh 0.2.0-rc.2 (desktop profile, bili native plugin bundle)

Operating system *

Windows 11 25H2 (build 26200.9457), native Windows, not WSL2

Upstream and model *

api.deepseek.com (anthropic wire: /anthropic/v1/messages) · deepseek-flash · 1,000,000

Compression-related config (optional)

无 —— ~/.config/billion-context/billion-context.json 只有 {"providers":{}}

Log excerpt (strongly recommended)

2026-10-05T05:46:30.548Z [info] [v=0.1.184] [window] model=deepseek-flash source=plugin native=1000000 effective=1000000 launcher=none configured=none peek=none fallback=false
2026-10-05T05:46:30.555Z [info] [sess=session-052c1eaf-0416-4aae-a002-4fbefcfa1d5c] [v=0.1.184] [session-052c1eaf-0416-4aae-a002-4fbefcfa1d5c] side request (max_tokens<=200) → passthrough + tag strip only, kernel state untouched
2026-10-05T05:46:30.555Z [info] [sess=session-052c1eaf-0416-4aae-a002-4fbefcfa1d5c] [v=0.1.184] [session-052c1eaf-0416-4aae-a002-4fbefcfa1d5c] request: 1 msgs, inbound=119.0KiB, outbound=119.0KiB, local=26ms
2026-10-05T05:46:30.569Z [info] [sess=session-052c1eaf-0416-4aae-a002-4fbefcfa1d5c_sub:d1bdbce38bf93a46] [v=0.1.184] [session-052c1eaf-0416-4aae-a002-4fbefcfa1d5c|sub:d1bdbce38bf93a46] processTurn: 3 msgs, renderTags=text-only, 3 text tagged, 0 tool tagged
2026-10-05T05:47:51.703Z [warn] [v=0.1.184] [plugin] tool "compress": host-stamped native caller "session-052c1eaf-0416-4aae-a002-4fbefcfa1d5c" conflicts with outbound witness — honoring the native caller, refusing the witness (#2024)
2026-10-05T05:47:51.707Z [info] [v=0.1.184] [session-052c1eaf-0416-4aae-a002-4fbefcfa1d5c] [plugin] [acp-proxy: compress FAILED m00004–m00066 → 0 blocks. None of the 1 requested range(s) resolved — every ref is unknown to this session. [diagnostics: session highest ref=none, unknown ranges in request=1/1, session history=0 compression(s), 0 block(s)]

/acp or acp_status output (optional)

本会话的 acp_status 拿不到块列表(这本身就是症状之一)。等价的持久化状态
(~/.local/share/billion-context/sessions/anthropic/*.json):

session-052c1eaf-…|sub:d1bdbce38bf93a46 : blocks=0, messageRefs.byRaw=233, stats.requests=54, lastInputTokens=263991
session-052c1eaf-…                     : blocks=0, byRaw=0,   requests=0,  lastInputTokens=0      ← compress 工具调用带的裸 id
da768738-…  (子 agent A)               : blocks=6 (6 active), requests=56
026b76fd-…  (子 agent B)               : blocks=1 (1 active), requests=11

Activity

  1. ranxianglei commented on Oct 5, 2026

    @ranxianglei
    Owner

    🤖 Powered by ework · qwen3.8-27b

    [bot] 🏷

    查重:按 persona anchor / side request / sub fork / subagentNamespace 等关键词检索了 open+closed issues 与 PRs,无重复。相关条目是本 bug 打碎的机制本身(#1916/#1307/#1314 指纹机制、#388 side passthrough 契约、#1897 leaked-tools demotion),不是重复报告。

    审核(动手前三步):代码+你的日志双重确认——kernel 的 subagentNamespace 把「首个非空 system」锚定为 raw key(可变进程内状态,无删除 API),而 bili 在 src/server.ts 里 persona 身份解析跑在 #388 side-passthrough 短路(~line 2807)之前,于是无状态的 side request 也参与锚点写入。你的日志时间线(05:46:30.555 side request … sess=<bare-id> → 05:46:30.569 processTurn sess=<bare-id>|sub:d1bdbce…)与代码路径完全吻合。这是根因层而非表面现象:修法是让 side request 根本不参与锚点解析(producer 处),而不是在下游加恢复逻辑。

    结构化七问:

    1. 是什么问题:dsh 对主 turn 和辅助请求(title/classifyRisk)复用同一 conversation id;辅助请求先到会抢走 persona 锚点,主会话被 fork 到 |sub:<fp> 会话,主会话上的原生 compress 永久失败("every ref is unknown to this session")。
    2. 什么原因导致的:subagentNamespace 以「首见 system = raw key」为锚(可变进程内存,无删除 API);bili 的身份解析先于 side-passthrough 短路执行,使从不触碰 kernel 状态的 side request 也写锚点。第一个到达的请求决定一切,之后不可恢复。同一机制的第二个切面:即便主 turn 先锚定,side request 之后也会骑到垃圾 |sub:<fp(side)> 会话上,违背 标题生成等侧请求污染主会话状态:prepareAnthropic 缺 isTitleGen 守卫、快照无条件覆盖、survivedCount 每请求空转 #388「side requests share the main session key」契约。
    3. 怎么修复的:身份解析前新增 sideRequestLike 预判——完整镜像 标题生成等侧请求污染主会话状态:prepareAnthropic 缺 isTitleGen 守卫、快照无条件覆盖、survivedCount 每请求空转 #388 lane 条件(budget≤200/无工具形态,或全-bili-tools demotion 形态,含 [bug] bili dsh 长会话中 max_output_tokens 被压到 ≤200,主请求被误判为 side request 并绕过压缩 #546 starved-budget 否决与 ACP-artifact 检查;detectAcpArtifacts 排最后,proxy 流量不付全历史重编码的代价)。side request 一律解析为 verbatim 原 key:既不读也不写锚点,与其「永不触碰 kernel 状态」的地位一致。顺带抽出 hasLeakedBiliToolsOnly(stripLeakedBiliTools 的只读孪生,行为不变)。
    4. 是否有回归问题:逐路径审过既有行为——dsh review persona fork(并发同 session-id 流互相覆盖 lastInputTokens 基线:#388 侧请求分类漏掉「整段上下文单消息」形态,#1595 re-anchor 放大覆盖 #1916)保持不动(新测试 phase 4 专门钉住);leaked-tools demotion(OMP extension injects tools and compression philosophy in helper prompts #1897/[bug] bili dsh 长会话中 max_output_tokens 被压到 ≤200,主请求被误判为 side request 并绕过压缩 #546/opencode v2 title-gen requests get injected with compression philosophy (misclassified by isTitleGen) #1699)语义不变;claudeSubagentSplit 分支未碰;codex instructions-fingerprint lane 仅 side 形态受影响(那些请求本来就走 标题生成等侧请求污染主会话状态:prepareAnthropic 缺 isTitleGen 守卫、快照无条件覆盖、survivedCount 每请求空转 #388 passthrough、不碰 kernel state,旧行为纯是锚点污染)。本地:typecheck 干净;dsh-persona-fingerprint 7/7(未打补丁时 5/7,两个新回归 case 都失败,证明断言有牙);fix-1897-leaked-tools-side + side-request-isolation 33/33;instructions-drift + subagent-namespace 13/13;build OK。codex e2e 本地缺 upstream secret 无法真跑,A/B 验证了 clean master 上同样失败(环境因素,非本 PR 引入),CI 对本 diff 的热文件自动覆盖。
    5. 是否破坏缓存:否。prefix-cache 的 affinity token / client label 本来就消费 raw identity 值;改动只是让 side request 不再错误地落到指纹化 key 上。
    6. 是否改了设计方向:无架构转向。只把一个决策(该请求是否会走 side passthrough)提前到身份解析之前,使身份解析与既有的 标题生成等侧请求污染主会话状态:prepareAnthropic 缺 isTitleGen 守卫、快照无条件覆盖、survivedCount 每请求空转 #388 契约对齐。
    7. 是否引入了新的配置:无。没有新 env / config / CLI 字段。

    行为变更披露(old → new):

    • dsh plugin-lane side request 的会话 key:旧值 = 首见 system 可抢走 raw key(side 先到时),或锚定后骑垃圾 |sub:<fp(side)> 会话;新值 = 恒为 verbatim conversation key,永不触碰锚点。
    • proxy-mode Responses side 形态请求(max_tokens≤200、无工具):由 instructions-fingerprint keying 改为 verbatim——同一机制的同一修法,理由相同。

    残留(超范围):proxy 重启后若 classifyRisk/review 先到,仍会看到冷锚点表(src/session-id.ts:151-153 已记录的 worst case,#1956 接受);彻底解决需要持久化锚定,是独立的设计决定,不在本 PR。

    你那个坏掉的会话不可恢复:状态孤立在带后缀的 key 下,host 继续戳 bare id——开新会话即可恢复正常,此修复保证不再复发。

    PR: #2157 (Closes #2156,待人工合并)

  2. added 2 commits that reference this issue on Oct 5, 2026
  3. added 3 commits that reference this issue on Oct 9, 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

    Labels

    bugSomething isn't working

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions