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
[bot] 🏷 Triage: bug confirmed on master; independent fix designed (NOT lifting #1092's hunk). Implementation starting now.
1. Reproduce / verify
Master keying path: src/server.ts:1348 → subagentNamespace(identity, instructions). The kernel anchors the first-seen instructions fingerprint per conversation id and namespaces any later different fingerprint as <id>|sub:<fp> (acp-kernel subagentNamespace). So any mid-conversation instructions drift forks the session and resets anchor + compression state. Confirmed from the code path, not just the report.
Verified opencode's side in upstream source (anomalyco/opencode, dev branch, packages/opencode/src/session/llm/request.ts): every model request stamps x-session-affinity / X-Session-Id = the session id, and task-tool subagents get their OWN child session ids (sessions.create({ parentID })). One conversation id = one persona in opencode, so same-id + drifting instructions can only mean system-context reconcile (AGENTS.md edit) — never a persona switch. For this client the fingerprint is pure harm.
2. Layer judgment
Root cause is in session-key derivation (identity → session mapping), not wire shape: the instructions fingerprint exists to separate personas that SHARE one conversation id (Codex threads, #150). It is misapplied to clients whose native ids are already persona-scoped. The fix belongs where the key is derived — the same site as #1092's hunk, but trust must come from verified client semantics instead of the anchor feature.
3. Design (independent of #1092)
Skip the instructions fingerprint ONLY when the winning conversation signal is a verified persona-scoped native identifier:
plugin declaration: new protocol header x-bili-plugin-instructions-mutable: 1, honored only together with x-bili-plugin + x-bili-plugin-conversation. Only the opencode plugin stamps it — other hosts (dsh/hermes/…) stay unverified and keep today's behavior.
Everything else keeps the fingerprint unchanged: Codex body/header/metadata session ids (#150 guard), x-claude-code-session-id (Claude subagents share the main session id, #970), grok/mcode/generic x-session-id, prompt-cache-key. Zero regression surface; the existing #150 e2e guard stays green.
Rejected alternatives: blanket trust of all client-provided ids (would re-merge #150's case); comparing old-vs-new instructions content (fragile across compaction/truncation boundaries); user config gate (bug persists by default until configured — the declaration belongs with the integration that knows the host's semantics).
Next: unit matrix + e2e regression (same ses_ id, edited instructions → one session, compression state carried over) + plugin-mode variant, then a PR linked here.
Activity
ranxianglei commentedon Sep 21, 2026
[bot] 🏷 Triage: bug confirmed on master; independent fix designed (NOT lifting #1092's hunk). Implementation starting now.
1. Reproduce / verify
src/server.ts:1348→subagentNamespace(identity, instructions). The kernel anchors the first-seen instructions fingerprint per conversation id and namespaces any later different fingerprint as<id>|sub:<fp>(acp-kernelsubagentNamespace). So any mid-conversation instructions drift forks the session and resets anchor + compression state. Confirmed from the code path, not just the report.anomalyco/opencode, dev branch,packages/opencode/src/session/llm/request.ts): every model request stampsx-session-affinity/X-Session-Id= the session id, and task-tool subagents get their OWN child session ids (sessions.create({ parentID })). One conversation id = one persona in opencode, so same-id + drifting instructions can only mean system-context reconcile (AGENTS.md edit) — never a persona switch. For this client the fingerprint is pure harm.2. Layer judgment
Root cause is in session-key derivation (identity → session mapping), not wire shape: the instructions fingerprint exists to separate personas that SHARE one conversation id (Codex threads, #150). It is misapplied to clients whose native ids are already persona-scoped. The fix belongs where the key is derived — the same site as #1092's hunk, but trust must come from verified client semantics instead of the anchor feature.
3. Design (independent of #1092)
Skip the instructions fingerprint ONLY when the winning conversation signal is a verified persona-scoped native identifier:
x-session-affinity(valueses_…) /x-opencode-session;x-bili-plugin-instructions-mutable: 1, honored only together withx-bili-plugin+x-bili-plugin-conversation. Only the opencode plugin stamps it — other hosts (dsh/hermes/…) stay unverified and keep today's behavior.Everything else keeps the fingerprint unchanged: Codex body/header/metadata session ids (#150 guard),
x-claude-code-session-id(Claude subagents share the main session id, #970), grok/mcode/genericx-session-id, prompt-cache-key. Zero regression surface; the existing #150 e2e guard stays green.Rejected alternatives: blanket trust of all client-provided ids (would re-merge #150's case); comparing old-vs-new instructions content (fragile across compaction/truncation boundaries); user config gate (bug persists by default until configured — the declaration belongs with the integration that knows the host's semantics).
Next: unit matrix + e2e regression (same
ses_id, edited instructions → one session, compression state carried over) + plugin-mode variant, then a PR linked here.中文摘要:确认了 opencode 编辑 AGENTS.md 后 Responses 会话被 instructions 指纹分裂成孤儿、压缩状态重置的 bug(master 现存);按"仅已验证的 persona-scoped 原生会话标识才跳过 instructions 指纹"独立设计修复(opencode 原生头 + 插件声明头),其余客户端防御保持不变,正在实现并准备提 PR。
ranxianglei commentedon Sep 21, 2026
[bot] 🏷 ## 修复完成 → PR #1104
一句话摘要:修了 Responses 会话 instructions 指纹随 AGENTS.md 编辑漂移、fork 孤儿
|sub:<fp>会话并重置压缩状态的问题——只对"已验证 persona-scoped"的会话 id(opencode 原生 ses_ 头 / 插件显式声明)跳过 instructions 指纹,其余客户端全部保留指纹,#150 的人格隔离保证不受影响;可以合并(建议合并前用 manual-dispatch CI e2e 补跑一次 codex 全流程)。审核结论(动手前验证了什么)
src/server.tsResponses 分支的会话 key =subagentNamespace(identity, instructions);kernel 侧subagentNamespace对同一 identity 首次见到的非空 instructions 锚定指纹,之后漂移即 fork|sub:<fp>。opencode 每次请求都把当前 AGENTS.md 渲染进instructions(system-context reconcile)→ 每次编辑都触发 fork,折叠视图丢弃、压缩状态归零。bug 属实,层次判断与 issue 一致:根因是指纹把 "same persona, updated instructions" 误判为 "different persona",不是锚/压缩机制本身的问题。stableSystemAnchor把 drift 吸收为 notes,单独落地会把真不同人格(同 conversation id、不同 instructions)并进同一 session/fold 空间。本 PR 走独立设计。信任集(每项都对客户端源码核实过)
x-opencode-session/x-session-affinity: ses_…sessions.create({ parentID })拿全新子 session id(opencode 仓库packages/opencode/src/session/llm/request.ts、tool/task.ts)→ 一个 id 只对应一个人格x-bili-plugin-conversation+x-bili-plugin-instructions-mutable: 1x-claude-code-session-id(Claude 子代理共享主 session id,#970)、grok/mcode/generic、pck改动面
src/session-id.ts(抽出conversationHeaderSource()+ 新增instructionsFingerprintExempt(),信任集及理由全写在注释里)、src/server.ts(Responses 分支对豁免信号按原文 keying,与 trusted codexTurn 分支同等待遇)、src/plugin.ts(新常量 + manifest 条目)、两个 opencode agent 插件(盖章)、PLUGIN.md(文档)、新增tests/responses-instructions-drift.test.ts。验证证据
src/server.ts重跑 → 两个 e2e 均失败(fork 复现),证明测试真的咬住了修复。npm run typecheck干净;npm test2169/2171 通过(2 skip = ACP_TEST_E2E gated);npm run build干净。E2E_CHECK=1零 token 预检通过;ACP_TEST_E2E=1全流程在本沙盒跑不了——本地 sglang upstream(127.0.0.1:8199)拒绝连接,环境问题,与本改动无关(codex identity 路径未动,bodysession_id仍走指纹)。建议合并前 manual-dispatch 跑一次 CI e2e 兜底。附带发现(仅报告,不开新 issue)
rebuildMessages先 pinfirstUserIndex再 prune)——有意设计,master 同样如此,与本 bug 正交;测试已用 seed 消息对规避并在注释里写明。cache_control断点稳定测试、Prepared.systemNotes通道形状)仍归属 feat: stable head-system anchor for prefix-cache preservation (#1085) #1092/Feature: content-addressed message store — ID-referenced tool results + acp_retrieve (built-in CCR) #1097,不在本 PR 范围。PR: #1104 (Fixes #1102)
ranxianglei commentedon Sep 22, 2026
附带发现提交 issue
本 issue 根本原因是按照 hash 判断消息导致的吗
ranxianglei commentedon Sep 22, 2026
[bot] 🏷 ## 回答:根因不是"按 hash 判断消息",是会话 key 的输入选择
先分清两个不同层次的 "hash"
① 消息级身份(健康,与本 bug 无关)
kernel 给每条消息分配 content-hash id + 单调递增的
mNNNNN引用号,会话内永不复用。压缩状态(block、折叠视图)是挂在会话上的,不是按消息 hash 找的。这一层工作正常。② 会话级命名空间(真正的根因所在)
master 上 Responses 分支的会话 key =
subagentNamespace(identity, instructions)(acp-kernel wire 模块),逻辑是:同一个 conversation id,第一次见到的 instructions 被锚定为基准;之后任何一轮 requests 里 instructions 文本变了 → fp 不等 → 会话 key 变成
<id>|sub:<fp>→ 孤儿会话,压缩状态归零。opencode 每次 AGENTS.md 编辑都把新内容重渲染进instructions,于是每编辑一次 fork 一次。所以根因是什么
不是 hash,是把"会中途变化的字段"放进了会话 key。 hash 在这里只是比较原语——把
hashId(instructions)换成字符串全等比较,这个 bug 一个字节都不会变。缺陷是设计决策层面的隐含假设:"instructions 变了 ⇒ persona 变了"。对 opencode 这类原生 id 就是 persona-scoped(一个人格一个 session id,子代理拿全新子 id)的客户端,这个假设不成立:instructions 变了但人格没变,那是 "same persona, updated system context"。PR #1104 的修法也印证这一点:不是删掉指纹机制(codex 线程跨人格复用同一 session id #150、Claude 子代理共享主 session id #970——对它们 instructions 变化确实意味着不同 persona,指纹必须保留),而是把已验证 persona-scoped 的信号(opencode 原生 ses_ 头 / 插件显式声明)从这一个维度里摘出去,按原文 keying。
一句话:病因在"key 由什么构成"(输入选择),不在"用什么方式比较"(hash 与否)。
关于"附带发现提交 issue"
系统规则规定工作会话不能开新 issue(自动开的 issue 会再触发 agent 会话,形成无限 issue/PR 循环;issue 必须由人发起)。所以我把可直接粘贴的 issue 稿准备好了,请你在对应仓库点一下新建:
第一条发现 → 归属
ranxianglei/acp-kernel(行为在 kernel 侧)标题:
正文(4 反引号内整段复制):
第二条发现(salvage 清单两项归属 #1092/#1097):这条不是缺陷,只是范围归属说明——c0b041c 的 cache_control 断点稳定测试和
Prepared.systemNotes通道形状本来就挂在已打开的 #1092/#1097 上,无需另开 issue;需要的话你在那两个 issue 里加一句交叉引用即可。ranxianglei commentedon Sep 22, 2026
问题你帮我报告
ranxianglei commentedon Sep 22, 2026
[bot] 🏷 已按你的指示代为提交。
acp-kernel#341(行为在 kernel 侧,故开在归属仓库):
ranxianglei/acp-kernel#341
[行为确认] rebuildMessages pin 住第一条 user message:即使被 active block 覆盖仍原样转发——请确认意图并写入契约文档来源: billion-context#1102 …分析时发现),含行为、代码证据(0.0.82 dist 核实的 pin 先于 covered 检查)、PR fix(responses): keep persona-scoped sessions stable across instruction drift #1104 的观测、影响、以及"若有意→写文档 / 若非有意→调整检查顺序"两条处理建议。说明:这条是行为确认 + 文档化类 issue,不是 bug 修复单;它不阻塞本 issue 的 PR #1104。第二条附带发现(salvage 两项归属 #1092/#1097)如前述只是范围归属,未单独开单。
@Dog 需要我改标题、加标签或补充内容的话直接说。
fix(responses): keep persona-scoped sessions stable across instructio…
fix: invert the Responses instructions fingerprint into a codex/claud…