Skip to content

acp_status 缝合报告:Compressible ranges/Nudge 读冻结的 ctx.nudge,压缩成功后旧区间与新块同框并存 #387

Closed

Description

@wosnxn123

症状(2026-08-31 取证,HEAD 仍在)

compress m00001-m00025 成功返回(54125 tokens saved、块 b1 激活)后,紧接着的 acp_status 在同一份输出里:COMPRESSED BLOCKS 区正确显示 b1 活跃,而 "Compressible ranges" 区仍列出刚被压掉的 m00001–m00025(25 msgs 54.1K)为可压缩,Nudge 行仍印旧值 ready: T1 54073——而 bili.log(11487 行)显示 nudge 缓存早在 16:37:56 已翻成 max compressible 4793。模型极易据旧 ranges 发起重复/错位压缩(本仓库取证里就有一次)。

根因

handleAcpStatus(bili src/loop/core.ts:136-156,dist 51221-51236):

  • base 报告读 ctx.session.state(压缩时被 applyRanges 原地更新,dist 50421)→ live;
  • ranges/protected 读 ctx.nudge —— frozen:ctx.nudge 仅在 processTurn 的 recommend/nudge 节点于请求 prepare 时生成(buildNodes,dist 45578-45592),循环内没有任何代码重新赋值 ctx.nudge(loop/core.ts 里 nudge 只有类型字段与读取,loop 内 re-request 走 adapter.buildRequest 不重过 processTurn);plugin 工具路径同样读 mem?.nudge(plugin.ts:417)。
  • 另:formatRanges(dist 43650-43725)把 compressible+protected 合成一列,陈旧的 protected 行还会伪装成可压缩项。

即一份报告内缝了两个新鲜度层级,状态互斥。

建议修复(择一,倾向前者)

  1. handleAcpStatus 内以 ctx.session.state + ctx.messages 现算 ranges/protected(复用 viableRanges 过滤,参照 dist 56272 的一次性过滤语义);
  2. (不推荐)在 Nudge/ranges 区块头标注 as of last request ——数据仍是错的,只是不撒谎。

验收标准

  • compress 成功后的同轮 acp_status:被压区间不再出现在 Compressible ranges;ready/nudge 数值与 state 派生一致
  • 单测:state 变更后立即 buildStatusReport,不经过新一次 prepare 也不得输出陈旧 ranges
  • 顺带核对 scope= 短路分支(loop/core.ts:140)与三处 dispatcher 副本(stream.ts dist 50376 / loop/core.ts dist 51194 / compress-loop-responses.ts dist 52880——后两者完全没有 Nudge/ranges 区块,同工具名不同协议输出不一致,建议一并收敛)

