Skip to content

[PR] feat: fold before pi's cancelled auto-compaction (POST /__bili/plugin/compress) - #6351

Open
HS-Jack-YZY wants to merge 7 commits into
ranxianglei:masterfrom
HS-Jack-YZY:2026-11-12_plugin-compress-route
Open

HS-Jack-YZY wants to merge 7 commits into
ranxianglei:masterfrom
HS-Jack-YZY:2026-11-12_plugin-compress-route

Conversation

@HS-Jack-YZY

@HS-Jack-YZY HS-Jack-YZY commented Nov 12, 2026 •

Copy link
Copy Markdown

Closes #6199

This builds shape A as sketched in #6199. Built that way, the re-entered walk folds only when the session moved after the last request's own preflight: k̂ learned from that answer's usage, an overflow arm, or an auto-fold target. Otherwise the route answers folded: false and today's behaviour stands. The reason is that every request reaching pi's threshold has already passed preflight under the proxy's target: bili reports no window to pi, pi sends its own window W to the proxy, the proxy judges against W less an output reservation, and pi compacts at W − 16384. How often a session moves enough to fold is not measured. The code and the tests show both cases. Do you want this taken further, or left as it is?

What a pi host sees today

Under bili, the plugin's session_before_compact handler returns {cancel: true} for pi's threshold and overflow passes, so that pi and the proxy do not compact twice. Nothing is folded at that moment. The context stays full until the next model request reaches the proxy, and preflight folds it then, on the request path.

What it sees after

The handler first POSTs {conversationId} to a new loopback route, /__bili/plugin/compress, and awaits it. Then it returns {cancel: true} exactly as before, whatever the answer.

  • The route. The proxy re-runs preflightCompressIfNeeded over the conversation's last model request, under the session lock. It uses the same gates and summary rounds that request ran.
    • If the session is over its target, the fold happens now, and the next request ships it.
    • If the session fits, nothing is folded.
  • pi's events. pi emits compaction_start before the hook and compaction_end after it. So the fold runs inside pi's own compaction span:
    • The TUI shows its compaction indicator for the span, and Escape aborts it. The hook passes pi's signal to the fetch.
    • An RPC host receives both events, forwarded unchanged.
  • The wait is bounded by pi's abort signal and a 300 s timeout.
  • It fails open. An error answer, a timeout, an abort or an unreachable proxy are logged to the host log, and the cancel goes ahead as today.

Answers from the route:

Case Answer
Ranges were folded {ok: true, folded: true}
The request already fitted {ok: true, folded: false}
The session has no plugin request yet {ok: true, skipped: "no-request"}
Preflight could not fold {ok: false, error}
Invalid JSON or missing conversationId 400
Unknown conversation 404
Preflight threw 500

While summary rounds run, the route may send 200 and whitespace before the JSON. This is the hold preflight already gives a non-streaming client.

Out of scope:

  • No config key and no kernel change.
  • The reactive preflight path is untouched. The only line added on the request path stores the call's own arguments.
  • omp is not changed. Its auto_compaction_* flow can take the same call as a follow-up.

What is retained

The proxy keeps each plugin session's last preflight call in a WeakMap keyed by the session, in memory only. That call is the request, its headers included, because the summary rounds need its credential. It is replaced by the session's next request and dropped when the session object goes. It is never logged, persisted or returned by any route.

Costs, stated plainly

  • Retained request. The last request, headers and body, is retained per plugin session until the session goes. No cap or new config is added for it.
  • pi's UI after a fold. A pi TUI still prints "Auto-compaction cancelled" even when the proxy folded. An RPC host still sees compaction_end {aborted: true}. pi has no way for an extension to report "done elsewhere".
  • Not run. The codex E2E lane was not run.

Both compression modes

  • Plugin mode. The call is retained only for sessions bound to a plugin agent. The fold lands in the session's block state, and the next request's prepare applies it, as a reactive preflight fold would.
  • Proxy (wire) mode. Nothing is retained. The route answers skipped: "no-request". The request path differs only by the plugin check.

Licence

The repository is MIT. A contributor's code is taken under the same MIT terms, with the copyright and permission notice kept.

What was run

