Repository navigation
Description
English abstract: On DeepSeek Harness (DSH), forking a session always degrades to "no inherited compression". The child's first provider request is the uncompressed history (191,391 input tokens, 0% cache), while the parent sat at 66,523 tokens / 99% cache. Root cause: the proxy refuses to build a fork snapshot for any session whose raw snapshot contains non-text parts (DSH emits
thinking/reasoningblocks), returning HTTP 409SNAPSHOT_UNAVAILABLE; the client's adopter classifies onlysnapshot|fork error/http 5xxas transient, so a 409 is terminal and never retried. Repro is deterministic, evidence below.
- 插件版本:
billion-context@0.1.206(buildf161c518,packdefault) - 宿主:DeepSeek Harness
0.2.1-rc.3(Windows,dsh web),模型deepseek-flash
1. 摘要
在 DSH 上 fork(GUI「Fork」或 subagent_fork,两者都会产生 header.isSeeded=true + header.parentSession=<parent> 的会话)每一次都失败,子会话拿到 0 个压缩块,首个 provider 请求就是完整未压缩历史:
| 指标 | 父会话 session-0f710d30… | 子会话 d147e338… |
|---|---|---|
| blocks | 4(active=4) | 0 |
| folds | 4,累计 savedSoFar = 3,422,760 tokens | 0 |
| 首包大小 | 145 msgs / inbound=844.2KiB | 82 msgs / inbound=644.3KiB |
| acp-usage input | 66,523(cached 65,920,命中 99%) | 191,391(cached 0,命中 0%) |
| compressibleRanges | 已全部折叠 | 4 段(m00001–m00126 原样重现,与父会话折叠前完全一致) |
子会话首包是父会话的 2.88× tokens、0% cache 命中;在 128K / 200K 上下文窗口的模型上,这会直接触发上下文溢出——这正是用户报告的现象。
2. 复现步骤(确定性)
- 在 DSH 中开一个普通会话(根会话),进行多轮工具调用,让插件完成至少 3–4 次
compress(父会话blocks ≥ 3,folds ≥ 3)。 - 对父会话最后一次 provider 请求,确认
bili.log有[acp-usage] input=... cached=...(表明 snapshot 已记录)。 - 直接 fork 该会话:GUI 上的「Fork」,或等价的
subagent_fork(会 spawn 一个isSeeded=true的子 session)。 - 观察:
bili.log出现fork adoption for <child> degraded (snapshot http 409 SNAPSHOT_UNAVAILABLE ...);GET /__bili/plugin/status?conversationId=<child>(同一代理端口)→blocks: []、compressibleRanges与父会话折叠前一致;- 子会话第一次请求的
[acp-usage]:input接近未压缩历史总量,cached=0。
3. 日志证据(原样摘录)
3.1 变体 A:父会话快照存在但"不可按文本比较"(reasoning/thinking 块)
2026-10-24T14:55:33.087Z [info] [sess=session-0f710d30-…] [plugin] [acp-usage] input=66523 cached=65920 (cache hit 99%)
2026-10-24T14:55:33.204Z [warn] [v=0.1.206] [dsh-client] bili-native-dsh: fork adoption for d147e338-a3cc-4935-a3c7-ca6178981b35 degraded (snapshot http 409 SNAPSHOT_UNAVAILABLE (Error: multimodal or opaque content cannot be compared by text)) — the session continues without inherited compression state (#2399/#2469)
2026-10-24T14:55:33.282Z [info] [sess=session-0f710d30-a78d-4dfa-b37d-cce93365e085] [v=0.1.206] [session-0f710d30-…] request: 145 msgs, inbound=844.2KiB, outbound=255.1KiB, local=105ms
2026-10-24T14:55:33.328Z [info] [sess=d147e338-a3cc-4935-a3c7-ca6178981b35] [v=0.1.206] [d147e338-…] request: 82 msgs, inbound=644.3KiB, outbound=649.9KiB, local=121ms
2026-10-24T14:55:38.234Z [info] [sess=d147e338-…] [plugin] [acp-usage] input=191391 cached=0 (cache hit 0%)
3.2 变体 B:代理重启后父会话快照缺失
代理在 14:50:05Z 重启,随后 24 秒内连续两次 fork 均失败:
2026-10-24T14:50:29.272Z [warn] [dsh-client] bili-native-dsh: fork adoption for session-565aa43c-d972-4dc5-bf64-8c5d8d8d94a5 degraded (snapshot http 409 SNAPSHOT_UNAVAILABLE (Error: raw snapshot unavailable; send a fresh plugin model request))
2026-10-24T14:51:11.053Z [warn] [dsh-client] bili-native-dsh: fork adoption for session-0f710d30-a78d-4dfa-b37d-cce93365e085 degraded (snapshot http 409 SNAPSHOT_UNAVAILABLE (Error: raw snapshot unavailable; send a fresh plugin model request))
注意 session-0f710d30 本身也是 565aa43c 的 fork 子会话(isSeeded=true),它带着 0 blocks 起跑(首包 189,659 tokens),直到手动重新折叠出 4 个块后,第二次 fork(变体 A)依然失败。
整条 fork 链(直接解析会话文件 header 得到):
session-e915dcbc… isSeeded=false parent=null ← 根会话
session-565aa43c… isSeeded=true parent=session-e915dcbc… adoption 409 (raw snapshot unavailable)
session-0f710d30… isSeeded=true parent=session-565aa43c… adoption 409 (raw snapshot unavailable)
d147e338… isSeeded=true parent=session-0f710d30… adoption 409 (multimodal or opaque content…)
即 DSH 上的三次 fork 0/3 成功,且两种 409 原因可以同时出现在一条链上。
3.3 与 wire 协议无关
409 发生在服务端构造快照阶段(forkSnapshot),早于客户端 tryForkAdoption 里的 detectWireFormat() / chatBodyToCore()。也就是说它不依赖 anthropic / openai-chat-completions / openai-responses 中任何一种线格式:只要主机的 assistant 消息带 thinking / reasoning 块,任何 provider、任何协议都会走到同一个拒绝分支。
4. 根因(代码路径)
4.1 触发点:快照文本可比性白名单不含 DSH 的 reasoning/thinking 部件
dist/index.js:
function comparableHistory(value){
if(value===null||typeof value==="string")return true;
if(Array.isArray(value))return value.every(comparableHistory);
if(!value||typeof value!=="object")return false;
const part=value;
if(part.type!==void 0&&!["message","text","input_text","output_text","tool_use","tool_result","function_call","function_call_output"].includes(String(part.type)))return false;
if(part.type==="tool_use"||part.type==="function_call")return true;
if(part.audio!==void 0&&part.audio!==null)return false;
if(part.content!==void 0)return comparableHistory(part.content);
if(part.output!==void 0)return comparableHistory(part.output);
if(part.parts!==void 0)return comparableHistory(part.parts);
return typeof part.text==="string"||Array.isArray(part.tool_calls)
}
DSH 的 assistant 消息带 thinking / reasoning 块。对本次父会话的历史做统计(直接解析 session.v4.jsonl.zstd):
parent assistant part types: reasoning:117 tool-call:103 text:8 (非空 reasoning 109 条)
child assistant part types: reasoning:64 tool-call:49 text:6 (非空 reasoning 60 条)
于是 comparableHistory(...) === false → 记录 session.metadata.publicSnapshotTextComparable = false。
4.2 快照端点据此硬失败
on forkSnapshot(session){
const messages=session.pluginSnapshot;
if(!messages)throw new Error(session.metadata.publicSnapshotCapped===true
?"raw snapshot exceeded the retention cap (BILI_PUBLIC_SNAPSHOT_CAP_BYTES); fork is refused rather than retaining an unbounded raw copy"
:"raw snapshot unavailable; send a fresh plugin model request");
if(session.metadata.publicSnapshotTextComparable===false||messages.some(m2=>(m2.thinkingTokens??0)>0))
throw new Error("multimodal or opaque content cannot be compared by text");
…
}
handlePluginSnapshot 捕获后统一回:
forkReply(res, 409, { ok:false, status:"unavailable", code:"SNAPSHOT_UNAVAILABLE", error:String(err) })
4.3 为什么这是 bug 而不是"诚实的保守拒绝"
fork 的父/子对齐用的是 forkMessageIdentityHash,它不包含 thinking 文本:
function forkMessageIdentityHash(message){
return forkHash([message.role, message.contentType, message.text ?? null, message.toolName ?? null,
message.toolCallId ?? null, message.thinkingTokens ?? null, message.summaryOfBlockId ?? null,
forkToolIsError(message)])
}
既然对齐哈希本就不比较 reasoning 文本,comparableHistory 的文本白名单和 thinkingTokens>0 的拒绝条件就是过度保守:reasoning 部件完全可以"存在但被忽略"(thinkingTokens 计数已进哈希)。结果是:接入 DSH 这种一定会带 thinking 块的主机后,fork 功能 100% 不可用。
4.4 客户端把 409 当作终态(第二个 bug)
dist/agent/dsh-native.js:
const transient=/^(snapshot|fork) (error|http 5\d\d)/.test(result.reason)||result.reason==="body unmappable";
if(!transient||(attempts.get(input.child)??0)>=maxAttempts)done.add(input.child)
snapshot http 409 … 不匹配 http 5\d\d → 直接 done.add(child) → 本进程内该子会话再也不会重试 adoption,也不会降级为"按父会话 blocks 重建"。失败只写在日志里:
fork adoption for <child> degraded (<reason>) — the session continues without inherited compression state (#2399/#2469)
UI 上没有可见提示,用户只会看到下游成本/上下文暴涨。
4.5 变体 B 的路径
冷加载(hydrate)从会话文件恢复 state.blocks(本次重建出 4 个块、244 refs 正常),但 session.pluginSnapshot 未恢复 → forkSnapshot 抛 raw snapshot unavailable → 同样 409 → 同样不重试。
5. 影响
- 成本:子会话首包 2.9×,且缓存命中 0%(父会话 99%+)。对长会话,未压缩前缀在每次请求上重复计费。
- 可用性:191K tokens 首包在 128K/200K 窗口模型上直接溢出——fork 从"省上下文的功能"变成"炸上下文的陷阱"。
- 静默:仅 warn 日志,无 UI 提示,用户无法察觉 fork 没生效。
- 连锁:fork 子会话本身也
isSeeded=true,再被 fork 时继续失败(本次链路上连续 3 次,0/3 成功)。
6. 候选修复方案(优先级仅供参考)
下面几处是照着代码整理出来的可能改法,前两条是本 issue 的直接修复方向,其余属于健壮性增强;是否采纳、先改哪个,交给作者判断。
comparableHistory:把reasoning/thinking视为可比部件——只要求typeof part.text === "string",不必因为存在 thinking 块就判定整段快照不可比:if(part.type==="reasoning"||part.type==="thinking")return typeof part.text==="string";forkSnapshot:考虑放宽messages.some(m => (m.thinkingTokens??0) > 0)这条拒绝。父子对齐只依赖forkMessageIdentityHash,其中已含thinkingTokens计数、不含 thinking 文本,所以看起来不需要整段快照拒绝。createForkAdopter:可以把http 409/SNAPSHOT_UNAVAILABLE纳入可重试范围,或在 409 时用父会话现有blocks降级重建,而不是一次失败就放弃继承。handlePluginSnapshot:父会话有 blocks 但快照不可比时,可返回"降级快照"(例如最近一个 block 边界 + 尾部原文),让子会话至少继承部分摘要。可见性:adoption degraded 时在子会话里留一条可见提示,避免用户误以为继承成功(目前只有 warn 日志)。
冷加载:代理重启后按需重建
pluginSnapshot,覆盖变体 B。
7. 建议的验收标准
- 在 DSH(带 thinking 块、
anthropic/openai-chat-completions任一线格式)中 fork 一个blocks≥3的会话后:- 子会话
status.blocks.length > 0、compressibleRanges明显少于父会话折叠前; - 子会话首包
acp-usage input≤ 父会话最近一次input的 1.15×,cached > 0;
- 子会话
- 重启代理后立即 fork 仍成功(变体 B 回归);
bili.log不再出现fork adoption … degraded (snapshot http 409 …)。
8. 取证方式
- fork 前后各取一次
/__bili/plugin/status,对比blocks与compressibleRanges; - 直接请求
/__bili/plugin/snapshot?protocolVersion=2,可复现 409 及其error文本; bili.log里搜fork adoption,能看到每次 degraded 的具体原因;- 会话文件第一帧的 header 里
isSeeded=true且parentSession非空,即说明该会话是 fork 子会话。
Activity
NekogamiJam commentedon Oct 24, 2026
Related: #4345
ranxianglei commentedon Oct 24, 2026
(ai: vllm-qwen/qwen3.8-27b)
查重结论
重复 —— duplicate of #4266(家族级跟踪票,2026-10-22 按 owner 指示开,标签 bug/p1/dsh/opencode/pi/scope/wiring)。同症状(DSH 克隆子会话恒定不继承压缩状态),且本票报告的每个机制都已在它的清单上;按「同症状同票 + 先来后到」并入该票。你补的 Related: #4345 也确认了关联——#4345 修的是本家族第 ⑨ 项机制(能力探测失败被当终态),与你的两个变体正交但同链。按现行规则 agent 不关闭 issue:已打
duplicate标签并在此说明,关不关由你决定。标签:
bugdshscope/wiringp1duplicate— p1 依据:核心承诺失灵(含 thinking 的 DSH 会话克隆后继承全丢、大会话首轮即卡死)且生产多版本复现;scope/wiring 因主线是 fork 收养协议(客户端接入层)。标题已是「English | 原文」格式,不动。逐项核实(对照最新 master @ 146b34f 实测)
multimodal or opaque content cannot be compared by text),手动再折叠恢复 4 块后仍失败raw snapshot unavailable/^(snapshot|fork) (error|http 5\d\d)/;修复 PR #3024(结构化 retryable 字段 + 服务端兜底源)open 未合并一点需要指出:#3011 在 10-24 被一条清理评论以「修复已由已合并 PR #3819/#4525/#4590 落地」为由关闭,但上面三个机制在当前 master(v0.1.206 之后)全部原样存在,那次关闭过早。家族跟踪 home 仍是 open 的 #4266。
本票新增的价值(已补充进 #4266)
八问
收工判定:本票判为 #4266 的重复(机制已全部在其清单跟踪,先来后到保留早票);按规则未执行关闭,请自行决定。后续修复与决策均在 #4266 推进,其中第 ③ 项(你主报的变体 A,生产最大头)等你拍板方向后即开工。
ranxianglei commentedon Oct 24, 2026
(ai: vllm-qwen/qwen3.8-27b)
收工确认(完整分析见上一条评论):本票已完成 triage——判为 #4266 的重复(同症状「DSH 克隆零继承」,三个机制全部在其清单跟踪:thinking 硬门、跨重启快照源缺失、客户端 409 误判终态;已对照最新 master 逐行核实均未修复)。标签
bugdshscope/wiringp1duplicate已打齐;你补充的 v0.1.206 生产样本(一条 fork 链内两种 409 变体共存、三代 0/3)已补进 #4266。按规则 agent 不关闭 issue,是否关闭由你决定;后续修复与方向拍板均在 #4266 推进。ranxianglei commentedon Oct 27, 2026
(ai: zhipuai-lb/glm-5.3)
跟踪票 #4266 的机制 1(thinking 硬门)已修:PR #4900;#4589 描述的 DSH fork 零继承中 409 分支不再对 thinking 会话全量触发。
fix(plugin-fork): allow-list typed reasoning parts too (#4266)
ranxianglei commentedon Oct 27, 2026
(ai: vllm-qwen/qwen3.8-27b)
核验结论:你的说法成立(对 DSH 车道),我在 #4900 分支上逐行核过,并顺手补了一个验证时发现的残留缺口。
核验证据
forkSnapshot删掉了「会话里有任何 thinkingTokens>0 就拒绝」的条款;comparableHistory白名单加入 anthropic 风格的thinking/redacted_thinking块。thinking 会话从此不再被 409 全量拒绝——这正是本票报告者(DSH)命中的路径:DSH 走 chat-completions 线,reasoning 以无 type 标记的reasoning_content兄弟字段上行,可比较性判定本来就不被它否决,拦住它的是已被删掉的 thinkingTokens 条款。验证中发现并已修复的残留缺口(披露)
#4900 的白名单只加了 anthropic 风格块,没加 Responses 协议的带类型
{type:"reasoning"}输入项——用 responses 线回放推理项的客户端仍会永久 409(同一症状家族)。已作为独立标注的追加提交推到 #4900 分支:45bafb3(白名单加reasoning+ 真实服务器回归测试:snapshot 200、fork 201、子会话继承 reasoning 消息)。本地定向测试 4/4 绿、typecheck 干净;全量套件由 CI 在推送头判定。仍未修复、验收标准未满足的部分(全部在 #4266 清单跟踪)
→ 所以本票验收标准里「代理重启后立即 fork 仍成功」这一条目前还不成立。
八问(本轮为核验+小修披露,非新缺陷分析)
本票维持 #4266 重复判定不变;整体进度与待拍板决策请跟 #4266。
closerex commentedon Nov 5, 2026
Follow-up evidence from a Windows DSH/Codex Responses installation on bili 0.1.212 (not a new duplicate issue). #5407 and #5595 also cover the snapshot refusal, so I am adding the narrower identity/validation data here.
The parent root had 49 blocks / 14 active; snapshot failed with
409 SNAPSHOT_UNAVAILABLE (multimodal or opaque content cannot be compared by text). The fallback did inherit 4 blocks from an older sub lane, so this particular incident was not literally zero inheritance. It still estimated 1071946 > effective input budget 700400 and entered long preflight.Our Responses-only local workaround did not merely delete the gate. On messages retaining rawResponsesItem, both server/native identity hashes use the same Core ID + raw sidecar + existing content/tool fields; the server-only thinkingTokens estimate is excluded from that raw identity. Without a sidecar the original hash remains. sameSnapshotView also compares this identity, so equal visible captions do not retain a stale snapshot when image payload or encrypted reasoning changes. Other protocol guards and prefix/ref/block/parent-revision checks remain unchanged.
Directed tests with actual production functions distinguish changed user image, tool image and encrypted reasoning under the same visible text; one-sided token estimates do not alter identity; JSON persistence and legacy/non-Responses behavior are checked. This is local workaround evidence, not a proposal to accept arbitrary unknown wire items.
Full isolated HTTP check: actual installed proxy + actual native tryForkAdoption; create parent b1 through the compress tool, request snapshot then POST fork. Result: adopted, branchPoint=65; the child's formal request reused the parent summary, omitted compressed non-anchor originals, preserved images/encrypted reasoning, and made no additional preflight upstream calls. Only localhost fake model traffic and isolated HOME/config/state were used; no private prompt/media/ciphertext or database is attached. It is not an authenticated live long-session/cold-start acceptance claim.
Current master 0aace2f still has the blanket gate in src/plugin.ts:1264. Please consider wire-payload identity/refresh parity along with any gate relaxation. I am reporting evidence here rather than opening another multimodal-fork symptom ticket.
ranxianglei commentedon Nov 5, 2026
(ai: vllm-qwen/qwen3.8-27b)
核验:你报的三个关键事实全部成立(已对照当前 master
0aace2f20,即最新 tag v0.1.212 的源码逐行确认):src/plugin.ts:1264的整段拒绝门确实还在,含 thinkingTokens 条款——thinking/多模态会话仍会全量 409;src/agent/fork-adopt.ts:575的正则不认 4xx,一次失败即永久放弃该子会话(对应 PR [PR] fix: fork adoption no longer gives up permanently on 409 SNAPSHOT_UNAVAILABLE (#3011) #3024 也还开着)。你的事故定位:你测到的父会话带图片/加密推理等不透明载荷(你的定向测试区分 user image / tool image / encrypted reasoning),这类会话即使 #4900 合入也不在其解除范围内——#4900 刻意保留了对图片/音频的拒绝。你要的「wire-payload identity/refresh parity」正是家族跟踪票 #4266 上待拍板的决策一方向一方向①+②(不透明字节进身份哈希 + 可比较性标记降级为优化位)。这条线已经动工:#4900 分支最新提交 50d9447 把 redacted_thinking 的 sidecar 字节摘要进了身份元组的第 10 槽(服务端/客户端镜像同步扩展,复用图片块的既有寻址模式),但图片与 responses 加密推理的全量覆盖尚未完成,且按仓库规则属 owner 拍板区。
你的 sameSnapshotView 观察被采纳为验收标准:可见文本不变而载荷字节变化(换图、加密推理轮换)时,快照必须判为过期并刷新——否则克隆会静默继承旧字节。这是任何放宽门的实现都必须满足的一条,我记入 #4266 清单。另外你提到 fallback 从旧 sub lane 继承了 4 个块(非字面零继承)——这个部分继承路径的现象也一并记录在案。
关联条目:你说的两个同族 issue 我核对过(标题分别为「fork adoption degrades for thinking-model sessions」与「Fork adoption fails on multimodal parents…400 InvalidArgument」),均 open,与本票同机制家族,统一在 #4266 跟踪,不再另开新票。
八问(本轮为核验+证据归档,无代码改动)
收工判定:本票维持 #4266 重复判定;本轮全部事实核验通过,证据已归档至家族票;合并与拍板归 owner。