Activity

  1. ranxianglei commented on Aug 31, 2026

    @ranxianglei
    Owner

    🤖 ework agent · vllm-qwen/qwen3.8-27b

    已修复,PR: #397

    采用建议方案 1(现算),并顺带完成了验收标准第 3 条的收敛:

    改动

    • 新增 src/acp-status.ts 共享 handleAcpStatus:base 报告之后(保留原有 scope= 短路分支——已核实该分支只含 live base,无陈旧数据),用 kernel 的纯函数 processTurn 对 ctx.session.state + ctx.messages 现算 nudge(已逐一验证所有 pipeline node 返回新对象、syncBlocks 深拷贝 state,无副作用),tokenCount 取 session.stats.lastInputTokens(与下一次 prepare 完全同值,且 applyRanges 压缩后已即时扣减),ranges 复用 prepare 路径同款 viableRanges 一次性过滤。turn.state 刻意不采纳——不触碰 nudge 节奏簿记;现算失败时降级为 base-only,绝不输出陈旧数据。
    • 三处 dispatcher 副本收敛:stream.ts(executeAnthropicProxyTool)与 compress-loop-responses.ts(executeProxyTool)原先裸调 buildStatusReport 且忽略全部 options,现在统一委托共享 handler——三种协议输出同一形状,且都支持 scope/view/tool/sort/limit。
    • 删除 LoopCtx.nudge 字段及其两处赋值点(server.ts、plugin.ts)——冻结快照从此无法再漏进报告;plugin 工具路径自动获得 live 行为。

    测试(tests/acp-status.test.ts,3 个新测试)

    1. 验收 2:真实 applyRanges 压缩后不经过新 prepare 立即 handleAcpStatus → 被压 refs 不再出现于 Compressible ranges,b1 活跃,Nudge 行与 state 派生一致(实测:Nudge: idle — max compressible 1250 < threshold 50000,ranges 只剩 m00007–m00007)。
    2. scope= 短路:仅 base,无 ranges/Nudge 区。
    3. 验收 1 端到端:走 runCompressLoop + responses adapter,同轮 compress + acp_status——acp_status marker 不再列出刚压掉的区间。

    Pre-flight:typecheck 干净;npm test 871/871 通过(868 旧 + 3 新);build 成功。E2E(codex 套件)本环境无 codex 二进制/本地 upstream 跑不了,已在 PR body 注明,可走 CI 手动触发。

    顺带发现(未改,建议另开 issue):plugin UI 面板 buildStatusPanel(src/plugin.ts)仍读 prepare 时刻的 nudge 快照做展示——同类陈旧问题、不同表面,超出本 issue 范围,已在 PR body 标注为 follow-up。

  2. added a commit that references this issue on Sep 6, 2026
    1a1178d
  3. ranxianglei commented on Sep 6, 2026

    @ranxianglei
    Owner

    Update on the third sub-symptom: the /acp panel served to thin plugins (pi / dsh / opencode, GET /__bili/plugin/status) had the same staleness defect, now fixed in PR#397 as well (commit 1a1178d).

    Root cause (panel path): handlePluginStatus (src/plugin.ts) built the panel with the nudge remembered at the last model request (prepare-time snapshot). A compress executed through the plugin tool API mutates session.state without re-running prepare, so between the compress and the next request the panel mixed live blocks with stale, already-consumed ranges — the "old ranges and new blocks in the same frame" effect.

    Fix: the panel now recomputes the nudge on every status request — processTurn over the remembered pre-fold view against the current session.state (same arbitration as the acp_status tool path). If recompute fails, the nudge/ranges sections are omitted rather than falling back to the stale snapshot.

    Verification: new e2e in tests/plugin-protocol.test.ts ("plugin status panel recomputes the nudge after a mid-turn compress") — drives a real conversation, compresses m00001..m00002 via the tool API, asserts the panel lists the new block and no longer recommends the consumed range. Pre-fix this test fails (stale nudge keeps listing the consumed range).

    Also confirmed while investigating (no changes needed):

    • acp-kernel (v0.0.54): buildStatusReport / buildStatusPanel / viability filter are pure functions of caller-passed state — the kernel computes the nudge fresh per processTurn; no defect on that side.
    • billion-context-pi: status-tool / commands both call runtime.core.processTurn fresh per invocation — clean, no issue filed.

    PR#397 head is now 1a1178d (acp_status tool fix + dispatcher unification + this panel fix).

  4. ranxianglei commented on Sep 6, 2026

    @ranxianglei
    Owner

    🤖 ework agent · qwen3.8-27b

    [bot] 🏷 收到面板路径的更新(PR#397,head 1a1178d,已确认 open、待合并)。同步一下本 issue 我这条线的收尾状态,均已实测验证:

    内核修复(批量门文案)— 已发布

    • acp-kernel PR fix: normalize localhost bind host; simplify codex web card to url-only #175 已于 2026-08-31 合并,修复随内核发布;billion-context master 现 pin acp-kernel: 0.0.54(v0.1.87 起捆绑)。
    • 端到端验证:下载 npm 上 acp-kernel@0.0.54 的发布 tarball,grep 整个 dist —— "renumber" 0 处。验收标准第 3 条(全仓库用户可见文本不再出现该断言)在真实发布产物上成立。

    本仓库最后残留 — 新 PR:#578

    汇总:三个子症状至此各有归属——① 批量门假文案(内核 PR#175,已随 0.0.54 发布)、② acp_status 工具快照陈旧(PR#397)、③ /acp 面板快照陈旧(PR#397)。待 PR#397 与 PR#578 合并后,#387 的全部验收标准闭环,可以关闭。

  5. added a commit that references this issue on Sep 7, 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

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions