Skip to content

[PR] pi lane: show a labeled effective-context line in the keyed footer status slot - #4621

Open
ranxianglei wants to merge 9 commits into
masterfrom
2026-10-24_pi-effective-context-line
Open

ranxianglei wants to merge 9 commits into
masterfrom
2026-10-24_pi-effective-context-line

Conversation

@ranxianglei

Copy link
Copy Markdown
Owner

Closes #3912

What / why

After a failed attempt's recovery omission, pi's native footer shows PI'S OWN raw-history projection estimate (chars/4 over the FULL unfolded local history — the #3912 repro reads 562.8% of the window) while the effective request bili sends is ~20%. bili keeps pi's local history unfolded on purpose (the wire carries the folded view; the disk copy stays raw for decompress fidelity), so the two numbers are measuring different things and neither is "wrong" — they just coexist with no explanation.

This PR gives the pi lane a persistent, labeled line for the PROXY's effective-request observation, rendered into pi's keyed status slot (ctx.ui.setStatus("billion-context", …)). Example from the repro shape:

bili 20.9% 104.7K/500.0K · usage · host est 562.8%

Behavior change disclosure

  • NEW visible surface (intended): the pi TUI gains one additive line in the footer status area. Before this PR there was no persistent context line in the pi lane (only transient /acp command output). The native footer itself is untouched (setFooter is never called) and other extensions' slots are untouched.
  • No changes to metering, wire format, compression behavior, or provider usage/cost reporting. The line only displays existing proxy observations (/__bili/plugin/status: contextTokens / contextTokensSource / contextTokensAt / contextLimit) plus pi's own read-only getContextUsage() for the reconciliation note.
  • Pi lane only (agent === "pi" gate); omp/dsh/opencode and all other lanes unchanged.

Semantics (per the issue's acceptance criteria)

  • Grade label on every number: usage = provider-measured input of the last settled request; est = bili's calibrated estimate of the current payload — what a FAILED request leaves behind (stamped fresh at prepare time, so failures never freeze the value at zero and real growth is tracked until the next settlement).
  • Staleness marker by observation age: <5 min none; 5–60 min · Nm; ≥60 min · stale.
  • Reconciliation note when |host − ours| ≥ 25 points: · host est N.N%; below that the numbers agree closely enough to stay quiet.
  • Honesty: no data / unknown grade → no line (a number is never rendered without its grade, nothing is clamped); unknown session, local tree rewind, session shutdown → the line clears instead of keeping stale/foreign values.
  • Refresh cadence: turn_end / agent_settled / after_provider_response (throttled 2 s, fire-and-forget — never blocks the host event loop); session_start (any reason) force-refreshes; generation counter prevents out-of-order writes from overlapping fetches.

Config surface

None. No new env var, config field, or CLI flag.

Tests

tests/issue3912-pi-context-line.test.ts (17 tests): renderer semantics — both directions of the grade labels, staleness tiers, divergence threshold at/below/above, honesty on missing/unavailable data — plus the wiring lifecycle against a live mock status endpoint: throttle (both directions), force-refresh bypass, no-cross-session-bleed clear, and silent degradation when the host lacks ui.setStatus or no proxy base resolves. Local verification: typecheck clean, 17/17 new tests + adjacent createBiliPlugin suites (incremental-ack-pull, pi-omp-fork-adopt, 25 tests) green; full-suite verdict left to CI.

Upstream root fix (out of scope here)

The number's producer is pi's estimator (estimateProjectedContextTokens invalidates the usage anchor after ANY recovery omission). A proper upstream contract (sourced/freshness-scoped effective context shared by the footer and core budget checks) lives in the pi repo and needs an owner-approved cross-repo submission per policy — it is documented in #3912 and deliberately not filed/submitted from this PR.

…ter status slot (#3912)

pi's native footer percent comes from pi's own projection estimator: once a
failed attempt's recovery omission lands after the last provider-usage anchor,
pi falls back to a chars/4 count over its FULL local history (which bili keeps
unfolded on purpose), so a healthy folded session can read 500%+ while the
effective request is ~20% of the window.

The pi lane now renders the proxy's effective-request observation into pi's
keyed status slot (additive - never replaces the native footer): grade label
(usage = provider-measured / est = calibrated estimate of the current payload),
staleness marker, and an explicit reconciliation note when pi's own estimate
diverges >= 25 points. Refreshed on turn_end / agent_settled /
after_provider_response (throttled 2s, fire-and-forget), force-refreshed on
session_start (any reason), cleared on session_tree / session_shutdown. An
unknown session clears the line instead of keeping previous numbers. Pi lane
only; no config surface, no wire changes.
@github-actions

github-actions Bot commented Oct 24, 2026 •

Copy link
Copy Markdown
Contributor

📦 Built Package Artifact

Branch: 2026-10-24_pi-effective-context-line (28de172)

Latest build — install this exact version

npm install -g billion-context@0.0.6169-pr.4621.213bc27

This exact version is immutable and reproducible. The rolling pr tag tracks the newest test build across all PRs.

Recent builds (commit → version)

commit version build
28de172 billion-context@0.0.6169-pr.4621.213bc27 build
c3faf4b billion-context@0.0.6082-pr.4621.6cf79ab build
6ad2110 billion-context@0.0.5985-pr.4621.807988b build
5a18a39 billion-context@0.0.5875-pr.4621.288f55a build
6d4e64c billion-context@0.0.5808-pr.4621.f203aee build
a1541e5 billion-context@0.0.5657-pr.4621.2e4a3f5 build
6961286 billion-context@0.0.5613-pr.4621.9e33554 build
754c04b billion-context@0.0.5592-pr.4621.3509d83 build

Download artifact

  1. Download the artifact from the Actions run
  2. Extract the tarball and install:
tar xzf billion-context-pr4621.tgz
npm install -g package

Install instructions are refreshed on each push.

@ranxianglei ranxianglei changed the title pi lane: show a labeled effective-context line in the keyed footer status slot [PR] pi lane: show a labeled effective-context line in the keyed footer status slot Oct 24, 2026
@ranxianglei

Copy link
Copy Markdown
Owner Author

🤖 Powered by ework · qwen3.8-27b

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

查重:不重复。 本 PR 就是 #3912 的交付物(Closes #3912),不是重复立项。相关条目核对:#1927(dashboard 方案 PR,已被 10-24 清理批次关闭,误关机制另在 #4613 跟踪)——本 PR 明确不搭它的车,走的是独立的 pi-only 最小行方案;#2855(已关闭文档 PR,范围不同)。open/closed 检索无其他同症状同机制条目。

标签: pi + scope/ui + p3(功能展示面,非缺陷;UX 增强、无可用性影响)。

身份与流程说明(先说清楚): 这个 PR 是上一个 ework-daemon 会话按 #3912 floor 8 自己推荐的「选项 2」实现的——但 floor 8 结尾是「等你拍板」,线程里没有你的明确选择,floor 9 就直接开工提了 PR。这违反了功能类「多方案须 owner 拍板后才实现」的顺序。缓解因素:方案与 issue 报告者自己提出的修复 A 一致、改动小且纯增量、合并权在你手里。本轮审核按独立审核做(重新读 diff、对照真实 pi 类型验证 API 声明、本地定向验证、查 CI),结论见后续八问回复;如果你认为选项本身不该选 2,这个 PR 可以直接打回,成本很低。

当前状态(进行中):

完整八问结论稍后补一条。

@ranxianglei

Copy link
Copy Markdown
Owner Author

🤖 Powered by ework · qwen3.8-27b

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

独立审核完成(未复用 issue 侧结论:重读了全量 diff、对照本机 pi 0.83.6 的 dist 类型与实现逐条验证 API 声明、本地定向跑测试、查了 CI 与在途 PR)。八问如下。

1. 是什么问题:pi 原生 footer 在一次失败请求触发恢复性省略后,显示的是 PI 自己对本地完整原始历史的投影估计(chars/4,复现读 562.8%/窗),而 bili 实际发出的有效请求只有 ~20%——两个数字都「没错」但量的是不同东西,界面上并排出现却无任何解释(#3912)。

2. 什么原因导致的:根因在 pi 上游——estimateProjectedContextTokens 在 usage 锚点之后出现任何恢复性省略就废弃锚点、退回全历史 chars/4;bili 按设计放大该现象(线上发折叠视图、本地磁盘保留原始历史以保 decompress 保真),但 bili 不是数字的生产者。所以本 PR 只修「展示层无解释」,不碰生产者(上游契约修复需跨仓审批,已在 PR 说明中明确留待)。

3. 影响范围与严重程度:仅 pi 车道用户;纯信息展示问题——footer 出现误导性高百分比但无标注。无可用性、计量、成本、压缩行为影响。p3。

4. 怎么修复的:在 pi 的 keyed status 槽位(setStatus("billion-context", …))加一行带标签的代理侧观测:bili 20.9% 104.7K/500.0K · usage · host est 562.8%。语义:每个数字带等级标签(usage=provider 实测 / est=bili 校准估计,失败请求留下的就是 est 且 prepare 时刷新打戳);按观测年龄加陈旧标记(<5min 无 / 5–60min · Nm / ≥60min · stale);|host−ours|≥25 个百分点才追加对账注记;无数据/未知等级→整行不出(绝不渲染无标签数字、不做任何 clamp);未知会话/树回退/会话关闭→清行不留外来值。刷新挂在 turn_end / agent_settled / after_provider_response(2s 节流、fire-and-forget 永不阻塞宿主事件循环)+ session_start 强制刷;生成代计数防重叠请求乱序写。机制层面:只读既有观测做展示,不改任何生产路径。

5. 是否有回归问题:未发现回归。逐项清点触碰路径的既有行为:

  • 原生 footer:setFooter 从未被调用,零改动 ✔
  • 其他扩展的槽位:只写自己的 key "billion-context",仓库与 pi dist 内无冲突 ✔
  • 既有事件处理器(session_start 身份注册、session_shutdown 子代理拆除、session_tree loadout 重断言、after_provider_response ack 通道 Delta lane: native-mode clients send only deltas, server maintains full state + one-time fold, upstream receives snapsho | 增量车道:native 模式客户端只发增量,服务端全量维护+一次折叠,上游只收快照(#2926 的泛化) #3248、omp repin):全部未动;新处理器注册在其后、内部全捕获、不可能阻塞或改变它们 ✔
  • metering / wire / 压缩 / provider usage·cost 上报:diff 零触及 ✔
  • omp/dsh/opencode 及其他车道:agent === "pi" 硬门控 ✔
  • 高危模式逐项过:无 fail-fast 变吞错(新代码只新增自己的软失败 UI 刷新,与文件内既有 fire-and-forget 模式一致)、无阈值/时序/输出格式漂移(新增行是披露过的增量面)。
  • 一个已验证的设计细节:TUI 切会话时 pi 先发旧会话 session_shutdown(reason new/resume/fork)再发新会话 session_start,所以是「清行 + 强刷」两段式,没有跨会话残留窗口;pi 实现里 setExtensionStatus(key, undefined) 即删除该 key(dist 源码确认)。
  • 非阻塞观察一条:after_provider_response 在流消费前触发,当次响应的 usage 记录可能尚未落定,行最多滞后一次响应,由后续 turn_end/agent_settled 刷新吸收——设计内可接受。

6. 是否破坏缓存:不涉及——请求内容、前缀、缓存键、重试/游标逻辑零改动。

7. 是否改了设计方向:没有。现有插件架构内的展示面增量,数据流仍走既有的 /__bili/plugin/status;上游根因修复方向不变(留 pi 仓库,owner 批准后再提)。

8. 是否引入新配置:没有。无 env、无 config 字段、无 CLI flag(config-surface-guard 绿)。

测试有效性(质量关):17 个测试是真测试——精确字符串断言钉住每个门的双向行为(等级标签两向、陈旧三档、25 点阈值含/不含边界、零/负/NaN token 与缺失 source 的诚实性);wiring 用真实 mock HTTP 端点跑生命周期(节流双向断言:连发事件不重取 + 强刷绕过;未知会话清行;宿主缺 setStatus/proxy 不可达时静默降级)。唯一小缺口:5min/60min 精确边界值未钉(逻辑是简单 >=,风险低)。本地实测:typecheck 干净、17/17 新测试 + 相邻 createBiliPlugin 套件 25/25 绿。

CI 状态:head 754c04b36 上唯一红 = unused-exports(INTERNAL_ONLY src/agent/client-build-note.ts: ClientBuildCheck),master(146b34f) 自身继承红,#4599 总控有记录;原修复 PR #4603 已关闭未合,现在由外部 PR #4606 一揽子清掉两个 master-red 门禁。该红还导致 test 矩阵全部腿被 skip(test job depends on unused-exports),故本 head 尚无全量套件判定——#4606 合入后 base 移动会自动重跑本 PR 的 CI,无需本侧动作。热文件检查:无其他在途 PR 触碰 src/agent/pi.ts。

流程事项(需要你拍板):如首条回复所述,上一会话在你要拍板选项时未等到选择就按自推方案实现了。代码本身我审下来是干净闭环,但选项合法性归你:A 追认选项 2、等 #4606 后看 CI 全绿即合;B 改道(比如并入 dashboard 路线)则此 PR 直接关,成本极低。合并权在你:#4621

…master-red #4606; same one-liner as #4606 commit 1, drop on rebase after it merges)
@ranxianglei

Copy link
Copy Markdown
Owner Author

🤖 Powered by ework · qwen3.8-27b

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

CI 修复完成(auto-fix lane attempt 1/2):本 PR 唯一红条 unused-exports 是继承性失败,已按几行级小修纪律在分支上直接修掉并推送,新 head 696128616。

八问

  1. 是什么问题:head 754c04b36 的 unused-exports 门禁报 INTERNAL_ONLY src/agent/client-build-note.ts: ClientBuildCheck——该类型所有引用都在本文件内却带 export,门禁拒绝。本 PR 的 diff 只动 src/agent/pi.ts(+112/-2)并新增 tests/issue3912-pi-context-line.test.ts,完全不碰那个文件,与本 PR 的改动无关。
  2. 什么原因导致的:[PR] dsh lane: note in-session when running an unverified @deepseek-ai/dsh client build (soft, exact-match) #4545 train 落 master(146b34f27)后,这个类型只剩文件内引用却保留了 export,去导出清扫漏掉了它 → master 自身即红,每个 rebase 到 tip 的 PR 都继承同一报错行。已在不含本 PR 任何改动的干净 origin/master worktree 本地复现:同一单条发现、同一退出码。
  3. 影响范围与严重程度:信号级问题——所有 rebase 到 master 146b34f27 的 PR 都多一条 unused-exports 红,检查矩阵被遮蔽(当前 CI 风暴的成员之一);无用户侧功能影响。
  4. 怎么修复的:按几行级小修纪律 + 本风暴先例([PR] fix(storage): block interval bounds survive post-fold resaves (#4592) #4607/[PR] fix(pi): inline mode now intercepts codex Responses WebSocket traffic (#4526) #4559/[PR] fix: verify responder identity before claiming a settled proxy origin (#4125) #4622/[PR] feat: host-stable tool-unit id side channel — ingress half (#2938 Tier-1 Increment 1; supersedes erroneously closed #298 | feat: host-stable tool-unit id side channel — ingress half (#2938 Tier-1 增量 1;接替误关的 #2981) #4615 等),在本 PR 分支去掉该类型的前导 export(独立标注 commit 696128616,与 [PR] fix(ci): clear the two master-red gates in one branch — unused-exports (#4602) + the #3890 LIVE_FILES tripwire (#4604) #4606 提交 1 同法)。安全性依据:type-only 声明、全仓 5 处引用全部在同文件(grep 实证)、非入口文件不进公共 d.ts surface → 行为中性。本地门禁 ✓ unused-export gate: clean (6 waived)。master 侧根治仍以 [PR] fix(ci): clear the two master-red gates in one branch — unused-exports (#4602) + the #3890 LIVE_FILES tripwire (#4604) #4606 为准(哨兵已接管、待 owner 合并);[PR] fix(ci): clear the two master-red gates in one branch — unused-exports (#4602) + the #3890 LIVE_FILES tripwire (#4604) #4606 合入后 rebase 时丢弃本重复 commit。
  5. 是否有回归问题:无。逐项审过:唯一改动是删一个前导 export 关键字,引用全在同文件,编译与运行时语义不变;无 wire 形状、配置、持久化、阈值/时序/输出格式变化。旧 head 上除 unused-exports 外其余 check 全绿或 skip,无其他红条。
  6. 是否破坏缓存:不涉及。
  7. 是否改了设计方向:没有。
  8. 是否引入新配置:没有。

结论:分支侧修复完成并已推送(754c04b36 → 696128616),本地门禁绿,等 CI 重触发确认;master 侧根治等 #4606 合并。

@ranxianglei

Copy link
Copy Markdown
Owner Author

🤖 Powered by ework · qwen3.8-27b

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

CI 判定(auto-fix lane attempt 2/2):11 条红全部是继承性失败,分支侧不再改动

失败的 11 个 check 全部是 test 分片(ubuntu-22×3 / ubuntu-24×3 / windows-22×5)。已取全部 11 个 job 日志逐一核对,报错行逐字一致:

process-spawning test files missing from LIVE_FILES in scripts/run-ci-tests.mjs: tests/issue3890-parent-gone-confirm-drain.test.ts. Register them there after reviewing their concurrency assumptions (#1248).

跑测试前的自检直接退出,零真实测试运行、零真实测试失败。同一 run(run 40141157076)其余 15 个 check 全绿——包括 unused-exports(attempt 1 的去导出修复已生效)、全部静态门禁/guards/docs/lock-sync/static-gates×2,仅 red-signal skip。

八问

  1. 是什么问题:新 head 696128616 的全部 test 分片命中 LIVE_FILES tripwire——master 自身的测试文件 tests/issue3890-parent-gone-confirm-drain.test.ts 会起子进程但未登记进 scripts/run-ci-tests.mjs 的 LIVE_FILES,门禁「未登记即失败」的设计让每个分片在跑任何测试前就退出。
  2. 什么原因导致的:tier-5 train 落 master(146b34f27)时该文件漏登记([PR] fix: route codex context-only prewarms to the probe relay via the upstream proxy #4595 最先发现上报);master 自身重型 test 车道在 schedule/push 事件按设计跳过,所以 master 面不显形,任何 rebase 到 tip 的 PR head 都继承。attempt 1 修掉 unused-exports 后静态门禁转绿,fail-fast 分层让 test 层第一次真正执行,这条继承红才显形(当时已预告:「单独推去导出单行,test 矩阵仍会撞 LIVE_FILES 常红」)。
  3. 影响范围与严重程度:信号级问题——波及所有 rebase 到 master 146b34f27 的 PR 检查矩阵(今天 18:00Z 起全舰队同签名报红:[PR] fix(storage): block interval bounds survive post-fold resaves (#4592) #4607/[PR] fix: report fold-substrate vacuum instead of staying silent (#2438 F1-a) #4617/[PR] feat: host-side conversation delete co-deletes compression artifacts (#2935) #2937/[PR] fix: HTTP-lane egress byte budget so image-dense sessions stop 503-looping (#3909) #4623/[PR] feat: add compress.preserveRecentTurns and protectUserMessages (#4593) #4620 等);无用户侧功能影响。
  4. 怎么修复的:分支侧不改,根治走 [PR] fix(ci): clear the two master-red gates in one branch — unused-exports (#4602) + the #3890 LIVE_FILES tripwire (#4604) #4606 提交 2(同一登记,已按 tests/claude-native.test.ts linux live-E2E subtests fail/hang in shared multi-agent sandboxes #1248 评审并发假设,在途待 owner 合并)。不重复小修的三条理由:① 与 [PR] fix(ci): clear the two master-red gates in one branch — unused-exports (#4602) + the #3890 LIVE_FILES tripwire (#4604) #4606 同根因,查重纪律一个根因一个 PR,风暴内其他分支([PR] fix(storage): block interval bounds survive post-fold resaves (#4592) #4607/[PR] fix: report fold-substrate vacuum instead of staying silent (#2438 F1-a) #4617/[PR] feat: host-side conversation delete co-deletes compression artifacts (#2935) #2937/[PR] fix: HTTP-lane egress byte budget so image-dense sessions stop 503-looping (#3909) #4623)判定一致;② 单独登记只会让分片继续往下跑、撞上已盘点的 ~35 用例 born-red 集群(CI Control Center: Centralized CI Failure Handling & Status Sync (Comment all CI issues here; do not open new issues) | CI 总控: CI 失败集中处理与状态同步(所有 CI 问题在此评论, 勿开新 issue) #4599 18:45 清单)——PR 依旧红,只是把「11 条 tripwire 红」换成「至多 11 条 born-red 红」,超出 auto-fix 车道范围;③ 登记 spawn 型测试需 tests/claude-native.test.ts linux live-E2E subtests fail/hang in shared multi-agent sandboxes #1248 并发评审,[PR] fix(ci): clear the two master-red gates in one branch — unused-exports (#4602) + the #3890 LIVE_FILES tripwire (#4604) #4606 已做过,重复登记不重审反而更差。
  5. 是否有回归问题:无。本轮分支侧零改动;attempt 1 的唯一改动(删一个前导 export)行为中性,其对应 check unused-exports 本 run 已绿。
  6. 是否破坏缓存:不涉及。
  7. 是否改了设计方向:没有。
  8. 是否引入新配置:没有。

结论:本 PR 的 11 条红全部继承,分支侧无可再修——唯一转绿路径是合并 #4606(哨兵 22:58Z 已确认:14 个 test 分片全在 required checks 里,当前没有任何 PR 能走正常按钮合并,需 owner admin override 解锁,详见 #4599 floor 57 的决策请求)。#4606 合入后本分支 rebase/重触发即全绿(rebase 时丢弃 attempt 1 的重复去导出 commit)。

ci-check added 7 commits October 25, 2026 10:10
master window commits 293ae65/de5e03659 bumped kernel/package.json to
0.0.165 without regenerating the lockfiles; lock-sync re-resolution then
rewrites the stale recorded versions (root 0.0.163, kernel 0.0.164) and
fails. Pure recorded-version sync via npm install --package-lock-only;
no dependency or semantic change.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

1 participant