Skip to content

[PR] fix: cap ineffective pi tool re-registration with verify + backoff (#6080) - #6107

Open
ranxianglei wants to merge 5 commits into
masterfrom
2026-11-10_pi-reassert-backoff
Open

ranxianglei wants to merge 5 commits into
masterfrom
2026-11-10_pi-reassert-backoff

Conversation

@ranxianglei

Copy link
Copy Markdown
Owner

Problem

Long-lived pi sessions (pi 1.5.0 + bili 0.1.213, ~8h with a codemode default→only switch + reload) showed two correlated anomalies that both vanished on pi restart:

  • A: paired dropped from the host registry — re-registering (#2708) warns on every turn (544 lines over 82 min) — the self-heal never converged.
  • B: the host's hiddenDeclarations computed stale (fresh SDK probe = 24 hidden vs live session = 13), leaking 14+ direct tool declarations into requests.

The reporter's ACP_DUMP_BODY comparison (INCOMING vs REQ tools byte-identical) exonerated the forwarding path: B happens inside the pi process's loadout computation, and both anomalies rose and fell together with the re-register churn.

Root cause

reassertDroppedTools (src/agent/pi.ts) re-registered on every detection with no effectiveness check and no backoff. It is called from two independent per-turn hooks (before_agent_start + before_provider_headers) — the source of the paired warns. When the host's registry no longer reads our instance map (pi runner/instance generation drift after a mid-session mode switch/reload; the exact pi-side drop source is outside this repo), every attempt landed in a dead map and the loop churned forever. Each registerTool synchronously triggers a full _refreshToolRegistry() → active-set recompute + system-prompt rebuild + prepareLoadout hook execution in pi 1.5.0 — up to 12 such rebuilds per broken turn injected mid-turn-prep. That is the perturbation surface behind anomaly B.

Fix

reassertDroppedTools now verifies its own effect:

Backoff default 10 min, injectable via the existing createBiliPlugin(..., opts) channel for tests (no new config/env surface).

Behavior change (disclosed)

Old = re-register on every detection (unbounded per-turn in a broken state). New = immediate first attempt, then at most one attempt per 10 min until effective or scenario change. In the healthy case nothing changes (first attempt sticks, backoff never engages); in the broken case churn drops from ~2×6 registerTool calls per turn to ≤1×6 per 10 min, removing the loadout-perturbation source of anomaly B.

Tests

Targeted (tests/plugin-agent.test.ts, same fake-pi harness as the #2708 suite):

All four existing #2708 tests stay green (transient heal unchanged). Full-suite verdict comes from CI on this head.

Note: if anomaly B persists in a session where NO dropped/re-register events fire at all, that residual would be a pure pi-side bug to report upstream — this PR removes the bili-side perturbation source.

Closes #6080

@github-actions

github-actions Bot commented Nov 10, 2026 •

Copy link
Copy Markdown
Contributor

📦 Built Package Artifact

Branch: 2026-11-10_pi-reassert-backoff (735d3f7)

Latest build — install this exact version

npm install -g billion-context@0.0.10670-pr.6107.37241f1

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
735d3f7 billion-context@0.0.10670-pr.6107.37241f1 build
4920ab6 billion-context@0.0.10526-pr.6107.ddd4a83 build
a5a39b1 billion-context@0.0.10520-pr.6107.b7094f6 build
d559c55 billion-context@0.0.10518-pr.6107.34066ba build
afa0271 billion-context@0.0.10517-pr.6107.b41fe6d build
84530b2 billion-context@0.0.8899-pr.6107.a4cd9f3 build

Download artifact

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

Install instructions are refreshed on each push.

@ranxianglei ranxianglei changed the title fix: cap ineffective pi tool re-registration with verify + backoff (#6080) [PR] fix: cap ineffective pi tool re-registration with verify + backoff (#6080) Nov 10, 2026
@ranxianglei ranxianglei added bug Something isn't working p2 pi scope/wiring labels Nov 10, 2026
@ranxianglei

Copy link
Copy Markdown
Owner Author

🤖 Powered by ework · qwen3.8-27b

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

查重: 不重复 — searched mirror + upstream for #6080, reassertDroppedTools, and the pi re-registration topic: no other open or closed thread covers this mechanism; this PR thread is the only one.

标签: bug · pi · scope/wiring · p2 — pi plugin-lane self-heal defect (client wiring layer); session stays usable but churns warns every turn and perturbs the host loadout until restart → p2, not p1 (no unavailability, no unbounded growth/cache leak). Applied to both the mirror thread and PR #6107 (which was unlabeled).

Review in progress: fetched head 84530b29 (branch 2026-11-10_pi-reassert-backoff, 1 commit, src/agent/pi.ts +60/−10, tests/plugin-agent.test.ts +139), code read-through done, targeted test run starting locally; CI suite still running on the mirror (no cached checks yet). Structured verdict to follow.

@ranxianglei

Copy link
Copy Markdown
Owner Author

🤖 Powered by ework · qwen3.8-27b

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

结论先行:CI 已转绿。本次是 Windows 负载下的瞬时抖动(flake),重跑即绿,未改动任何代码,diff 保持干净。

查重: 不重复 —— 这是既有 PR 的 CI 红灯自动修复车道,非新缺陷报告;按政策未为本次抖动单独立项。

结构化七问:

  1. 是什么问题:PR head 84530b296a 有两个测试分片红——test (windows-latest, 22, 2) 与 test (windows-latest, 22, 3);其余全绿(ubuntu 6 分片、windows 1/4/5、static-gates×2、mysql-contract)。

  2. 什么原因导致的:三个失败用例与本 PR 改动无关。本 PR 只动 src/agent/pi.ts(pi 工具重注册 backoff)+ tests/plugin-agent.test.ts;实际失败的是:

    • tests/fork-replica-convergence.test.ts #2960 ②:error: 'fetch failed',出在测试自己的 request() helper(fork-replica-convergence.test.ts:55)访问本地 proxy 的传输层,尚未走到任何机制断言;
    • tests/wire-exit-matrix.test.ts 两个 abort 用例(openai-sse / anthropic-sse):断言 up.socketsClosed() >= 1 拿到 closed=0(客户端中止后上游 socket 未在 awaitUpstreamTeardown 有限窗口内销毁)。两者耗时 23.9s / 21.6s,而同族 proxy-responses-sse(156ms)、proxy-json(427ms)毫秒级通过——典型 Windows 负载下事件循环被饿过固定预算(CI: windows-latest node-22 shard 2 intermittently red on timing-sensitive e2e tests under load (rotating flakes: issue760, #4079, storage-full-flip #3818) #4161 家族),非断言回归。
    • 佐证:本 PR 未动 ci-shard-weights.json,分片确定性划分在 master 上一致,故非 PR 引入的重新分片,属环境性抖动。
  3. 影响范围与严重程度:仅该次 windows node-22 两分片;对产物/用户零影响(PR 自身 plugin-agent.test.ts 通过,功能正确)。严重度:CI 流程一度红的体验瑕疵,非可用性缺陷。

  4. 怎么修复的:判定为瞬时 flake 后走最小侵入——GitHub Actions rerun-failed-jobs 只重跑两个红分片(HTTP 201),不改代码、不动 diff、不开新 issue(契合 CI 协调政策:CI 问题不塞进 PR、不为 CI 单独立项)。重跑后 run_attempt 2 两分片转绿,整 run conclusion=success。

  5. 是否有回归问题:无。零代码改动,无行为漂移;重跑后全量分片(ubuntu×6 + windows×5 + static-gates×2 + mysql-contract)全绿。

  6. 是否破坏缓存:不涉及(未触碰任何缓存/重试/游标逻辑)。

  7. 是否改了设计方向 / 引入新配置:均不涉及。纯 CI 运维动作(重跑),零代码、零配置变更。

收工判定:CI 已绿,PR 可进入人工评审/合并(合并权在 owner,我不代合)。若此类 windows 负载抖动复发,建议归入 CI 总控 #4599 跟踪——其中 wire-exit-matrix 的 socket-teardown 字面量目前不在 #4161 自动重试分类器内,可考虑补一条;本次不另立 issue。

@ranxianglei

Copy link
Copy Markdown
Owner Author

🤖 Powered by ework · qwen3.8-27b

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

Review complete — verdict: ready to merge; the merge itself stays human.

What I did and verified live (tools, not memory):

CI state (live-verified via mirror cache + single API pulls):

  • Main CI run on head: all 28 jobs green. The initial run had exactly two reds — test (windows-latest, 22, 2) and (windows-latest, 22, 3) — both now green after a rerun.
  • Those two reds are environmental flakes in files this PR does not touch: tests/fork-replica-convergence.test.ts (TypeError: fetch failed, undici vs the local fake server) and tests/wire-exit-matrix.test.ts ×2 ("upstream socket(s) … closed=0" after ~20 s teardown waits, while adjacent abort variants passed in <500 ms on the same runner). The rerun on the identical commit (06:14–06:21Z) passed both. Note for honesty: that rerun predated my session's first rerun attempt (which then no-op'd with 404 = "no failed jobs left"), so I am not claiming it. Flake observation logged in CI Control Center: Centralized CI Failure Handling & Status Sync (Comment all CI issues here; do not open new issues) | CI 总控: CI 失败集中处理与状态同步(所有 CI 问题在此评论, 勿开新 issue) #4599.
  • Observation only, unattributed: a batch of extra E2E workflows was dispatched at 06:03Z for this SHA and almost all were cancelled (one success: e2e-native-dsh). I can't see who triggered it from here.

Code review (direction → regression → code → tests → diff):

  • Direction (bug: per-turn re-register loop races pi loadout → stale declarations #6080): root cause correctly identified — reassertDroppedTools retried unconditionally on every per-turn hook call, so against an instance map the host no longer reads it churned forever (paired warns = symptom A), and each registerTool synchronously rebuilds pi's registry/loadout mid-turn-prep (the perturbation behind symptom B). The fix removes the producer — verify effect, back off when ineffective — rather than masking the symptom.
  • Mechanism correctness: reassertDroppedTools is fully synchronous, so check→set of the backoff is atomic under JS single-threading — both hooks firing in one turn cannot double-burst (test asserts exactly one burst). Natural heal is still picked up immediately (the missing-empty early return precedes the backoff check). Probe-throw semantics preserved: pre-probe throw → return unchanged; post-probe throw → treated as ineffective (conservative, one burst already spent, which matches master's spend for that turn). Scenario changes (fresh sid registration, session_tree) clear the backoff so a new episode heals immediately.
  • Regression audit of prior behaviors on touched paths: (1) transient-drop heal pi-native: tools register once per session id, so a pi tool-registry rebuild silently removes compress/decompress/... for the rest of the session #2708 — unchanged (legacy tests green); (2) drop-warn message text — byte-identical; cadence in the broken state drops from every-turn to ≤1/10min — that IS symptom A's fix, disclosed in the PR body; (3) throwing-probe guard — unchanged; (4) fresh-sid registration — additive backoff-clear only; (5) pi-native: /tree rewind resets the active tool loadout from the transcript, so bili tools become registered-but-inactive ("Tool compress not found") and the #2708 self-heal cannot see it #3542 tree-loadout re-assert — function untouched, additive clear before it; (6) no wire/message-shape, config-schema, persistence, kernel, or cache/cursor changes; proxy mode has no tool-registration path, so both compression modes reasoned through and unaffected.
  • Tests: real teeth — exact registerCall counts across both hooks, exact log-line counts per episode, negative terminal-surface assertion ([Bug][native lane] #2827 同机制的剩余面:其他 native 车道的会话中途 console.* 仍直写宿主终端 #2831 pattern), and both directions asserted (churn capped AND no stale suppression: a later transient drop heals immediately; host-converges case goes quiet). Deterministic via injected reassertBackoffMs — no real-time waits. Gate-test discipline satisfied.
  • Quality bar: named constant with rationale comment in the file's existing style, no magic numbers, no new env/config surface (opts injection channel already exists — config-surface discipline respected), no as any/@ts-ignore, clean diff (every line on-topic, no lockfile/version churn).
  • Residual boundary (acknowledged, not a defect): if anomaly B ever persists with zero dropped/re-register events firing, that residual is a pure pi-side bug to report upstream — this PR removes the bili-side perturbation source, as its body states.

结构化八问(PR #6107):

  1. 是什么问题: pi 长会话中,当宿主注册表读不到插件的工具映射时(会话中途切模式/reload 后的实例代际漂移),每轮的两个钩子都无条件重新注册工具——永不收敛,且每次注册同步触发宿主全量 registry/loadout 重建,造成 warn 每轮刷屏 + 宿主 hiddenDeclarations 投影变脏。
  2. 什么原因导致的: reassertDroppedTools 无效果验证、无退避:注册落进死映射后循环空转;扰动源是每轮多次 registerTool 触发的宿主重建风暴。修的是生产者(无条件重注册机制),不是症状。
  3. 影响范围与严重程度: 仅 pi 插件车道、且仅在宿主实例代际漂移的坏态下触发;能用但体验受损(成对 warn + 多余工具声明泄漏进请求),重启可解 → p2。健康路径零行为变化。
  4. 怎么修复的: 注册后回探验证效果:有效即清退避(pi-native: tools register once per session id, so a pi tool-registry rebuild silently removes compress/decompress/... for the rest of the session #2708 原行为不变);无效则一次诊断 + 10 分钟退避窗(窗内只探测不重注册),到期再试一次、再失败再开窗;新 sid 注册或 /tree 导航清窗,保证新事件立即自愈。退避时长走既有 createBiliPlugin opts 注入通道(测试用),无新配置/env 面。
  5. 是否有回归问题: 逐项审过——瞬时丢失自愈(不变)、drop warn 文案(逐字不变)、探针异常守卫(不变)、新 sid 注册与 pi-native: /tree rewind resets the active tool loadout from the transcript, so bili tools become registered-but-inactive ("Tool compress not found") and the #2708 self-heal cannot see it #3542 tree 重断言(纯加性清窗)、wire/配置/持久化/kernel(未触碰)。坏态下 warn 频率从每轮到 ≤1次/10min 属有意变更且已披露。未见回归。
  6. 是否破坏缓存: 不涉及(未触碰任何缓存/游标/去重键机制)。
  7. 是否改了设计方向: 不涉及——同一自愈机制内加效果验证与退避,架构/边界/数据流未变。
  8. 是否引入了新的配置: 不涉及用户可见配置(reassertBackoffMs 仅内部 opts 注入,默认 10min 常量)。

判定: 方向正确、代码与测试扎实、head 上 CI 全绿(含 flake 重跑确认)——可合。合并动作留给人工: #6107

The #2708 self-heal re-registered dropped bili tools on every detection,
with no effectiveness check and no backoff. When the host's registry no
longer reads our instance map (pi runner/instance generation drift after
a mid-session mode switch/reload), it churned forever: paired
dropped->re-registering warns on every turn for 82 minutes (544 lines),
and each re-register synchronously rebuilds the host's whole registry +
active loadout mid-turn-prep, which left the host's hiddenDeclarations
stale (#6080 anomaly B).

reassertDroppedTools now verifies its own effect: a transient drop still
heals in the detecting turn (behavior unchanged since #2708); an
ineffective attempt logs one distinct diagnostic and enters a 10-minute
backoff during which probes continue but no further registerTool churn
happens; a fresh registration or a tree navigation clears the backoff.

Behavior change: old = re-register on every detection (unbounded per-turn
in a broken state); new = immediate first attempt, then at most one
attempt per 10 min until effective or scenario change.
@ranxianglei
ranxianglei force-pushed the 2026-11-10_pi-reassert-backoff branch from 84530b2 to afa0271 Compare November 16, 2026 22:51
@ranxianglei

Copy link
Copy Markdown
Owner Author

🤖 Powered by ework · qwen3.8-27b

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

本轮处理 PR #6107 与 master 的合并冲突(merge state: dirty),已完成 rebase 并推回,冲突解除。

结构化八问

  1. 是什么问题:PR 分支 2026-11-10_pi-reassert-backoff 与 base 分支 master 冲突,GitHub 判定 mergeable=False / mergeable_state=dirty,无法合并。

  2. 什么原因导致的:PR 切出后 master 前进了 754 个提交。冲突面很窄——只有 src/agent/pi.ts 的 createBiliPlugin 签名一处:master 在该签名上方插入了 nudge-debug 模块级变量(nudgeDebugWired / nudgeNotifiedTurns / nudgeFullPending),而本 PR 修改了同一行的函数签名(opts 增加 reassertBackoffMs?)及其紧随其后的 state 初始化行。两改动落在相邻行 → git 判定内容冲突。tests/plugin-agent.test.ts master 未改动,干净应用(无冲突)。

  3. 影响范围与严重程度:仅本 PR 分支自身;冲突集中在 1 个文件的 1 个区域,测试文件无冲突。属「无法合并」级别的阻塞(不解决就合不进),非行为缺陷、非线上问题。

  4. 怎么修复的:把分支 rebase 到当前 master(301e1a5459);对该唯一冲突做并集解决——同时保留 master 的 nudge-debug 变量块与 PR 的 reassertBackoffMs 签名/state 初始化,仅删除冲突标记。本地验证全绿:typecheck(exit 0)、tests/plugin-agent.test.ts 79/79 通过(含 3 个 backoff 用例)、root tsup build(exit 0)。随后 force-push 回 PR 分支——本次为最终 head,不带 [ework:ci-held] 标记,触发一次完整 CI。

  5. 是否有回归问题:rebase 本身不改变行为;冲突解决是纯并集,两侧改动逐字保留(master 的 nudge-debug 接线 + PR 的 backoff 机制),无语义漂移、无 fail-fast 变吞错、无阈值/时序/输出格式变化。本地 typecheck + 定向测试 + build 全绿;完整回归由远端 CI 把关(已触发,30 项 check:8 success / 6 skipped / 16 queued,暂无失败)。

  6. 是否破坏缓存:不涉及——未触碰任何缓存 / 重试 / 增量游标 / 去重键逻辑。

  7. 是否改了设计方向:不涉及——仅把 PR 与 master 既有改动对齐,未改架构 / 边界 / 数据流。

  8. 是否引入新配置:不涉及——rebase 未新增任何 env / config / 默认值(reassertBackoffMs 是 PR 原有代码,非本轮引入)。

结论:冲突已解决,PR 现 mergeable=True(mergeable_state=blocked 仅因新 head 的完整 CI 仍在跑)。rebase 后 head afa0271bdf 正好落在当前 master 之上(1 commit ahead / 0 behind),单提交结构保持。等 CI 全绿即可由人工合并。

@ranxianglei

Copy link
Copy Markdown
Owner Author

🤖 Powered by ework · qwen3.8-27b

[ework] CI fix verified green ✓

@ranxianglei

Copy link
Copy Markdown
Owner Author

🤖 Powered by ework · qwen3.8-27b

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

Re-verified the live check state first: head afa0271bdf had 4 failing checks — 3 test shards (ubuntu 22.3 / ubuntu 24.3 / windows 22.4) + architecture-docs. All 4 are inherited master-level failures, not caused by this PR:

Confirmed ci-fixes (the sentinel's master-fix convergence branch) already carries the exact fixes for both (the arch-docs one-line entry + the #2929 fold-probe schedule-independence recalibration), with a net diff of only those 2 files and zero kernel/pi-subagents drift. Per the CI-coordination policy (2026-10-24) I did not re-fix master-level issues on this branch — I merged ci-fixes in.

Action this run:

  1. Merged ci-fixes into the PR branch → merge commit d559c55cc9. Net diff vs master = this PR's 2 files + the 2 ci-fixes fix files; no unrelated churn.
  2. Verified locally: typecheck 0, build 0, architecture-docs guard all-green, tests/plugin-agent.test.ts 79/79, codex 命中率问题分析 #2929 fold-probe test 1/1.
  3. Pushed d559c55cc9 as the final head (no [ework:ci-held] marker — this is the branch's one full CI pass).

PR now: head d559c55cc9, base master 301e1a5459, mergeable=true (state=blocked only because the fresh CI pass is still running). The PR's own code (pi tool re-registration backoff) is untouched and introduced no regression.


八问

  1. 是什么问题: PR 分支 CI 红了 4 个 check(3 个 test 分片 + architecture-docs);都是继承自 master 的既有失败,不是本 PR 代码引入。
  2. 什么原因导致的: ① architecture-docs — master 在 [Bug] Inconsistent system prompt separator in Responses internal re-request breaks cache prefix | [Bug] Responses 内部重请求的系统提示分隔符不一致,破坏缓存前缀 #6922 新增 src/responses-system-sections.ts 却没把它写进 reference/architecture.md 模块地图,guard 要求每个 src/ 文件都在地图里;② 3 个 test 分片 — 同一个 schedule 敏感的 flaky 测试 #2929: nudge + proxy-tool-round fold keeps re-request/next-turn byte-stable,在各分片跑到的副本上各自挂掉。
  3. 影响范围与严重程度: 仅阻塞本 PR 的 CI 绿灯(合并被 block),不影响任何运行时行为;属 master 级既有问题。
  4. 怎么修复的: 按 CI 协调政策(2026-10-24),master 级失败收敛到 ci-fixes 哨兵分支、不在自己分支重复修;确认 ci-fixes 恰好带这两个修复且 net diff 只动 2 个文件、零 kernel/pi-subagents 漂移后,把 ci-fixes merge 进 PR 分支,本地验证后作为最终 head 推送。
  5. 是否有回归问题: 无。merge 只带入 arch-docs 文档行 + codex 命中率问题分析 #2929 测试自身两个 ci-fixes 文件,不碰本 PR 的 pi.ts 逻辑,也不动任何运行时/协议/缓存路径;本地 typecheck/build/arch-docs guard/plugin-agent 79 测试全绿。
  6. 是否破坏缓存: 不涉及。改动面是文档地图 + 一个测试文件,不碰任何缓存/重试/游标/去重逻辑。
  7. 是否改了设计方向: 不涉及。纯 CI 继承失败处置,无架构/边界/数据流转向。
  8. 是否引入了新的配置: 不涉及。无新 env/config/默认值。

判定: 4 个红 check 的根因(master 级继承失败)已消除,最终 head d559c55cc9 已推送,等 CI 全量重跑转绿即可合并;本 PR 自身改动未动、未引入回归。

@ranxianglei

Copy link
Copy Markdown
Owner Author

🤖 Powered by ework · qwen3.8-27b

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

This event is a stale re-delivery — it references head afa0271bdf, which has already been superseded. The 4 failing checks it lists (3 test shards on the #2929 flaky test + architecture-docs) were all inherited master-level failures, already fixed in the previous run by merging ci-fixes → new head d559c55cc9.

Live state (mirror cache, fresh this run): head d559c55cc9; the test shards are in_progress (the fresh CI pass triggered by that push), no failures reported yet; static-gates / mysql-contract / gate / unused-exports already green.

Nothing left to fix this run — the reported failures are already addressed and the authoritative CI pass on d559c55cc9 is still running. Stopping without further work (no re-fix, no re-push).

A loaded runner can drift a real sleep(80) past (or short of) the 40ms backoff window, so the suppressed / burst-after-expiry assertions flake (windows 22,3: expected 6, actual 8). Freeze Date.now() and advance it explicitly instead of relying on real-time margins.
@ranxianglei

Copy link
Copy Markdown
Owner Author

🤖 Powered by ework · qwen3.8-27b

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

Re-verified live: head d559c55cc9 had exactly 1 failing check — test (windows-latest, 22, 3). All other checks (including the 4 from the previous event, already fixed by the ci-fixes merge) are green.

Diagnosis: the failing test is this PR's own #6080: after the backoff window expires, exactly one more attempt is made (tests/plugin-agent.test.ts:1093, expected 6, actual 8). It's a real-clock flake: the test uses a 40ms backoff window + sleep(80), and on a loaded Windows runner the real gap between the 2nd and 3rd before_provider_headers events exceeded 40ms, so the backoff window expired early and an extra re-registration burst fired (8 instead of 6). The sibling test #6080: a host that starts accepting registrations converges and goes quiet shares the same real-clock dependency and could flake too.

Fix (test-only, no production code change): drive the clock explicitly — freeze Date.now() and advance it by 80ms at the backoff-expiry point, instead of relying on a real sleep(80) vs a 40ms window. Both timing-sensitive #6080 tests are now deterministic.

Verified locally: typecheck clean; full tests/plugin-agent.test.ts 79/79; the 3 #6080 tests 3/3.

Pushed a5a39b125a as the final head (no [ework:ci-held] marker — this is the branch's one full CI pass). The PR's production code (src/agent/pi.ts backoff logic) is untouched.


八问

  1. 是什么问题: PR 分支 CI 红了 1 个 check(windows 22,3 test 分片);挂的是本 PR 自己加的测试 #6080: after the backoff window expires, exactly one more attempt is made,不是生产代码问题,是测试本身依赖真实时钟导致 flake。
  2. 什么原因导致的: 该测试用 40ms backoff 窗口 + sleep(80) 验证「窗口过期后恰好再试一次」;在负载高的 Windows runner 上,第二次与第三次 before_provider_headers 事件之间的真实间隔超过了 40ms,backoff 窗口提前过期,多触发了一次重注册 burst(8 次而非 6 次)。同族的「converges and goes quiet」测试有相同的真实时钟依赖,同样会 flake。
  3. 影响范围与严重程度: 仅影响本 PR 的 CI 绿灯(合并被 block);不影响任何运行时行为——生产代码(src/agent/pi.ts 的 backoff 逻辑)完全没动,只是测试的计时方式不可靠。
  4. 怎么修复的: 纯测试改动,不碰生产代码——把 Date.now() 冻结并显式推进(在 backoff 过期点 fakeNow += 80),取代对真实 sleep(80) vs 40ms 窗口的依赖,让两个 timing-sensitive 的 bug: per-turn re-register loop races pi loadout → stale declarations #6080 测试都变成确定性的。
  5. 是否有回归问题: 无。改动面只有 tests/plugin-agent.test.ts 两个 bug: per-turn re-register loop races pi loadout → stale declarations #6080 测试的计时方式,断言逻辑(验证 backoff 抑制 / 过期后重试 / 收敛)完全不变;本地 typecheck 干净、全文件 79/79、bug: per-turn re-register loop races pi loadout → stale declarations #6080 三测全过。
  6. 是否破坏缓存: 不涉及。纯测试计时改动,不碰任何缓存/重试/游标/去重逻辑。
  7. 是否改了设计方向: 不涉及。纯测试确定性修复,无架构/边界/数据流转向。
  8. 是否引入了新的配置: 不涉及。无新 env/config/默认值。

判定: 唯一红 check 的根因(本 PR 测试的真实时钟 flake)已消除,最终 head a5a39b125a 已推送,等 CI 全量重跑转绿即可合并;生产代码未动、未引入回归。

…sh sid)

The Fix section claims a fresh registration (new sid) or a tree navigation
clears the reassert backoff so a new episode heals immediately, but no test
exercised either clear path. Add one test per path:

- a /tree rewind (session_tree) clears the backoff — a new attempt fires
  immediately on the next turn instead of waiting out the window;
- a fresh registration for a new sid clears the backoff — a later drop on
  the new sid heals immediately.

Both reuse the existing makeDroppingRegister / frozen-clock harness.
@ranxianglei

Copy link
Copy Markdown
Owner Author

🤖 Powered by ework · qwen3.8-27b

已顺手修:补了两条退避清除路径(session_tree 导航 + 新 sid 注册)的缺失测试,PR「Fix」声称但无测试覆盖 + commit 4920ab6

@ranxianglei

Copy link
Copy Markdown
Owner Author

🤖 Powered by ework · qwen3.8-27b

APPROVE

The fix is correct and well-tested. The core logic — verify effect after re-register; ineffective → one diagnostic + 10 min backoff (probes continue, no registerTool churn); window expiry → exactly one more attempt — is sound, and the three core scenarios are covered by deterministic clock-pinned tests.

The two backoff-clear paths (fresh-sid, session_tree) were claimed in the Fix section but had no test. I added one test per path on this branch (commit 4920ab6) — both reuse the existing makeDroppingRegister / frozen-clock harness and pass.

Behavior drift (intended, disclosed in the PR): before, an ineffective re-registration churned on every per-turn hook (paired warns + a synchronous full-registry rebuild mid-turn-prep). Now it backs off for 10 min (REASSERT_BACKOFF_MS default). Probes continue, so a host that starts accepting registrations still heals on the next turn. This is an availability-over-churn tradeoff, not a regression.

Scope: src/agent/pi.ts + tests only. No kernel/ changes, no new config/env surface (the backoff is injectable via the existing createBiliPlugin opts channel). Follows house conventions.

八问

  1. 是什么问题: pi 工具在宿主 registry 不再读取插件实例映射时(mid-session 模式切换/重载后的实例代际漂移),每次 per-turn hook 都盲目重注册、落进死映射 → 每轮配对 warn + 同步重建整个 registry(anomaly A: 544 行/82min;anomaly B: stale hiddenDeclarations)。
  2. 什么原因导致的: reassertDroppedTools 在 before_agent_start + before_provider_headers 两个 hook 都经 registerTools 触发,但无有效性检查、无退避——每次尝试都落进死映射,永不收敛。
  3. 影响范围与严重程度: 特定条件下有问题——宿主 registry 与插件实例映射失步时(mid-session 模式切换/重载后),每轮 churning + 同步 registry 重建。性能下降/体验瑕疵,非完全不可用。
  4. 怎么修复的: 重注册后验证效果;无效 → 一条诊断 + 10min 退避(探测继续,无 registerTool churn);窗口到期 → 恰好再试一次;新 sid 注册或 session_tree 导航清除退避,保证新 episode 立即愈合。
  5. 是否有回归问题: 审过既有行为——pi-native: tools register once per session id, so a pi tool-registry rebuild silently removes compress/decompress/... for the rest of the session #2708 drop warn 文本字节级不变;natural heal(missing.length===0)在退避检查之前,健康宿主不受影响;pre-probe throw 路径(present=undefined)不变(不盲目重注册)。无回归。
  6. 是否破坏缓存: 不涉及——退避只影响 registerTool 调用频率,不影响缓存/重试/增量游标/去重键。
  7. 是否改了设计方向: 不涉及——在既有 reassert 机制上加有效性检查 + 退避,不改变架构/边界/数据流。
  8. 是否引入了新的配置: 不涉及——REASSERT_BACKOFF_MS 是内部常量(10*60_000),经既有 createBiliPlugin(...,opts) 通道可注入,无新 config/env 表面。

判定:可合(APPROVE)。

@ranxianglei

Copy link
Copy Markdown
Owner Author

🤖 Powered by ework · qwen3.8-27b

[bot] 🏷 Review complete — verdict: APPROVE / 可合 (full review above, floor 27; receipt for the on-the-spot fix, floor 28).

What I did and the outcome:

  • Reviewed PR [PR] fix: cap ineffective pi tool re-registration with verify + backoff (#6080) #6107 (fix: cap ineffective pi tool re-registration with verify + backoff, Closes bug: per-turn re-register loop races pi loadout → stale declarations #6080) end-to-end: PR body, linked issue bug: per-turn re-register loop races pi loadout → stale declarations #6080, and the full diff (src/agent/pi.ts +60/−10, tests/plugin-agent.test.ts). Independent read-through — not a copy of the earlier floor-7 review.
  • Verdict: APPROVE. The fix removes the producer (unconditional per-turn re-registration into a dead instance map), not the symptom: verify effect after re-register; ineffective → one diagnostic + 10 min backoff (probes continue, no registerTool churn); window expiry → exactly one more attempt; fresh-sid registration / session_tree navigation clears the backoff. Behavior drift is intended and disclosed (broken-state churn drops from ~2×6 registerTool/turn to ≤1×6/10min; healthy path unchanged). No kernel/ changes, no new config/env surface (backoff is injectable via the existing createBiliPlugin opts channel).
  • Small finding fixed on the spot: the two backoff-clear paths (session_tree navigation + fresh-sid registration) were claimed in the PR's Fix section but had no test. Added one deterministic test per path (commit 4920ab6, pushed to the PR branch; both reuse the existing makeDroppingRegister / frozen-clock harness and pass — 81/81 in the file). Receipt at floor 28.
  • CI (mirror cache, last snapshot 01:14Z on head 4920ab6): 0 failures across all 30 checks — 13 success, 12 skipped, 5 test shards still in progress at that snapshot (no red). The earlier reds were inherited master-level flakes already converged via ci-fixes per the 2026-10-24 policy. Those 5 pending shards have had 8+ h to complete since; no failure has been reported.
  • Coordination issue: I could not locate a distinct "coordination issue" to post the one-line completion report on — the review and receipt are in this thread. Flagging so the owner can point me at the right thread if one exists.

Final verdict: 可合 (APPROVE) — merge stays human-only. #6107

Union of master's nudgeNotifyText function (above the signature) and the PR's reassertBackoffMs? opts. Verified: typecheck clean, plugin-agent 81/81, nudge-debug 8/8, build clean.
@ranxianglei

Copy link
Copy Markdown
Owner Author

🤖 Powered by ework · qwen3.8-27b

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

Re-verified live: the PR was dirty (conflict with base). The remote head had moved to 4920ab6db4 (another agent added a test commit on top of my a5a39b125a), and master advanced to a259e0b8fa (Merge PR #6996).

What I did:

  1. Fast-forwarded my local branch to the remote head 4920ab6db4 (my a5a39b125a was its ancestor — no history rewrite of the other agent's commit).
  2. Merged upstream/master (a259e0b8fa) into the branch. One conflict, in src/agent/pi.ts at the createBiliPlugin signature region: master added a nudgeNotifyText function directly above the signature, while this PR added reassertBackoffMs? to the opts. Resolved as a union (keep master's function + the PR's opts). All other 30+ files auto-merged cleanly.
  3. Verified locally: typecheck clean; tests/plugin-agent.test.ts 81/81; tests/nudge-debug.test.ts 8/8 (master's nudge surface intact); build clean.
  4. Pushed the merge commit 735d3f7f38 as the final head (fast-forward, no force, no [ework:ci-held] marker — this is the branch's one full CI pass).

The PR's production change (src/agent/pi.ts backoff logic) and the other agent's test commit are both preserved; only the signature-region conflict was resolved.


八问

  1. 是什么问题: PR 与 base 分支(master)产生合并冲突(merge state: dirty),合并被 block。
  2. 什么原因导致的: master 前进到 a259e0b(合入 [PR] fix: pi nudge debug view — strict fidelity, drop the appended example line #6996),在 createBiliPlugin 签名正上方新增了 nudgeNotifyText 函数;本 PR 在同一签名区给 opts 加了 reassertBackoffMs?。两边改了相邻行,git 无法自动合并,产生冲突。
  3. 影响范围与严重程度: 仅影响本 PR 的合并(被 block),不影响任何运行时行为——冲突是纯文本级的相邻行改动,语义上两者互不干扰(master 的 nudge 通知函数 + 本 PR 的 backoff 配置项)。
  4. 怎么修复的: 先把本地分支 fast-forward 到远端 head 4920ab6(另一位 agent 在我 a5a39b1 之上加的测试提交,保留不重写),再 merge upstream/master;唯一冲突按「并集」解——同时保留 master 的 nudgeNotifyText 函数和本 PR 的 reassertBackoffMs? opts。
  5. 是否有回归问题: 无。并集解法两边语义都完整保留;本地 typecheck 干净、plugin-agent 81/81、nudge-debug 8/8(master 的 nudge 表面完好)、build 干净。其余 30+ 文件全部自动合并干净。
  6. 是否破坏缓存: 不涉及。纯合并冲突解决,不碰任何缓存/重试/游标/去重逻辑。
  7. 是否改了设计方向: 不涉及。纯冲突解决,无架构/边界/数据流转向。
  8. 是否引入了新的配置: 不涉及(本 PR 原有的 reassertBackoffMs? 配置项保留,无新增)。

判定: 合并冲突已解决并推送最终 head 735d3f7f38(fast-forward,未 force-push,未重写他人提交),等 CI 全量重跑转绿即可合并;生产代码与他人的测试提交均完整保留、未引入回归。

@ranxianglei

Copy link
Copy Markdown
Owner Author

🤖 Powered by ework · qwen3.8-27b

[ework] CI fix verified green ✓

@ranxianglei

Copy link
Copy Markdown
Owner Author

🤖 Powered by ework · qwen3.8-27b

[bot] 🏷 Re-review of new head 735d3f7f3 — verdict: APPROVE / 可合 (reaffirmed).

The head moved from a5a39b125 (my last review) to 735d3f7f3. The new head is not new PR content — it is a merge of upstream/master (a259e0b8fa, PR #6996 fix/compress-nudge-example) into the PR branch to resolve the createBiliPlugin signature conflict.

Verified on the new head:

  • PR content is byte-identical to what I approved at 4920ab6. The 3-dot net diff vs master is unchanged: src/agent/pi.ts +60/−10, tests/plugin-agent.test.ts +224. The backoff logic (reassertDroppedTools, REASSERT_BACKOFF_MS = 10*60_000, reassertBackoffUntil, the three clear paths) is untouched. The only pi.ts delta from the merge is master's new nudgeNotifyText export (nudge-debug refactor, owner direction 2026-11-17), which is unrelated to this PR's backoff path.
  • Signature conflict resolved correctly. createBiliPlugin(agentOverride?, opts?: { retryIntervalMs?; reassertBackoffMs? }) — the PR's reassertBackoffMs? opts param is preserved alongside master's nudge changes (pi.ts:980).
  • Tests intact. tests/plugin-agent.test.ts is byte-identical to my head (empty diff) — the two backoff-clear-path tests I added (commit 4920ab6) are present.
  • CI green on the new head (mirror cache, 2026-11-17T17:36Z, sha 735d3f7f3): 0 failures across all 30 checks — 17 success, 13 skipped, 0 pending. mergeable_state=blocked is the awaiting-review gate, not a CI red.

No kernel/ changes, no new config/env surface. No small findings to fix on this re-review — the PR is clean. (GitHub review API returns 422 "cannot approve your own pull request" — same as last cycle — so this mirror comment is the review of record.)

八问(中文):

  1. 是什么问题:pi 工具「无效重注册」无上限——宿主注册表不再读插件实例映射时,每轮都重注册进死映射,造成永久 churn。
  2. 什么原因导致:reassertDroppedTools 在每个 per-turn hook 无条件重注册,无效果校验、无退避。
  3. 影响范围与严重程度:坏态下 churn 从 ~2×6 registerTool/轮 降到 ≤1×6/10min;健康路径不变。属体验/资源问题,不影响可用性。
  4. 怎么修复:重注册后校验效果;无效 → 一条诊断 + 10min 退避(探针继续,不 churn);窗口到期再试一次;新 sid 注册 / session_tree 导航清除退避。
  5. 是否有回归:无。退避逻辑与测试均与我上轮批准的 4920ab6 逐字节一致;本轮新 head 仅是合并 master([PR] fix: pi nudge debug view — strict fidelity, drop the appended example line #6996 nudge 重构),与本 PR 退避路径无交互;CI 全绿。
  6. 是否破坏缓存:否。
  7. 是否改了设计方向:否。
  8. 是否引入新配置:否——退避时长经既有 createBiliPlugin opts 通道注入,无新 env/config 面。

最终判定:可合(APPROVE)——合并仍由人执行。#6107

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

Labels

bug Something isn't working p2 pi scope/wiring

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bug: per-turn re-register loop races pi loadout → stale declarations

1 participant