Run locally with the npm test runner's preloads, at cb77c059a unless stated. The head, dc6f364de, differs from it by one word: an export dropped for the unused-exports check, with check-unused-exports and typecheck re-run on it.

  • npm run typecheck: clean, tests/ included.

  • tests/issue6199-pre-compact-fold.test.ts is new and has six tests:

    • pi's real AgentSession._runAutoCompaction with its collaborators stood in, run against a fake proxy. It checks the order compaction_start, then the compress POST, then compaction_end {aborted: true}, and that the hook returned {cancel: true}.
    • Fail-open on a 500 and on pi's abort.
    • No call for manual /compact or an unowned conversation.
    • A plugin session whose answers outgrew its estimate. Two turns of the same payload, each billed 24k against a 20k window, publish k̂; neither turn folded by itself. The route then folds it through the fake upstream's summary rounds, which carry the request's own credential. Neither the answer nor /__bili/plugin/status contains it. The next turn ships the summary.
    • A fitting session (two turns billed 9k) is left as it is.
    • The route's 400, 404 and no-request gates.

    All six pass (node --import ./tests/preload-storage-baseline.mjs --import ./tests/preload-test-env.mjs --import tsx --test tests/issue6199-pre-compact-fold.test.ts).

  • tests/plugin-agent.test.ts passed at an earlier amend of this commit; the amends since touched only the new test file.

The full suite was not run locally; CI's test lanes run it on the pushed head.

🤖 Generated with Claude Code

@ranxianglei ranxianglei changed the title feat: fold before pi's cancelled auto-compaction (POST /__bili/plugin/compress) [PR] feat: fold before pi's cancelled auto-compaction (POST /__bili/plugin/compress) Nov 12, 2026
@HS-Jack-YZY
HS-Jack-YZY force-pushed the 2026-11-12_plugin-compress-route branch from cb77c05 to dc6f364 Compare November 12, 2026 06:30
@ranxianglei

Copy link
Copy Markdown
Owner

🤖 Powered by ework · qwen3.8-27b

[bot] 🏷

查重 (duplicate screening): 不重复 (not a duplicate).
Searched open+closed PRs for compaction/compress themes. Closest: #6217 (pre-compaction history restore — different mechanism: it restores, it does not fold) and #2113 (closed, compaction watchdog). This PR is distinct: it folds before pi's cancelled auto-compaction via a new POST /__bili/plugin/compress route. No duplicate.

Review of #6351 — rebased to current master (9674cfafbc).
The PR was 5 commits behind; I cherry-picked its single commit dc6f364dea onto fresh master — clean, no conflicts. Verified locally:

  • npm run build — OK
  • npm run typecheck — clean on the rebased head
  • Targeted tests (full-suite verdict is remote CI, per local test discipline):
    • tests/issue6199-pre-compact-fold.test.ts — 6/6 pass
    • tests/plugin-agent.test.ts + tests/admin-origin.test.ts — 80/80 pass
  • CI on the PR head (dc6f364dea): 52 check-runs → 38 success + 14 skipped, 0 failures (green). PR is currently open / draft / behind.

What the PR does (verified in code):

  • New route POST /__bili/plugin/compress (src/server/admin.ts:883-894 → handlePluginCompress in src/plugin.ts:977-1030).
  • The request pipeline retains the last request's preflight closure per plugin session (src/server/handle.ts:3159-3168, retainPreflight WeakMap), forcing stream:false so the route answers JSON, not SSE.
  • pi's session_before_compact hook (src/agent/pi.ts:1018-1036) now asks the proxy to fold now (requestPreCompactFold, src/agent/shared.ts:236-245, 300 s bound + pi's abort signal), then always cancels pi's own compaction (fail-open: a route failure falls back to the old cancel behavior).
  • docs/plugin-protocol.md documents the route.

Findings / concerns:

  1. Unbounded per-session memory retention — the last request (headers incl. credential + body Buffer) is retained per plugin session with no cap. Disclosed by the PR; the tests pin no leak in the route answer or plugin status. Cap-or-not is an owner call (feature surface; the PR adds no config knob).
  2. Re-entry re-runs the full runPrepare only when the trigger fires AND a fold happens. Side effects are self-consistent: the post-rebuild anchor is re-set after the fold rebuild (src/server.ts:4389), stats/metadata stamps are latest-wins — no net drain.
  3. Hook racing an in-flight request: serialized by withSessionLock, bounded by preflight round caps, correct (a redundant second preflight pass is possible but safe).
  4. This is a feat + new wire route → §7.4 auto-merge NOT eligible; human merge tier.
  5. Disclosed limits: codex E2E lane not run locally (CI gates it); pi TUI still prints "Auto-compaction cancelled" even when the proxy folded (pi has no "done elsewhere" channel); omp untouched (follow-up candidate).

Code quality: good — naming, doc comments, and tests with teeth (real pi _runAutoCompaction, real startServer, credential-leak pin, fail-open, gate rows). No ②a restructure trigger seen.

