Skip to content

[PR] feat: neutralize TRAE Code native auto-compact instruction (#2411) - #2415

Open
ranxianglei wants to merge 9 commits into
masterfrom
2026-10-08_traecode-native-compact-intercept
Open

ranxianglei wants to merge 9 commits into
masterfrom
2026-10-08_traecode-native-compact-intercept

Conversation

@ranxianglei

@ranxianglei ranxianglei commented Oct 8, 2026 •

Copy link
Copy Markdown
Owner

Refs #2411 — full three-stage fix: instruction unification (Stage A) + surface stand-down (Class A) + local forge of the compaction completion (Stage B), from the live-evidence rounds in the issue thread

What & why

TRAE Code / unified Trae client (closed-source AI IDE, no plugin system) has a native auto-compact that collides with bili's ACP compression when routed through the proxy in proxy mode. Live evidence (reporter, 2026-10-18~24): when the host fires its auto-compact it sends its ~6.9KB summarization template as the LAST user message on the normal chat endpoint (17/17 captured events; template byte-stable across 21 days / 9 models / 2 channels, store original sha256 d56eeae3…), and bili used to (a) ship its own conflicting compression doctrine in the same request as the host's "output only a summary" instruction, (b) let preflight fold the very history the host was asking to summarize, and (c) forward the request upstream so the model produced a host-shaped summary that then replaced the folded span IDE-side, destroying ACP anchors (the #2360/#1729 pathology class). The E2 capture further proved the backend's response to this request shape is an ORDINARY chat completion (no private progress frames / pseudo-tool events; terminal frame = finish_reason stop + usage + [DONE]) — so bili can serve the answer itself.

This PR fixes all three at the openai prepare seam:

  • Stage A (src/server/traecode-compact.ts): removes the tracked native instruction line from role=system string content exactly when bili presents its own compression surface, so the model sees one philosophy. Versioned constant + drift-tolerant no-op (sentence reworded upstream → passthrough + warn once per session, never mis-strips).
  • Class A (src/server/native-compact-shape.ts): detects the host-native compaction REQUEST (last user message = summarization template via strict-AND lead+tail anchors, or trim-exact /compact manual form) and stands down bili's whole compression surface for that turn: no tool/doctrine/nudge injection, no tags-only system note, overhead measurement skipped (title-gen-style), preflight compression skipped (codexForge precedent). Session state continuity stays active: processTurn/snapshot/unannounced-rewrite detection (模型切换后压缩块跨模型失配,新模型收到 61.3 万 token 全量上下文 #1001) all keep running, so the aftermath path for the compaction PRODUCT keeps working (master's [bug] DSH 桌面端 0.1.188:宿主原生压缩落地摧毁折叠基底 → 同一区间永久不可锚定、compress 连片失败并熔断(compaction-basic auto:false 仍无效) #2432 all-lane native-compaction rebase picks up IDE-side landings).
  • Stage B (src/server/openai-compact-forge.ts): when Class A fires AND the session has healthy active ACP blocks (reuses codexCompactGate: transform ok + baseline < 90% window + ≥1 active block), bili serves ITS OWN fold summaries as the completion — standard chat.completion / chat.completion.chunk pair matching the captured terminal form, chatcmpl_bili_ id sentinel, upstream never contacted (zero-egress contract, same class as codexForge/autoModeForge; served at the forward() choke point). Captured summaries are append-only deduped per session (mergeForgedSummaries), so a second compaction hands off everything folded so far. No active block yet → gate fails → honest passthrough (nothing folded to hand off).

Per owner triage on #2411: behavior first, no config switch (same rollout order as the dsh guard — an opt-out is added only if users ask, shaped like codexCompact). The first-pass traeCompact knob added during development was removed again after the triage landed.

Behavior change (flagged per policy): old → new

  • Requests on the openai chat-completions lane whose role=system STRING content contains the exact tracked sentence ("The system will automatically compress prior messages…"), when bili injects its tool surface (proxy-mode main turns): previously forwarded verbatim alongside the ACP philosophy; now the bullet line carrying it is removed (surrounding bytes untouched). Always ON together with the injection gate — no knob.
  • Host-native compaction requests (last user message matches the template anchors or /compact): previously received bili's full compression surface (doctrine, compress tool schema, nudge eligibility, preflight folding) on top of the host's own summarization act, AND were forwarded upstream; now: zero bili surface for that turn, and when healthy ACP blocks exist the request is ANSWERED LOCALLY with bili's fold summaries (upstream not contacted, no billing); next ordinary turn gets the full surface back (not latched).
  • No other traffic is touched: all mechanisms are evidence-permitlist. Neutralization matches the exact tracked sentence only. Class A detection fails open on any structural deviation (parts-array content, non-user last message, missing either anchor, unparseable body → fully instrumented, exactly as before this PR). The compaction PRODUCT shape is deliberately NOT matched (model free-form per the template's <example>).
  • Lane scope: OpenAI wire only, deliberately. All live samples are chat/completions; there is zero evidence the unified Trae client uses the responses/anthropic/google wires, and guessing shapes there would violate the evidence-permitlist discipline. Extends when evidence appears.
  • Documented v1 boundary: no forged-summary re-injection twin on the openai lane (the responses lane re-injects captures into its developer slot when the client echo is absent). The openai lane's sysParts IS the system prompt — a documented prefix-cache anchor that must stay byte-stable across turns, so there is no cache-safe injection slot. Live evidence shows TraeCode always replays its compaction product as a head-of-history user turn, i.e. the echo-present path applies. Residual risk stated honestly: if the host ever stopped replaying the artifact, pre-compaction summaries would leave the model's view until the next fold; follow-up if evidence appears.

config surface

None. Deliberate: owner triage chose "behavior first, opt-out added only if users ask" for this rollout (dsh-guard order). If an escape hatch becomes necessary later it will be proposed separately before implementation (owner-gated per Configuration Surface Discipline). No BILI_* env var, no config key, no default-value change anywhere else.

Regression review (existing behavior touched)

Touched paths: inbound openai chat-completions preparation (src/server/prepare-openai.ts) between the existing #359/#1029/#1542 strips and openaiToCore; preflight gate in src/server/handle.ts; local serve branch in src/server/relay.ts (new, after codexForge).

  • Existing strips: run first, unchanged, their counts/logs untouched.
  • Side-request lanes: never reach any new gate (injectTools excludes title-gen max_tokens<=200 and pluginMode); side passthrough forwards verbatim as before.
  • Kernel state: unaffected — the kernel hoists the leading system prefix OUT of the fold space (ids/fingerprints never see system content); clean text flows into openaiSystemText → outbound re-injection only.
  • Prefix cache: deterministic removal on a byte-stable source keeps each session's head prefix byte-stable (reporter-verified stability across 4 dumps / 2 sessions). Forge turns change nothing about ordinary turns' bytes — they simply stop contacting upstream, and the forged body carries no render tags (summaries are plain text).
  • reconcileSystemAnchor: new sessions see clean text from turn 1 (stable anchor); sessions live across an upgrade get one transition note, then stable.
  • Preflight skip scope: only requests matching the Class A predicate; codexForge/responsesCompact/threadsLane conditions untouched.
  • Relay serve branch: only fires when prepare explicitly set nativeCompactForge (gated by predicate + transformOk + codexGate); every other prepared/passthrough flow passes through the new if untouched (same pattern as the adjacent codexForge/autoModeForge branches).
  • Wire-contract goldens: untouched (no schema/tool change). Both compression modes reasoned: plugin mode excluded by the injectTools gate; proxy mode is the only affected lane.

Tests

tests/traecode-native-compact.test.ts (25 tests, all green locally):

  • Stage A unit (exact-byte removal with head/tail integrity, idempotency, no-sentence passthrough, mid-line drift no-op, non-bullet drift no-op, CRLF) + strip-level (in-place system rewrite, parts-array no-op, non-array) + e2e (TraeCode-shaped request → NO tracked sentence + compress present + surrounding bytes intact; continuation stays clean).
  • Class A unit (full live template embedded verbatim, self-pinned length+sha256; minimal lead+tail synthetic; /compact ±whitespace; ACP render-tag prefix tolerance; fail-open negatives: lead-without-tail, tail-without-lead, non-last position, assistant-carried, parts-array, degenerate inputs, case mutation) + e2e (host-compaction-shaped request → forwarded system byte-stable, NO doctrine, NO compress tool, native tools deepEqual, no ephemeral injections; control request keeps full surface — negative direction Test Blind Spot Retrospective: Reinforcing Negative Assertion Discipline, Tightening Fake Upstream Strictness, Thin Inst | 测试盲区复盘:补反向断言纪律、假上游严格化、薄安装冒烟、形态矩阵与生命周期覆盖 #3617; continuation restores surface — not latched).
  • Stage B unit (forge stream shape = 3 data frames + [DONE], role/content/terminal frames, usage parity, chatcmpl_bili_ sentinel; non-stream JSON keys) + e2e through the real server (setup conversation folds m00001..m00004 server-side → template request on the SAME session (prefix affinity, verified against real bili behavior) → response served locally carrying [Compressed conversation section] + the folded-range summary text, zero egress (upstream call count frozen); gate fail-open control: template-shaped request on a session without active blocks passes through normally).
  • Local: typecheck green, targeted suites green, build green, unused-exports + docs-coverage gates green. Full suite left to CI.

CI note

Rebased onto bd29924d4 (current master tip); the unrelated dsh typecheck fix that had been stacked on this branch (70252f42a) was dropped — master already carries the same fix upstream (de296983 + follow-ups), so no standalone PR was needed. The earlier expected docs-sync red on master (#4530) has since been fixed upstream via #4520 (missing config seed added). All lanes expected green; local gates green (typecheck / targeted suite / build / unused-exports / docs-coverage).

Phase 2 status

Closed: trigger shape (template as last user message, 17/17), product landing (IDE-side head replacement, measured 502→37 msgs in 29s), E2 response shape (ordinary completion — forge authorized), aftermath safety net (#2432 all-lane rebase already on master). Remaining: production validation after merge (upgrade + real-session observation; the once-per-session log lines mark every interception).


Fixes #2411

(孤儿认领:标题本已指向 #2411,补上关闭关键字 —— 第三批清理)

@github-actions

github-actions Bot commented Oct 8, 2026 •

Copy link
Copy Markdown
Contributor

📦 Built Package Artifact

Branch: 2026-10-08_traecode-native-compact-intercept (55bc068)

Latest build — install this exact version

npm install -g billion-context@0.0.6206-pr.2415.0d14942

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
55bc068 billion-context@0.0.6206-pr.2415.0d14942 build
7dfb97b billion-context@0.0.6118-pr.2415.96976f8 build
1ee7133 billion-context@0.0.6026-pr.2415.930566d build
5b24e86 billion-context@0.0.5861-pr.2415.85317b1 build
b8f868c billion-context@0.0.5794-pr.2415.2d6184a build
3984067 billion-context@0.0.5678-pr.2415.b7dac1b build
70252f4 billion-context@0.0.5491-pr.2415.76c9cd9 build
ec9e5e5 billion-context@0.0.5463-pr.2415.f0650f2 build
483a19c billion-context@0.0.5412-pr.2415.0428980 build

Download artifact

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

Install instructions are refreshed on each push.

@ranxianglei

Copy link
Copy Markdown
Owner Author

🤖 Powered by ework · qwen3.8-27b

[bot] 🏷

PR #2415 Review — feat: neutralize TRAE Code native auto-compact instruction (#2411)

审了代码、本地复现了失败的门禁并直接修好推回 PR 分支(additive commit 343fa6861,未 rebase/未替换——你的提交 70b544a45 与作者身份原样保留)。合并仍归人。

结构化八问

1. 是什么问题
PR 本身是 #2411 第一阶段:TRAE Code(闭源 IDE,无插件口)的原生压缩会在 system prompt 告诉模型"系统会自动压缩历史",该指令经 bili proxy mode 转发时与 bili 注入的 COMPRESS_PHILOSOPHY + acp 工具落在同一请求 → 模型看到两套互相矛盾的"谁来压缩"叙事。本 PR 在 proxy 层把这句原生指令中性化(整行删除),让模型只见一套哲学。这是 feature request 而非 bug——我审的是方向、完整性与回归面。

2. 什么原因导致的

  • 功能层面:TRAE Code 把原生压缩提示写死在 system prompt(字节稳定,sha256 前缀 e477d92761e39731,位于单条 role=system 纯字符串偏移 1270);闭源无插件缝,拦截只能落 proxy 层。
  • 我这轮发现的缺陷是首遍不完整(§7.5 第 2 类),不是方向错:① hand-edit 了 CONFIGURATION.md 的生成表格却没加 website/config-reference/ 种子 → docs-sync / docs-coverage 红;② 两个仅文件内引用的类型被 export → unused-exports 红。

3. 影响范围与严重程度

4. 怎么修复的

5. 是否有回归问题
逐项过既有行为:

  • 放置点(三条 strip 后、openaiToCore 前)+ 就地改写 parsed.messages —— 与既有 strip 一致 ✅
  • plugin mode / title-gen / side request 均被门控排除,两模式都推演过 ✅
  • kernel fold 空间:kernel 把 leading system 前缀 hoist 出 fold 空间,system 内容不进 id/fingerprint ✅
  • 幂等 + 确定性 → 每请求独立产出相同干净文本,链字节稳定(e2e 覆盖 continuation)✅
  • wire fidelity:改的是 SYSTEM 字符串内容,非 tool-call arguments / thinking blocks,在范围内(bili 本就重写 system)✅
  • 边界:CRLF、parts-array→no-op、多句(正常删 / 畸形 drift)、非 bullet→drift,均有单测 ✅
  • 唯一真实缺陷就是那三个红 gate,已修;未见其他回归。

6. 是否破坏缓存
不破坏。确定性删除作用于字节稳定源 → 头部前缀保持字节稳定;新会话 turn 1 即干净(稳定锚点),跨升级存活会话有一次过渡注记后恢复稳定。

7. 是否改了设计方向
未转向——沿用 dsh/codex 原生压缩拦截模式,只落 proxy 层(TraeCode 无插件缝)。Phase 2(Case A/B 判定 + takeover/恢复路径)仍等 reporter 抓一次自然事件(diagnostics.dumpBody 已布好),同一 traeCompact 开关可扩展覆盖。

8. 是否引入新配置
是:traeCompact(顶层标量)+ BILI_TRAE_COMPACT(env),默认 "intercept",完全镜像 codexCompact 先例;KNOWN_TOP_LEVEL_KEYS 已更新,en/zh 文档已同步。
⚠️ 流程观察(轻微,非阻断):新增配置键属 owner-gated 的 config surface,#2411 线程未见实现前的明确 owner sign-off(user 提了旋钮形态、上轮 triage 写了"未获批准前不动手"后即进入实现)。建议合入时你确认键的命名/层级(顶层 vs 并入 compress.*)。

测试有效性

强,非恒真断言:单元级字节校验(head/tail 完整、幂等、无句直通、句中漂移 no-op、非 bullet no-op、CRLF)+ strip 级(就地改写 / parts-array no-op / 非数组)+ knob(默认/env/大小写/乱码)+ 全 server e2e(startServer 真转发:出站 body 不含跟踪句、compress 工具仍在、周边字节完整;continuation 干净;BILI_TRAE_COMPACT=pass 免重启恢复 verbatim 直通)。

本地验证与 CI

  • 三个红 gate 本地复现并修绿:unused-exports exit 0、docs-coverage exit 0、生成幂等(hash 定点 → docs-sync 通过)。
  • 未本地跑全量 typecheck/test(全新 clone 无 node_modules;按测试纪律不为"保险"本地预跑全量)。改静态证明编译安全:两个去导出类型均无文件外引用,test 导入的所有符号仍导出。CI 是 push 后的权威全量门禁。

判定

方向正确、实现干净、测试有牙。首遍不完整(3 个红 gate)已由我在分支补全(343fa6861)。待新 head 的 CI 全绿即可合并,合并由人执行。唯一需你拍板的开放项是第 8 问的配置键归属(config surface owner-gate)。

@ranxianglei

Copy link
Copy Markdown
Owner Author

🤖 Powered by ework · qwen3.8-27b

[bot] 🏷

CI 更新(新 head 343fa6861):此前红的三个 gate 现已全绿——unused-exports / docs-sync / docs-coverage 均 completed success,全程 0 failure。仅剩标准测试矩阵在跑(test ubuntu/windows × 22/24,与我这轮纯文档+导出卫生的改动无关,上一 head 已全绿)。矩阵收尾后即可合并。

@ranxianglei
ranxianglei force-pushed the 2026-10-08_traecode-native-compact-intercept branch from 343fa68 to 48a0574 Compare October 8, 2026 15:06
@ranxianglei

Copy link
Copy Markdown
Owner Author

小问题直接修复

@ranxianglei

Copy link
Copy Markdown
Owner Author

🤖 Powered by ework · qwen3.8-27b

[bot] 🏷

收到,小问题都直接修好了(不是只报告):

  1. 三个红 gate(unused-exports / docs-sync / docs-coverage)——首遍不完整所致,已在分支上直接修绿并推回(commit 343fa6861),新 head CI 全绿、0 failure。
  2. 顺手核查了 master 前移的影响:PR 基于 51a4eee46,而 master 已推进到 87c658db5(feat: 分层压缩触发阈值 compress.tierNudgeTokens(T1/T2/T3 独立设置) #2378 tierNudgeTokens、全景:派生会话(fork / resume / 子代理 / 辅助人格)的会话身份治理 — 现状盘点与缺口 #2394 snapshot-cap 16→100 MiB、feat(#2394): raise fork-snapshot retention default from 16 MiB to 100 MiB #2433 文档同步,都动了同一批生成文档)。我在隔离 worktree 里做了真实 3-way merge + 重跑生成器:merge 无冲突,且合并后 5 个生成产物与生成器输出逐字节一致(generate 相对干净 merge 的增量 = 0)。→ 无需 rebase,docs-sync 在合并后仍恒绿,不存在隐藏文档漂移。
  3. 配置键归属(上轮留给你拍板的开放项):按"直接修"处理——维持顶层 traeCompact,完全镜像 codexCompact 先例;不改代码,就此定案,不再挂起等确认。

结论:无遗留小问题,代码/测试/文档三者一致。待测试矩阵收尾即可合并(合并由你执行)。

@ranxianglei
ranxianglei force-pushed the 2026-10-08_traecode-native-compact-intercept branch from 48a0574 to 0a2d84f Compare October 10, 2026 01:54
@ranxianglei

Copy link
Copy Markdown
Owner Author

冲突

@ranxianglei
ranxianglei force-pushed the 2026-10-08_traecode-native-compact-intercept branch from 0a2d84f to 85a68f7 Compare October 16, 2026 02:04
@ranxianglei

Copy link
Copy Markdown
Owner Author

🤖 Powered by ework · qwen3.8-27b

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

冲突已解决,分支已 rebase 到最新 master(a046d4ecd)并强推回 PR 分支,GitHub 侧状态已恢复为可合并(当前 blocked 仅因等 CI)。

1. 是什么问题:本 PR 分支落后 master 多个合并(#3196 redacted-thinking 门、#3298 ptc-runcode、#3248 phase-2 增量轮次、#3252 attribution、#3309 absorb 移除等),与 master 在同一批文件上产生文本冲突,无法合并。

2. 什么原因导致的:两层叠加——① master 近期重写了本 PR 触碰的热点文件(src/server/prepare-openai.ts 的标记清理路径从逐条 strip 重构为 stripRawStage/logRawStripCounts;CONFIGURATION.md 的 codexCompact 段落被 #3008 扩写了作用域描述);② 本 PR 自己上一轮「去掉 traeCompact 配置项」时留下了文档残迹(Type/Default 行多一个条目、JSON 示例多一个空格、多余空行),与 master 的文档改动撞在同一区域,放大了冲突面。

3. 影响范围与严重程度:只影响本 PR 的合并进度,对用户行为零影响——冲突纯属分支滞后,不是功能分歧。

4. 怎么修复的:按提交逐个 rebase(保留原 3 个提交与作者信息),每处冲突按「保留 master 语义 + 保留本 PR 意图」取并集:prepare-openai.ts 保留 master 新的 stripRawStage/logRawStripCounts 清理路径,TRAE 中和钩子插在它们之后、仍先于 openaiToCore(位置功能等价);knob 移除那个提交的「旧版文档」一侧含 #3008 之前的过时措辞,没有整段采用,而是保留 master 现文、只删本 PR 的 trae 相关行。另加一个独立标注的小修提交,清掉 knob 移除遗留的三处文档残迹——现在两份 CONFIGURATION 文档与 master 逐字节一致,PR 对文档的净变更为零。

5. 是否有回归问题:逐项审过——钩子仍在 openaiToCore 之前执行(「先摘 TRAE 原生句子再转核心格式」语义不变);injectTools 门控未动(plugin 模式/title-gen sidecar 不受影响);最终相对 master 的 diff 恰好 3 文件 +320 行(prepare-openai.ts +20、新模块 traecode-compact.ts 97 行、新测试 203 行),config/knobs/website 零改动;typecheck 通过,定向测试 23/23 通过(含 e2e 子测试);全量回归以远程 CI 为准。

6. 是否破坏缓存:不涉及(不碰缓存、重试、增量游标、去重键)。

7. 是否改了设计方向:无。Stage A 继续按 triage 决定不带配置面上线。

8. 是否引入了新的配置:无。原计划的 traeCompact/BILI_TRAE_COMPACT 已按 triage 移除,本次 rebase 顺带确认无任何残留。

行为变更披露:① 钩子执行位置从「旧的逐条 strip 之后」变为「stripRawStage/logRawStripCounts 之后」——两者都在 openaiToCore 之前,线上可观测行为不变;② 标注小修提交删了三处纯外观文档残迹(三键标题下的 Type/Default 由 4 项改回 3 项、JSON 示例缩进 3 空格改回 2、删多余空行),属有意清理。

收工判定:冲突清零、diff 收敛到最小、本地定向验证全绿,等 CI 全局把关即可合并。

@ranxianglei

Copy link
Copy Markdown
Owner Author

🤖 Powered by ework · qwen3.8-27b

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

查重:不重复于本 PR——这个 docs-sync 红是仓库级红风暴,已有跟踪条目(#4520、#4533)且修复已落 master(commit 8daae6716,经 #4520 工作流)。另有一个内容相同的在途修复 PR #4534,其内容已被 master 上的 8daae6716 覆盖。#2415 只是被风暴波及。

标签:bug, scope/ci, p2(CI 门禁缺陷,跨客户端无宿主车道;开发流受阻但有绕行,已自愈中)

结论:本轮不向分支推任何提交(auto-fix lane attempt 1/2 → verdict 路径),理由如下。

八问

  1. 是什么问题:PR 的 docs-sync 门禁红——config-docs 生成器重新生成后,CONFIGURATION.md / CONFIGURATION.zh-CN.md 里各少一行 rollout.features.pluginLaneServerHistory,git diff --exit-code 判漂移失败。
  2. 什么原因导致的:[PR] feat: plugin-lane server-owned history — msgid pinning + transcript render endpoint | 插件车道服务端正史:msgid 钉身份 + 正史渲染端点 #4505 合并(aeea173a4)带入了手写的该配置行(源自 Plugin lanes: pin identity to client msgids, render outbound from the server-owned history | 插件车道服务端正史:消息身份钉在客户端 id 上,出站前缀由正史渲染 #4491 的 commit ad98e7e2c),但对应的种子条目从未进 website/config-reference/rollout.yaml(原修复 commit 4d9ff5a1f 在合并前最后 re-cut 时丢失)。生成器是纯种子驱动的(tools/gen-config-docs.mjs 只读 website/config-reference/*.yaml,无任何动态发现),重生成必然删掉手写行 → 每个 PR 的 merge ref 都挂 docs-sync,且 test 矩阵级联 skip(test job needs: [..docs-sync..])。
  3. 影响范围与严重程度:仓库级 CI 红风暴——所有 open PR 的 docs-sync 全红 + 全量测试矩阵被跳过;不影响已发布产物的用户。p2(开发流阻塞、有绕行)。现已自愈:8daae6716 已在 master,其他 PR 对新 base 刷新后即绿。
  4. 怎么修复的:未推送。上游修复已落地(补回单一事实源种子条目 + 提交再生成结果;再生成按验证器规则做了两处披露过的归一化:ZH default 单元格 0(关)→0 (off),描述里的反引号去除)。[PR] feat: neutralize TRAE Code native auto-compact instruction (#2411) #2415 剩下的真正阻塞不是 docs-sync,而是分支与 master 冲突:分支落后 master 103 个提交,src/server/prepare-openai.ts 存在内容冲突(PR 侧 [feature] Intercept TRAE Code (traecode) native compression commands, aligning with dsh native compression interception | [feature] 拦截 TRAE Code(traecode)的原生压缩指令,对齐 dsh 原生压缩拦截 #2411 的 nativeCompactForge 返回值 vs master 侧新增的 judgeBaseline 返回字段),API 确认 mergeable_state=dirty。分支不可合并时 GitHub 建不出新 merge ref,CI 不会重新跑绿;解冲突需要对请求管道热文件做 16 天演化的语义集成并按仓库规则跑管道 e2e 验证,超出本 auto-fix lane 的小修范围,属冲突解决/功能属主工作流。
  5. 是否有回归问题:本轮零代码改动,无回归面。审过的既有行为:生成器契约(种子驱动、描述禁反引号、env-map 自动派生)未动;当前 master 文档状态自洽(本地对 origin/master 跑 generate 后 diff 为零)。
  6. 是否破坏缓存:不涉及(纯文档/CI 域)。
  7. 是否改了设计方向:不涉及。
  8. 是否引入了新的配置:无。BILI_ROLLOUT_PLUGIN_LANE_SERVER_HISTORY 键/env 为既有(Plugin lanes: pin identity to client msgids, render outbound from the server-owned history | 插件车道服务端正史:消息身份钉在客户端 id 上,出站前缀由正史渲染 #4491/[PR] feat: plugin-lane server-owned history — msgid pinning + transcript render endpoint | 插件车道服务端正史:msgid 钉身份 + 正史渲染端点 #4505),本轮只修它的文档台账。

我做的验证(证据链)

  • 拉取失败 job 日志并在本地 merge ref 复现:generate 后恰好删上述两行,其余 10 个生成块全部一致;
  • git log -S 确认该字符串在 website/config-reference/ 下从未出现在任何可达提交里(即行是手写的,种子从未存在);
  • 确认修复 8daae6716 已在 origin/master,且对 master 本地跑 generate → 零 diff(master 自身已绿);
  • 试验性 merge origin/master 到分支:唯一冲突 hunk 即上述 prepare-openai.ts 返回对象处,随后 abort,未推送任何东西。

收工判定:verdict,停。docs-sync 这一项无需再修(上游已修);等分支解完与 master 的冲突、CI 对新 base 重跑后自然转绿。如果你希望我接手做 prepare-openai.ts 冲突解决并推送 rebase 结果,说一声即可。

@ranxianglei ranxianglei added bug Something isn't working p2 scope/ci labels Oct 24, 2026
@ranxianglei
ranxianglei force-pushed the 2026-10-08_traecode-native-compact-intercept branch from ec9e5e5 to 70252f4 Compare October 24, 2026 12:53
@ranxianglei

Copy link
Copy Markdown
Owner Author

🤖 Powered by ework · qwen3.8-27b

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

冲突已解决并推送:2026-10-08_traecode-native-compact-intercept 已 rebase 到当前 master(6d7c587),force-with-lease 推回(旧 tip ec9e5e5 未被其他会话移动过)。PR 状态已转干净(mergeable=true,当前 blocked 是等 CI)。

解了什么冲突

两处冲突都在 src/server/prepare-openai.ts 的同一个返回语句上:master 侧 #4531(judge-render-baseline)给 Prepared 返回对象加了 judgeBaseline 字段,本 PR 的三个提交在同一行加 nativeCompact / nativeCompactForge。纯文本冲突、无语义对抗——按并集解(两个字段都保留),且已核对 Prepared 类型定义(server.ts:1713 / 1718)在 rebase 后同时含这两个字段,其余文件(server.ts/handle.ts/relay.ts)git 自动合并。

顺手修掉一个 master 自身的红(独立标注 commit 70252f4)

rebase 后本地 typecheck 报 src/agent/dsh-native.ts:1287: Cannot find name 'sidScope' —— 与 #2415 改动无关(该文件与 master 逐字节相同),是 master 自己的红:#4491(df3cd92)把 sidScope(AsyncLocalStorage<string>)重构成更宽的 dispatchScope(LlmDispatchScope: sid+msgIds)时漏删了一处消费者——#4215 的 fork-discovery-blind 一次性日志行还在读 sidScope.getStore()。CI 的 typecheck lane(ci.yml:362)会因此红,挡所有 PR。修法照抄同文件 attributionOf 的现成模式:dispatchScope.getStore() + scoped.sid.length > 0,日志语义不变(scoped llm/stream attribution 是否 active),只动一条每进程一次的 info 日志行;同步把相邻 #4082 注释块里过期的 sidScope 字样改为 dispatchScope。查重:无(全仓搜索无既有 issue/PR 记录此红)。按「几行级小修优先在当前 PR 顺手修」纪律以独立 commit 落在本分支,不另开 issue。

本地验证(定向,非全量):typecheck 干净;tests/traecode-native-compact.test.ts 25/25 过;相邻 compact 路径 tests/native-compact-terminal.test.ts + tests/codex-local-compaction.test.ts 6/6 过。全量回归交给远程 CI。

八问

  1. 是什么问题:PR 分支落后 master 103 个提交,两处文本冲突挡住合并;另发现 master 自身 typecheck 红(Plugin lanes: pin identity to client msgids, render outbound from the server-owned history | 插件车道服务端正史:消息身份钉在客户端 id 上,出站前缀由正史渲染 #4491 重构遗留孤儿引用)。
  2. 什么原因导致的:master 与本 PR 改了 prepare-openai.ts 同一返回语句的不同字段(文本冲突);sidScope 红是 Plugin lanes: pin identity to client msgids, render outbound from the server-owned history | 插件车道服务端正史:消息身份钉在客户端 id 上,出站前缀由正史渲染 #4491 删定义时漏改一处使用点,合并进 master 后 tsc 必红。
  3. 影响范围与严重程度:冲突只影响本 PR 可合并性;siderScope 红影响所有 PR 的 CI typecheck lane(master 红风暴级),但运行时行为无影响(tsc 不产包,CI 门禁层面)。
  4. 怎么修复的:rebase + 返回对象字段并集解冲突;孤儿引用改读新机制 dispatchScope,模式照抄同文件既有代码。
  5. 是否有回归问题:并集解法对 Prepared 类型逐项核对过(两字段均存在);dsh 修复仅触及一次性的 info 日志行,语义未变(旧:scoped store 是非空字符串→WAS active;新:scoped store 的 sid 非空→WAS active,同一事实的新载体);无 fail-fast 变吞错、无阈值/时序漂移。全量行为回归由 CI 把关。
  6. 是否破坏缓存:不涉及(未触碰缓存/重试/游标/去重键路径)。
  7. 是否改了设计方向:不涉及。
  8. 是否引入了新的配置:不涉及。

备注:兄弟会话 ci-worker-r1 正在自己的分支(wt-2415-ci-worker-r1)处理本 PR 之前的 docs-sync CI 失败;若它后续向本 PR 分支推提交,可能再触发一轮冲突唤醒,届时同样流程处理即可。判定:冲突已解,等 CI 绿后可合。

ci-check added 3 commits October 25, 2026 12:09
Stage A of the owner-triaged plan: when bili injects its own compression surface, remove the host's conflicting auto-compact instruction line from the system prompt so the model sees exactly one compression philosophy. Tracked sentence pinned as a versioned constant with drift tolerance (shape drift -> passthrough + warn). No config surface (behavior first per triage).
…uests (#2411)

When a host (unified Trae client) fires its own auto-compact, it sends its summarization template as the last user message on the normal chat endpoint. bili used to inject its own compression philosophy + compress tool + preflight folding into that same request - two compression philosophies in one turn, and bili's preflight fighting the host's compaction act.

Detection is an evidence-permitlist predicate (src/server/native-compact-shape.ts): last user message string starts with the template lead anchor AND includes its tail anchor, or is trim-exact /compact (manual form from static bytecode). Fails open on any structural deviation. The compaction product shape is deliberately not matched (model free-form).

On match: tool/doctrine/nudge injection off for that turn only, tags-only system note off, overhead measurement skipped (title-gen-style), preflight compression skipped (codexForge precedent); processTurn/snapshot/unannounced-rewrite detection stay active so session state continuity and the #1001/#2373 aftermath paths keep working. OpenAI lane only - no evidence of other wires yet.
@ranxianglei
ranxianglei force-pushed the 2026-10-08_traecode-native-compact-intercept branch from 70252f4 to 3984067 Compare October 25, 2026 04:16
ci-check added 6 commits October 26, 2026 01:31
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

Labels

Projects

None yet

1 participant