On the author's question — "taken further, or left as it is?": my read is that this is a clean, well-tested, self-contained implementation of shape (a) that resolves the reported symptom (#6199: "a host sees nothing while the proxy compresses"). I'd recommend merging as is; the open follow-ups (omp parity, a retention cap, a TUI "done elsewhere" channel) are genuinely separate work and don't block this. Final call is yours.


8问 (reviewer checklist):

  1. 是什么问题: pi 插件宿主在 proxy 压缩期间看不到任何进展(pi plugin: a host sees nothing while the proxy compresses a conversation #6199)——proxy 只在下一个请求的 preflight 才折叠,而 pi 取消自身压缩后没有触发 proxy 折叠的通道,宿主就空等了。
  2. 什么原因导致的: 根因是压缩时机与宿主可见性错位——proxy 的折叠发生在"下一个请求",而 pi 取消自身压缩后缺少一个让 proxy 立即折叠的通道。本 PR 补上这个通道:宿主在取消自身压缩前显式请求 proxy 立即折叠。
  3. 影响范围与严重程度: 仅影响 pi 插件宿主(omp 未动);触发条件 = pi 发起 threshold/overflow 自动压缩且 proxy 拥有该会话压缩权。此前是体验缺陷(宿主空等、看不到压缩),压缩本身仍会在下一请求发生,非不可用。
  4. 怎么修复的: 新增 POST /__bili/plugin/compress 路由 + 每会话保留上一次请求的 preflight 闭包;pi 的 session_before_compact 钩子在取消自身压缩前调用该路由让 proxy 立即折叠(fail-open:路由失败仍取消 pi 压缩,回到旧行为)。
  5. 是否有回归问题: 审了既有行为——preflight 折叠判定(again !== prepared 对象比较,成立)、post-rebuild anchor(折叠重建后重新 set,无净消耗)、并发(withSessionLock 串行化)、admin 路由门(loopback + tunnel + trusted-origin,新路由同门)。未见回归。
  6. 是否破坏缓存: 不涉及——不改动缓存/重试/增量游标/去重键;折叠走既有 preflight 路径。
  7. 是否改了设计方向: 不涉及架构转向——是既有 preflight 机制的一个新触发入口(宿主主动请求),数据流不变。
  8. 是否引入了新的配置: 无新 config/env/默认值(PR 明确 "no config key")。唯一新增的内存面是每会话保留上一次请求(headers + body),无上限——已披露,是否加 cap 由 owner 定。

判定: 代码质量过关、测试有牙、CI 绿、rebase 干净。建议可合(human merge tier,非 auto-merge)。"taken further vs left as is" 是 owner 决策——我的推荐是按现状合入,omp 对齐 / 保留上限 / TUI "done elsewhere" 通道作为独立后续。

ranxianglei pushed a commit to dimas623/billion-context that referenced this pull request Nov 13, 2026
…the unrelated ranxianglei#6351

The two comments introduced by this PR cite ranxianglei#6351, which is an unrelated
open PR (fold before pi's cancelled auto-compaction). The bug they
describe is ranxianglei#6356, which this PR closes.
@HS-Jack-YZY
HS-Jack-YZY marked this pull request as ready for review November 13, 2026 01:09
ranxianglei pushed a commit that referenced this pull request Nov 13, 2026
#6351

The two comments introduced by this PR cite #6351, which is an unrelated
open PR (fold before pi's cancelled auto-compaction). The bug they
describe is #6356, which this PR closes.

(cherry picked from commit 828aed7)
@ranxianglei
ranxianglei force-pushed the 2026-11-12_plugin-compress-route branch from dc6f364 to 5d561d2 Compare November 15, 2026 09:28
@ranxianglei

Copy link
Copy Markdown
Owner

🤖 Powered by ework · qwen3.8-27b

(ci: opencode/qwen3.8-27b)

Rebased the PR onto current master and fixed the red CI. Both blockers are resolved and pushed (new head 5d561d2ab7 on HS-Jack-YZY:2026-11-12_plugin-compress-route).

1. Merge conflict (merge state dirty) — master added preparePluginWireMetadata to the src/server/handle.ts import from ../plugin.js; the PR added retainPreflight to the same import line → textual conflict. Resolved as a clean union — both symbols are used (preparePluginWireMetadata at handle.ts:699/700, retainPreflight at handle.ts:3244/3250; both exported from src/plugin.ts). Force-pushed the rebased branch (task-authorized conflict-rebase). Verified locally the branch is now a fast-forward from origin/master (no conflict).

2. Red CI — test 4 "the route folds a plugin session whose answers outgrew its estimate" — the route returned 500 {"error":"preflight threw"} instead of 200 {ok:true, folded:true}. Root cause: the PR's retained preflight closure re-enters runPrepare later (when pi's compaction hook fires POST /__bili/plugin/compress). Master's #4753 (releaseRequestInput, post-forward) nulls the request's parsed body. runPrepareInner read the mutable parsed slot on every call (const work = parsed), so the later re-prepare saw null → prepareResponses(null) threw TypeError: Cannot read properties of null (reading 'input') at prepare-responses.ts:72. Fix: capture parsed once at the top of runPreparedPipeline's body (before releaseRequestInput can null it) into inboundParsed, and read that stable capture in runPrepareInner (both the buildIncomingImageIndex and work reads). Behavior-preserving for existing paths (inboundParsed === parsed for the duration of the initial request + preflight re-prepare); only the post-release route re-entry is fixed.

Verified locally: npm run typecheck clean; all 6 tests/issue6199-pre-compact-fold.test.ts pass (was 5/1); related pipeline suites fix-arm-headroom-clamp + fold-drift (11 tests) pass.

CI status (live check): I could not verify the new head's CI live — the mirror cache is stale (fetched_at 2026-11-13, sha dc6f364 = the pre-push head; it has not picked up 5d561d2ab7 after ~13 min). The conflict is resolved (verified locally). The full-suite verdict comes from the remote CI on the pushed head.


八问:

  1. 是什么问题:PR 分支与 master 冲突(merge state dirty);rebase 后 PR 自带测试 4("route folds a plugin session whose answers outgrew its estimate")红——路由返回 500 "preflight threw",期望 200 {ok:true, folded:true}。
  2. 什么原因导致的:① 冲突:master 往 handle.ts 的 ../plugin.js import 加了 preparePluginWireMetadata,PR 往同一行加了 retainPreflight,文本冲突。② 测试红:PR 的 retained preflight 闭包在之后(pi 的 compaction hook 触发路由时)才重新进入 runPrepare;master 的 fix: release request input buffers before long-running responses #4753(releaseRequestInput,forward 之后)把请求的 parsed body 置 null;runPrepareInner 每次调用都读可变的 parsed 槽(const work = parsed),所以后来的 re-prepare 看到 null → prepareResponses(null) 抛 TypeError: Cannot read properties of null (reading 'input')。
  3. 影响范围与严重程度:① 冲突:挡住 PR 合并。② 测试红:pi plugin: a host sees nothing while the proxy compresses a conversation #6199 路由对"答案超出估计"的 plugin 会话返回 500 而非折叠——该场景功能失效;但 fail-open(pi 仍会取消自己的 compaction),无数据丢失,只是没折叠。
  4. 怎么修复的:① 冲突:import 行做干净并集(两个符号都需要)。② 测试红:在 runPreparedPipeline body 顶部(被 releaseRequestInput 置 null 之前)把 parsed 捕获一次到 inboundParsed,runPrepareInner 里(buildIncomingImageIndex 和 work 两处)读这个稳定捕获。对既有路径行为保持;只修 post-release 的路由 re-entry。
  5. 是否有回归问题:改动对既有路径行为保持。inboundParsed 在 runPreparedPipeline 运行时刻捕获,那时 parsed 仍是有效 body;初始请求与 preflight re-prepare 读同一个值,只有新的 pi plugin: a host sees nothing while the proxy compresses a conversation #6199 re-entry 路径(之前会抛)被改。已验证:typecheck 干净、6 个 pi plugin: a host sees nothing while the proxy compresses a conversation #6199 测试全过、相关 pipeline 测试(arm-headroom、fold-drift)全过。
  6. 是否破坏缓存:否。不碰缓存/重试/增量游标/去重键,只改 runPrepareInner 读请求 body 的变量引用。
  7. 是否改了设计方向:否。PR 的设计(retain preflight 闭包、之后重跑)不变,只是让它兼容 fix: release request input buffers before long-running responses #4753 的 input-release 优化。
  8. 是否引入了新的配置:否。无新 env/config/默认值。

判定:冲突已解、红 CI 已修(本地定向验证通过);新 head 的全量 CI 结果以远程 CI 为准——mirror 缓存当前 stale,本轮未能 live 验证。

ci-check and others added 5 commits November 16, 2026 20:42
…ns {3,5,11,14}

The probe anchor PROXY_TOOL_AT=6 was calibrated on 2026-10-31 for ranxianglei#4521
(schedule {4,6,8,9}). The nudge scheduling has shifted again — nudge now
lands at {3,5,11,14}. Re-calibrate the anchor to the next nudge-carrying
request pair (5 → tool round, 6 → fold round). The fold/proxy-tool-round
mechanics under test are unchanged.

Closes: master-red on test (windows-latest, 22, 3) and (ubuntu-latest, 22, 1).
…/compress)

pi's session_before_compact hook cancels pi's own threshold/overflow
compaction, so the proxy folds only when the next request arrives. The
hook now asks the proxy to fold first and then cancels as before:

- src/plugin.ts: the last preflight call of each plugin session is kept
  in a WeakMap (memory only, replaced by the next request, dropped with
  the session); handlePluginCompress re-enters it under the session lock
  and answers {folded} or {skipped}.
- src/server/handle.ts: retain the call at the preflight site for plugin
  sessions (stream off, so a hold sends whitespace before the JSON).
- src/server/admin.ts: the loopback-gated route.
- src/agent/shared.ts, src/agent/pi.ts: the pi hook awaits the fold,
  bounded by pi's abort signal and a 300 s timeout, and fails open.
- docs/plugin-protocol.md: the endpoint.

Closes ranxianglei#6199

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…anglei#6199 preflight re-entry

The ranxianglei#6199 retained preflight closure re-enters runPrepare AFTER
ranxianglei#4753's releaseRequestInput (post-forward) has nulled the request's
parsed body. runPrepareInner read the mutable parsed slot on every
call, so the route's later re-prepare saw null and threw
'TypeError: Cannot read properties of null (reading input)' in
prepareResponses.

Capture parsed once at the top of runPreparedPipeline (before it can
be released) and read that stable capture in runPrepareInner. Existing
paths are unchanged: inboundParsed === parsed for the duration of the
initial request and the preflight re-prepare; only the post-release
route re-entry is fixed.
@ranxianglei
ranxianglei force-pushed the 2026-11-12_plugin-compress-route branch from 5d561d2 to 464ef74 Compare November 16, 2026 16:49
@ranxianglei

Copy link
Copy Markdown
Owner

🤖 Powered by ework · qwen3.8-27b

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

CI re-trigger (attempt 1/6) — merge conflict re-resolved and pushed.

This run the PR was dirty again because master advanced past my last rebase: e7a42babec → 301e1a5459 (Merge PR #6151 nudge-debug-pi, plus ~25 more commits). Three of the PR's files (src/agent/pi.ts, src/plugin.ts, src/server/handle.ts) were touched by the new master commits, so I re-rebased onto current master.

The one conflict was the same src/server/handle.ts:59 ../plugin.js import line, but with a new twist this time:

Resolved as a clean union — kept all of master's symbols and inserted retainPreflight. Both symbols verified: actually used in handle.ts (PLUGIN_PURPOSE_CONVERSATION at :1255, retainPreflight at :3310) and exported from plugin.ts (:167, :1063). No logic touched — import line only.

Rebase completed clean → the PR's two commits (the feat + my earlier fix: capture the parsed body) re-landed on top of current master. Verified locally: typecheck clean, all 6 tests/issue6199-pre-compact-fold.test.ts pass (including the #6199 test my earlier fix repaired).

Before pushing I confirmed the fork's branch head was still my previous push (5d561d2ab7, no one else's work at risk) and used --force-with-lease. Pushed: 5d561d2ab7 → 464ef74875. The branch is now a clean fast-forward from master (no conflict, merge-base --is-ancestor = yes).

One honest caveat: the mirror cache stayed stale this run too — fetched_at 2026-11-15, sha still my previous push (5d561d2ab7), never picked up the new 464ef74875. So I could not verify the new head's CI live from the mirror. The full-suite verdict comes from remote CI on the pushed head; locally I've confirmed typecheck + the 6 targeted tests green.


八问

  1. 是什么问题:PR [PR] feat: fold before pi's cancelled auto-compaction (POST /__bili/plugin/compress) #6351 又和 master 冲突了(merge state: dirty)。master 在我上次 rebase 之后又前进了(e7a42babec → 301e1a5459,含 [PR] feat: pi lane — show the injected nudge text verbatim in the terminal when debug is on #6151 等约 25 个 commit),新 master 提交动了 PR 的三个文件,导致 handle.ts 的 import 行再次冲突。
  2. 什么原因导致的:冲突点在 src/server/handle.ts:59 的 ../plugin.js import 行——master 侧([Design][dsh] Stop guessing dsh's auxiliary requests — the in-process plugin can declare each request's purpose explicitly #6880 dsh-purpose)新增了 PLUGIN_PURPOSE_CONVERSATION 和 pluginPurposeHeader,PR 侧新增了 retainPreflight,两边各自往同一行加符号,产生文本冲突。是「同一 import 行双方各加符号」的机械冲突,不是语义冲突。
  3. 影响范围与严重程度:只影响 PR 分支与 master 的合并状态(冲突),不影响任何运行时行为。解决后 PR 分支是 master 的纯 fast-forward(无分叉)。严重程度:纯 CI 阻塞,无用户可见影响。
  4. 怎么修复的:import 行做成并集——保留 master 全部符号(含新增的 PLUGIN_PURPOSE_CONVERSATION、pluginPurposeHeader),再插入 PR 的 retainPreflight。两个符号都验证过真的被用到(PLUGIN_PURPOSE_CONVERSATION 在 handle.ts:1255,retainPreflight 在 :3310)且都从 plugin.ts 导出(:167、:1063)。rebase 干净完成,PR 的两个 commit 在新 master 之上重新落地。
  5. 是否有回归问题:无。本次只动 import 行(并集,不删任何符号),没改任何逻辑。typecheck 干净,PR 的 6 个测试全过(含我上次修好的 pi plugin: a host sees nothing while the proxy compresses a conversation #6199 测试)。master 新增的 dsh-purpose 逻辑与 PR 的 retainPreflight 逻辑互不干扰。
  6. 是否破坏缓存:不涉及。没碰任何缓存/重试/游标逻辑。
  7. 是否改了设计方向:不涉及。纯冲突解决,无架构/数据流变更。
  8. 是否引入了新的配置:不涉及。

收工判定:冲突已解决并 force-push(5d561d2ab7 → 464ef74875),PR 分支现在是 master 的 fast-forward。唯一未决项是新 head 的全量 CI——镜像缓存卡在旧 sha 没刷新,我没法实时确认,以远程 CI 在 push 后 head 上的结果为准;本地 typecheck + 6 个定向测试已绿。

@ranxianglei

Copy link
Copy Markdown
Owner

🤖 Powered by ework · qwen3.8-27b

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

No action taken this run — the reported merge conflict no longer exists (verified live).

Per status-freshness I checked the live state before touching anything:

  • Merge state (GitHub API): mergeable: true, mergeable_state: blocked. blocked = "waiting on required checks/reviews", not a merge conflict.
  • Local proof of no conflict: current master 301e1a5459 is a direct ancestor of the PR head 464ef74875 (PR is 2 commits ahead, 0 behind → fast-forward possible, so a conflict is structurally impossible). A virtual git merge-tree of master into the head produced zero conflict markers.
  • Why the trigger's "dirty" is stale: both PR commits carry the same committer timestamp 2026-11-17T00:44:28+08:00 (a rebase signature). The branch was already rebased onto current master ~11 min before this task fired (00:55:02) — the conflict the trigger read had already been resolved.
  • CI: 30 checks on head 464ef74875 — 4 success, 13 skipped, 3 in-progress, 10 queued, 0 failures. The head has no [ework:ci-held] marker, so this is its one full CI pass and it is still running.

So there was nothing to rebase (no conflict) and no red CI to fix (none has failed). Per push discipline I did not force-push a no-op rebase onto an already-current head. If any in-flight test shard turns red, the next auto-fix attempt will pick it up.

八问(结构化结论,供人工 review)

  1. 是什么问题:任务触发时报告 PR 与 base 分支冲突(merge state: dirty),要求 rebase 解冲突。
  2. 什么原因导致的:该冲突是历史状态。PR 分支此前落后 master 产生冲突;触发前约 11 分钟(00:44:28)分支已被 rebase 到当前 master,冲突随之消失。本次触发读到的是过期的 dirty 判定。
  3. 影响范围与严重程度:无实际影响。PR 当前可 fast-forward 合入(master 是 head 的祖先),无冲突;CI 运行中、无失败。属“触发前提已失效”,非代码缺陷。
  4. 怎么修复的:无需修复。先按 status-freshness 核对 live 状态(GitHub API + 本地 merge-base / merge-tree 双重验证),确认无冲突、无红 CI,故不执行任何 rebase / force-push,避免对已是最新 head 做无意义改写。
  5. 是否有回归问题:不涉及——未改动任何代码或分支,无行为变化。
  6. 是否破坏缓存:不涉及——无任何写入操作。
  7. 是否改了设计方向:不涉及。
  8. 是否引入了新的配置:不涉及。

结论:本轮 no-op。PR #6351 当前无合并冲突、CI 在跑且无失败,blocked 仅因必需检查尚未跑完;无需 rebase。若后续有 test shard 转红,由下一轮 auto-fix 处理。

…ic wire shape

The probe's hardcoded request-index anchors (PROXY_TOOL_AT/FOLD_AT) broke
every time the nudge gate's schedule shifted. The last recalibration
(245ecb1) was measured on a direct local run (timestamps ON by default
since ranxianglei#4313), but CI runs the suite preload pin BILI_MESSAGE_TIMESTAMPS="0"
(timestamps OFF) — a different wire shape, a different schedule (no nudge at
index 5) — so it passed locally and failed on every CI shard.

Root-cause fix instead of another anchor whack-a-mole:
- Arm the fold on the first request carrying the ephemeral nudge with >=11
  tagged refs; fold on the re-request after the acp_status round. The probe
  now materializes the ranxianglei#2929 scenario wherever the schedule places it.
- Pin compress.messageTimestamps:false so the probe's wire shape is hermetic
  regardless of how the suite is launched (matches the CI preload pin).

Supersedes the 245ecb1 recalibration. Verified: passes with and without
the preload pin, same deterministic schedule (nudge at inputs[7], fold at
inputs[8]).
@ranxianglei

Copy link
Copy Markdown
Owner

🤖 Powered by ework · qwen3.8-27b

[ework] auto-fix stalled: test (windows-latest, 22, 4), test (ubuntu-latest, 24, 3), test (ubuntu-latest, 22, 3) — stopping for human review

@ranxianglei

Copy link
Copy Markdown
Owner

🤖 Powered by ework · qwen3.8-27b

This run addressed the 4 red checks on PR #6351 (3 test shards + architecture-docs). All 4 are inherited master failures, not regressions from this PR:

Both are already fixed on the sentinel-maintained ci-fixes branch: 8ed56be997 (module-map entry) and 245ecb1a9e + 7247410976 (schedule-independent #2929 probe). Per the CI coordination policy (owner policy 2026-10-24), I did not self-fix master-level failures — I merged origin/ci-fixes into the PR branch and pushed. Both checks now pass locally (#2929 byte-stability confirmed; architecture-docs all green, 325 src files covered, no ghosts).

New head: 8bb14ead3b (final head, no ci-held marker → full CI pass). CI is re-running on the new head.


八问

  1. 是什么问题:PR [PR] feat: fold before pi's cancelled auto-compaction (POST /__bili/plugin/compress) #6351 的 CI 有 4 条红(3 个 test 分片 + architecture-docs),但全部是继承自 master 的红,不是本 PR 引入的回归。
  2. 什么原因导致的:① tests/issue2929-codex-fold-double-miss.test.ts 的 nudge 探针锚定在固定输入位置,而 nudge 调度是动态的,探针 miss——该测试在干净 master(301e1a5459)本地以完全相同的错误失败,属 master 侧 born-red;② architecture-docs 门禁要求 reference/architecture.md 覆盖所有 src/ 文件,而 src/responses-system-sections.ts(由 [Bug] Inconsistent system prompt separator in Responses internal re-request breaks cache prefix | [Bug] Responses 内部重请求的系统提示分隔符不一致,破坏缓存前缀 #6922 落 master,非本 PR 新增)未登记进模块图,属 master 侧遗漏。
  3. 影响范围与严重程度:仅本 PR 的 CI 信号(4 条红),非用户侧功能问题;PR 功能代码未受影响。
  4. 怎么修复的:按 CI 协调政策(master 红 = 继承性失败,禁止自行修 master 级失败),merge 哨兵维护的 ci-fixes 分支——其中已含两条修复:8ed56be997(补模块图)+ 245ecb1a9e/7247410976(codex 命中率问题分析 #2929 探针改为 schedule-independent)。merge 后本地两门禁全绿。
  5. 是否有回归问题:无。merge 只带入 ci-fixes 的两条 master 修复(测试探针重校 + 模块图补登),不触碰本 PR 功能代码;codex 命中率问题分析 #2929 测试 merge 后本地通过(byte-stability 确认),architecture-docs 本地全绿(325 个 src 文件全覆盖、无 ghost)。
  6. 是否破坏缓存:不涉及。
  7. 是否改了设计方向:没有;仅同步 master 既有修复。
  8. 是否引入新配置:没有。

结论:本 PR 侧无回归,4 条红均为继承 master 红,已通过 merge ci-fixes 收敛,等 CI 在新 head 8bb14ead3b 上重跑确认。

@ranxianglei

Copy link
Copy Markdown
Owner

🤖 Powered by ework · qwen3.8-27b

This event is stale — it reports the 3 failing test shards from the old head 464ef74875 (run 43911752701), which were already fixed in the previous run.

Re-verified live: the mirror cache now shows the PR head is 8bb14ead3b (the ci-fixes merge pushed last run) with all checks in_progress (new CI run in progress, no failures). The #2929 probe test and the architecture-docs check both pass locally on this head.

No further work needed this run — the inherited-master failures are already converged via ci-fixes; waiting for the new CI run on 8bb14ead3b to complete.

@ranxianglei

Copy link
Copy Markdown
Owner

🤖 Powered by ework · qwen3.8-27b

[bot] 🏷 APPROVE — fold before pi's cancelled auto-compaction (POST /__bili/plugin/compress)

Reviewed the full diff (9 files, +530/−32, head 8bb14ea) against linked issue #6199. The PR does what it claims: pi's session_before_compact (reason threshold/overflow, owned compaction) now POSTs {conversationId} to the new loopback route, awaits it (300 s cap + pi's abort signal), then returns {cancel:true} regardless. The route re-runs preflightCompressIfNeeded over the conversation's last model request under the session lock, with the same gates and summary rounds that request ran.

Correctness. The re-entry is the same code path as the normal preflight (same preflightCompressIfNeeded, same withSessionLock, same summary rounds), so the fold is correct and lossless. The inboundParsed capture (src/server/handle.ts:3035) is the right fix for the #4753 × #6199 interaction: releaseRequestInput nulls parsed post-forward, and the retained closure re-enters runPrepare after that, so the original body must be captured once at pipeline start. Verified runPrepare (handle.ts:3157) wraps runPrepareInner (handle.ts:3036) which closes over inboundParsed; the retainPreflight closure (handle.ts:3304) captures that runPrepare, so the re-entry reads the original body, not the released slot.

Credential handling. The retained call keeps the request's headers (credential) in a WeakMap<Session, …> (src/plugin.ts), in memory only — replaced by the session's next request, dropped when the session leaves memory, never logged/persisted/returned. The new test asserts the credential is absent from both the route answer and /__bili/plugin/status. Fail-open is correct: error/timeout/abort/unreachable all still cancel pi's pass.

Tests. tests/issue6199-pre-compact-fold.test.ts (6 tests) covers: hook order (compaction_start→POST→compaction_end{aborted:true}), fail-open on 500 + pi abort, manual /compact + unowned conversation never calling the proxy, the outgrew-estimate fold carrying the retained credential, the fitting-session no-fold, and the 400/404/no-request gates. These would catch a regression in the route, the hook, or the credential handling.

Scope note (non-blocking). The PR bundles two separate concerns: the #2929 test recalibration (schedule-independent fold probe) and the #6922 module-map row (src/responses-system-sections.ts in reference/architecture.md). Both are test-only/docs-only and needed for CI green on the merged head, so they're acceptable here, but ideally they'd be separate PRs. No kernel/ changes, no kernel-change declaration — the human-only kernel tier does not gate this.

8问 (中文):

  1. 是什么问题:pi 插件在 threshold/overflow 自动压缩时返回 {cancel:true} 取消宿主压缩,但代理此刻不折叠会话,上下文保持满状态直到下一个模型请求触发 preflight——宿主在压缩指示期间看不到任何折叠。
  2. 什么原因导致的:取消压缩与代理折叠是两条独立路径——pi 的钩子只取消,代理的 preflight 只在下一个请求时运行,中间没有桥接。
  3. 影响范围与严重程度:影响 pi 插件用户(threshold/overflow 触发的自动压缩)。严重度:体验瑕疵——上下文保持满状态直到下一个请求,宿主看不到折叠;不影响数据正确性。
  4. 怎么修复的:新增 POST /__bili/plugin/compress 路由,pi 钩子在取消压缩前调用它;路由在会话锁下对会话的最后一个模型请求重新运行 preflight(同样的门控与摘要轮次),折叠后宿主看到压缩。代理用 WeakMap 保留每个插件会话的最后一个 preflight 调用(含凭据头,仅内存),供重入使用。
  5. 是否有回归问题:无。重入走与正常 preflight 完全相同的路径(preflightCompressIfNeeded + withSessionLock),不改变现有行为;inboundParsed 捕获修复了 fix: release request input buffers before long-running responses #4753 释放后重入读空体的隐患。
  6. 是否破坏缓存:不涉及——不触碰缓存/重试/增量游标/去重键。
  7. 是否改了设计方向:不涉及——在既有 preflight 机制上加一个触发入口,不改变架构/边界/数据流。
  8. 是否引入了新的配置:不涉及——无新 env/config/默认值。

判定:可合并(APPROVE)。 无 kernel/ 改动,无人工决策项。

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

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

pi plugin: a host sees nothing while the proxy compresses a conversation

2 participants