From 5dbea23be10ff7dffe8a9af66a38bf604e37acec Mon Sep 17 00:00:00 2001 From: awork Date: Fri, 9 Oct 2026 15:05:29 +0800 Subject: [PATCH 1/2] =?UTF-8?q?fix(dsh):=20#1772=20conclusion=20correction?= =?UTF-8?q?=20=E2=80=94=20profile-layer=20full-snapshot=20patch=20CAN=20sw?= =?UTF-8?q?itch=20off=20web-profile=20native=20auto-compaction=20(#2474)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The #1772 boot warning ended in a dead end ('no patch layer can reach'). Verified live against dsh 0.2.1-alpha.1: preset-standard is an ordinary bundle-layer entry; a profile-level cordis.patch.yml row (applied after every bundle) replaces its config WHOLESALE, so a full-snapshot override carrying auto:false under compaction-basic switches off native auto-compaction. The once-per-process warning now names that recipe plus both verified traps (a partial snippet drops everything not restated — other plugins AND the preset's id/order identity; - insert: with the same id appends a dead duplicate row); launcher stderr, config doc, bundle-patch header and CLIENTS(en/zh)/README(en/zh) corrected to match; the regression test pins the exit pointer. Snapshot-freeze walkthrough lives in the companion CONFIGURATION.md PR (#2476). Supersedes #1786's dead recipe (.agent-presets user root removed in dsh 0.1.7+). Refs #2474 --- CLIENTS.md | 27 +++++++++++++++++++-------- CLIENTS.zh-CN.md | 2 +- README.md | 2 +- README.zh-CN.md | 2 +- dsh.bundle.patch.yml | 6 ++++++ src/agent/dsh-native.ts | 18 ++++++++++++------ src/config.ts | 6 ++++-- src/launcher.ts | 18 ++++++++++-------- tests/dsh-native.test.ts | 7 +++++++ 9 files changed, 61 insertions(+), 27 deletions(-) diff --git a/CLIENTS.md b/CLIENTS.md index a7189b8137..d4e7553105 100644 --- a/CLIENTS.md +++ b/CLIENTS.md @@ -80,14 +80,25 @@ Two lanes, same plugin (#941): settings overlay rewrites those providers' `baseURL`s to `/bili/` URLs, so the traffic reaches the proxy regardless of which fetch the transport uses or what the attribution state is. - - **Web-profile caveat (#1772):** when a profile's bundles include - `@deepseek-ai/dsh-web-app`, the running `compaction-basic` instance lives - inside an agent preset (`preset-standard.config.plugins`) that no patch - layer can reach by id — dsh's patch engine indexes only top-level rows and - true group children — so the bundled `auto: false` lands on web-app's - already-disabled host-plane row and the preset instance keeps - auto-compaction ON. The plugin logs a one-time `[dsh-client]` warning at - boot in such profiles; ACP compression is unaffected. + - **Web-profile caveat (#1772, corrected by #2474):** when a profile's + bundles include `@deepseek-ai/dsh-web-app`, the running `compaction-basic` + instance lives inside an agent preset (`preset-standard.config.plugins`). + No patch layer can address that NESTED row by id — dsh's patch engine + indexes only top-level rows and true group children — so the bundled + `auto: false` lands on web-app's already-disabled host-plane row and the + preset instance keeps auto-compaction ON. But `preset-standard` itself is + an ordinary bundle-layer entry: a profile-level patch (your profile's + `cordis.patch.yml`, applied after every bundle) overrides it by id with a + FULL-SNAPSHOT `config` — copy the complete preset config from + `dsh --profile --dump-config`, add `config.auto: false` under its + `compaction-basic` row, append the result to `cordis.patch.yml`. Config + replacement is WHOLESALE: a partial snippet silently drops everything not + restated — including the preset's own `id`/`order` identity, which can + leave the preset unrecognized by the roster — and `- insert:` with the + same id appends a second dead row instead of merging. The snapshot also + freezes the roster until re-copied after a dsh preset update. The plugin + logs a one-time `[dsh-client]` warning naming this recipe at boot in such + profiles; ACP compression is unaffected. Under a `bili dsh` launch the plugin ATTACHES to the launcher's proxy (no second spawn). Raw upstream URLs rewrite to `/bili/` like diff --git a/CLIENTS.zh-CN.md b/CLIENTS.zh-CN.md index 9e2d78f25a..d5c1a48c52 100644 --- a/CLIENTS.zh-CN.md +++ b/CLIENTS.zh-CN.md @@ -14,7 +14,7 @@ - **桌面应用(Electron 宿主):** 同一插件也运行在 deepseek-harness **desktop** 应用内(经其应用内插件管理器安装)。此时 bootstrap 在应用进程内拉起代理:该进程的 `process.execPath` 是 Electron 二进制而非 Node,GUI 的 PATH 又不含常规安装目录 —— `resolveNodeRuntime`(#819/#1429)先探测众所周知的安装位置(`/opt/homebrew/bin`、`/usr/local/bin`、Volta 等),再回退到以纯 Node 方式运行应用自身二进制(`ELECTRON_RUN_AS_NODE=1`,强制注入子进程 env),于是无需 PATH 里有独立 Node 也能零配置压缩;设 `BILLION_CONTEXT_NODE` 可强制指定某个 Node(优先于两者)。#1429 之前该路径在 spawn 前抛错,所有会话静默降级为直连(不压缩),只能从 bili.log 里发现。 - **自动更新保持各 profile 同步:** 刷新有两个触发器 —— 全局自更新完成后,以及**profile 自己的代理**在周期检查里发现注册表有新版本时(全局 bili 从不运行也一样刷新,#1196 —— 插件市场安装的用户往往根本没有全局安装)。两种触发器都扫描 `~/.dsh/profiles/*/package.json`,把注册表钉住的 `billion-context` 依赖刷新到目标版本(全局触发器刷到新全局版本,自触发刷到注册表最新),统一经 dsh 自己的 `plugin add` 通道,绝不在位覆盖 —— 加载的插件与代理从此不再漂移(#953);钉在本地源的 profile 不动。刷新是尽力而为,失败下个周期重试,绝不会让代理或更新本身失败。 - **已报告:Profile 安装下部分传输零代理流量(#1158,调查中):** dsh `llm-pi-ai` 层的部分传输服务会话**从未有任何模型请求到达代理**(日志无 `processTurn`,调用 bili 工具返回 404 "no model request has arrived"),而同宿主的其他 provider 正常。根因仍在用运行时证据定性 —— 候选:传输层 fetch 形态(SDK 注入 fetch / 非全局 dispatcher)或宿主侧归属缺口导致流量未被 takeover gate 认领。检测:此类情况会打一次性 `[plugin] NO MODEL REQUESTS seen for conversation …` 告警,dsh 插件还会把归属 gate 放行的每个端点各记一条日志(每进程一次)。期间可靠规避:改用 `bili dsh` 启动 —— 启动器的 settings overlay 会把那些 provider 的 `baseURL` 重写为 `/bili/` URL,无论传输层使用哪种 fetch、归属状态如何,流量都必然过代理。 -- **Web profile 说明(#1772):** 当 profile 的 bundles 含 `@deepseek-ai/dsh-web-app` 时,真正运行的 `compaction-basic` 实例位于 agent preset(`preset-standard.config.plugins`)内部 —— dsh 的 patch 引擎只按 id 索引顶层条目与真 group(`group: true` 且 config 为数组)的子项,preset 内的嵌套行任何 patch 层都够不到。于是 bundle 里的 `auto: false` 落在 web-app 已禁用的宿主平面行上,preset 实例保持自动压缩开启。此类 profile 启动时插件打一条一次性 `[dsh-client]` 告警;ACP 压缩不受影响。 +- **Web profile 说明(#1772,#2474 修正):** 当 profile 的 bundles 含 `@deepseek-ai/dsh-web-app` 时,真正运行的 `compaction-basic` 实例位于 agent preset(`preset-standard.config.plugins`)内部 —— dsh 的 patch 引擎只按 id 索引顶层条目与真 group(`group: true` 且 config 为数组)的子项,preset 内的嵌套行任何 patch 层都无法**按 id 直寻**。于是 bundle 里的 `auto: false` 落在 web-app 已禁用的宿主平面行上,preset 实例保持自动压缩开启。但 `preset-standard` 本身是 bundle 层的普通顶层条目:profile 层 patch(你 profile 自己的 `cordis.patch.yml`,在所有 bundle 之后生效)可用同 id + **完整快照** `config` 整体覆盖它 —— 从 `dsh --profile --dump-config` 抄下完整的 preset config,在其 `compaction-basic` 行下加 `config.auto: false`,把结果追加进 `cordis.patch.yml`。Config 替换是**整体语义**(片段会静默丢掉一切未重述的键 —— 不只是其他插件,连 preset 自己的 `id`/`order` 身份也会丢,可能使 roster 无法识别该 preset);`- insert:` 同 id 则是在末尾追加一条死行而非合并。dsh 升级 preset 后快照冻结 roster、需重抄一次。此类 profile 启动时插件打一条一次性 `[dsh-client]` 告警并给出该配方;ACP 压缩不受影响。 `bili dsh` 启动下插件**附看**(attach)启动器的代理(不二次拉起)。裸上游 URL 与 spawn 模式一样重写为 `/bili/`(回环代理目标永不被代理 env 拦截,等于直接绕开 MITM);已经路由的 `/bili/` 前缀请求原样放行、只盖章。已知局限:手动 `/compact` 没有 dsh 侧事件钩子,其边界交给内核的自然 ingest diff(非 web profile 下自动压缩已关,影响罕见;web profile 见上方 #1772 说明)。 diff --git a/README.md b/README.md index 94cc0e9511..c6b62ebb29 100644 --- a/README.md +++ b/README.md @@ -252,7 +252,7 @@ bili claude # launch claude through the proxy bili omp # pi-style, file-free (#535): env + extension registerProvider + compaction cancel, real ~/.omp untouched bili opencode # OpenCode (1.x & 2.x): full guide in the [OpenCode](CLIENTS.md#opencode) section below bili hermes # file-free (#535): hermes proxy env (HTTPS_PROXY + combined CA bundle via SSL_CERT_FILE) — https via CONNECT MITM, http via absolute-form forward proxy; real ~/.hermes untouched -bili dsh # deepseek-harness: full native plugin injected via --patch (#941) — real dsh tools, session-bound /acp + /acp-cache (plugin mode); non-loopback upstreams ride proxy envs, loopback keeps the overlay DSH_HOME rewrite (#535); dsh auto-compaction off outside web profiles (#1772) +bili dsh # deepseek-harness: full native plugin injected via --patch (#941) — real dsh tools, session-bound /acp + /acp-cache (plugin mode); non-loopback upstreams ride proxy envs, loopback keeps the overlay DSH_HOME rewrite (#535); dsh auto-compaction off outside web profiles, and switchable off there via a profile-level full-snapshot override of preset-standard (#1772/#2474) bili codebuddy # Tencent CodeBuddy Code CLI: CODEBUDDY_BASE_URL /bili/ rewrite (OpenAI chat completions wire), budget aligned via CODEBUDDY_AUTO_COMPACT_WINDOW; real ~/.codebuddy untouched bili qoder # qoder: model endpoint is hardcoded https (no /bili/ rewrite possible) — cert-MITM via HTTPS_PROXY + NODE_EXTRA_CA_CERTS, default model hosts whitelisted (#653) bili trae # Trae CLI (ByteDance, closed Go binary, no base-URL override) — cert-MITM via HTTPS_PROXY + SSL_CERT_FILE, model host from TRAE_CLI_API_HOST or the default enterprise gateway (#655) diff --git a/README.zh-CN.md b/README.zh-CN.md index 611c525b15..59c6fd8ee5 100644 --- a/README.zh-CN.md +++ b/README.zh-CN.md @@ -204,7 +204,7 @@ bili claude # 拉起 claude bili omp # pi 同款,file-free(#535):环境变量 + 扩展 registerProvider + 压缩取消,真实 ~/.omp 不动 bili opencode # OpenCode(1.x 与 2.x):完整指南见下文 [OpenCode](CLIENTS.zh-CN.md#opencode) 一节 bili hermes # file-free(#535):hermes 代理环境变量(HTTPS_PROXY + SSL_CERT_FILE 组合 CA bundle)—— https 走 CONNECT MITM,http 走绝对形式转发;真实 ~/.hermes 不动 -bili dsh # deepseek-harness:经 --patch 注入完整原生插件(#941) —— 真实 dsh 工具、会话绑定 /acp(plugin 模式);非回环上游走代理 env,回环保留 overlay DSH_HOME 改写(#535);dsh 自动压缩关(web profile 除外——preset 内实例无法经 patch 触及,#1772) +bili dsh # deepseek-harness:经 --patch 注入完整原生插件(#941) —— 真实 dsh 工具、会话绑定 /acp(plugin 模式);非回环上游走代理 env,回环保留 overlay DSH_HOME 改写(#535);dsh 自动压缩关(web profile 除外——嵌套行不可按 id 直寻,但可经 profile 层完整快照覆盖 preset-standard 关掉,#1772/#2474) bili codebuddy # Tencent CodeBuddy Code CLI:CODEBUDDY_BASE_URL /bili/ 重写(OpenAI chat completions wire),预算对齐走 CODEBUDDY_AUTO_COMPACT_WINDOW;真实 ~/.codebuddy 不动 bili qoder # qoder:模型端点硬编码 https(无法 /bili/ 改写)—— 证书 MITM(HTTPS_PROXY + NODE_EXTRA_CA_CERTS),默认模型主机已加白名单(#653) bili trae # Trae CLI(字节跳动,闭源 Go 二进制,无 base-URL 覆盖)—— 证书 MITM(HTTPS_PROXY + SSL_CERT_FILE),模型主机取 TRAE_CLI_API_HOST 或默认企业网关(#655) diff --git a/dsh.bundle.patch.yml b/dsh.bundle.patch.yml index e689a147f1..6af43b5533 100644 --- a/dsh.bundle.patch.yml +++ b/dsh.bundle.patch.yml @@ -2,6 +2,12 @@ # Mounted automatically when the profile's package.json lists billion-context # in dsh.profile.bundles (`dsh plugin --profile add billion-context`); # the loader resolves `name` from the profile's node_modules. +# #1772/#2474: the `auto: false` below targets the HOST-PLANE compaction-basic +# row. In profiles bundling @deepseek-ai/dsh-web-app that row is disabled and +# the running instance lives inside the preset-standard entry, which this +# bundle layer cannot address by id — switching off auto-compaction there +# needs a profile-level full-snapshot override of preset-standard (config +# replaces wholesale; see the plugin's boot warning / #2474). - insert: - id: bili-native name: billion-context diff --git a/src/agent/dsh-native.ts b/src/agent/dsh-native.ts index ea46f33ad1..ea860065e0 100644 --- a/src/agent/dsh-native.ts +++ b/src/agent/dsh-native.ts @@ -1217,12 +1217,18 @@ export function apply(ctx: PluginContext): void { refreshModelInfo(register.base ?? state.origin); } - // #1772: in profiles bundling @deepseek-ai/dsh-web-app the RUNNING + // #1772/#2474: in profiles bundling @deepseek-ai/dsh-web-app the RUNNING // compaction-basic instance sits inside an agent preset (preset-standard's - // config.plugins), which no patch layer can reach by id — the bundled - // `auto: false` lands on web-app's already-disabled host-plane row and the - // preset instance keeps auto-compaction ON. Surface it once through the - // durable channel (GUI hosts swallow stderr); ACP compression is unaffected. + // config.plugins). No patch layer can address that NESTED row by id — the + // engine indexes top-level rows only — so the bundled `auto: false` lands + // on web-app's already-disabled host-plane row and the preset instance + // keeps auto-compaction ON. #2474 corrected the earlier "unreachable" + // conclusion: preset-standard itself is an ordinary bundle-layer entry, + // and a profile-layer patch (applied after every bundle) can replace its + // config WHOLESALE with a full snapshot carrying auto:false — so the + // warning names that recipe instead of ending in a dead end. Surface it + // once through the durable channel (GUI hosts swallow stderr); ACP + // compression is unaffected. if (!webProfileWarned) { let bundles: readonly string[] | undefined; try { @@ -1238,7 +1244,7 @@ export function apply(ctx: PluginContext): void { } if (bundles !== undefined && bundles.includes("@deepseek-ai/dsh-web-app")) { webProfileWarned = true; - persistClientEvent("profile bundles include @deepseek-ai/dsh-web-app — its agent presets run their own compaction-basic where the bundle patch cannot set auto:false (#1772); dsh native auto-compaction stays enabled in this profile (ACP compression unaffected)"); + persistClientEvent("profile bundles include @deepseek-ai/dsh-web-app — its agent presets run their own compaction-basic where the bundle patch cannot set auto:false by id (#1772); dsh native auto-compaction stays enabled in this profile (ACP compression unaffected). To switch it off (#2474): append to your profile's cordis.patch.yml a FULL-SNAPSHOT override of the preset-standard entry (- id: preset-standard + the complete config copied from 'dsh --profile --dump-config', plus config.auto: false under its compaction-basic row) — the patch engine replaces a matched row's config WHOLESALE, so a partial snippet silently drops everything you did not restate (the other plugins AND the preset's id/order identity), and - insert: with the same id appends a dead duplicate row instead of merging; the snapshot also freezes the roster until you re-copy it after a dsh preset update"); } } diff --git a/src/config.ts b/src/config.ts index 10698890d6..28353a21a0 100644 --- a/src/config.ts +++ b/src/config.ts @@ -892,8 +892,10 @@ export type ProxyOptions = { * substrate, which is why this stays off by default. On non-web * profiles the shipped bundle patch (`auto: false`) still suppresses * AUTO-triggering — only manual /compact benefits there; on web - * profiles (where no patch layer reaches the preset-nested instance, - * #1772) auto-triggering works as-is. Enable with + * profiles the preset-nested instance is not reachable by id from any + * bundle patch (#1772), but a profile-layer full-snapshot override of + * preset-standard can switch it off (#2474); absent that, + * auto-triggering works as-is. Enable with * `{ "dsh": { "allowDshCompaction": true } }` in the config file, or env * BILI_ALLOW_DSH_COMPACTION=1. */ allowDshCompaction?: boolean; diff --git a/src/launcher.ts b/src/launcher.ts index e210b3eaf9..35dd2abed0 100644 --- a/src/launcher.ts +++ b/src/launcher.ts @@ -4944,15 +4944,17 @@ export async function runLaunch(params: RunLaunchParams, deps: LauncherDeps = {} } else if (allowDshCompactionState(process.env).enabled !== true) { // #2360 §3: native install owns the plugin chain — the overlay patch // above would insert a SECOND bili-native entry and hard-fail dsh - // boot, and DSH mounts compaction in the agent preset's group where - // a profile-level dsh.bundle.patch.yml cannot reach it either - // (#1772/#2360) — so compaction-basic auto:false is NOT in force and - // dsh native compaction stays armed. Say so at launch instead of - // leaving the user to discover a landed checkpoint through - // destroyed-substrate errors; the live protection is the proxy's - // wire-level refusal on every lane (openai/anthropic/responses). + // boot, and DSH mounts compaction in an agent preset whose nested + // rows no patch layer can address by id (#1772/#2360) — so + // compaction-basic auto:false is NOT in force unless the user + // applies the #2474 full-snapshot override of preset-standard in + // their profile's cordis.patch.yml, and dsh native compaction + // stays armed otherwise. Say so at launch instead of leaving the + // user to discover a landed checkpoint through destroyed-substrate + // errors; the live protection is the proxy's wire-level refusal on + // every lane (openai/anthropic/responses). console.error( - "bili: dsh native install detected — the launcher's compaction-basic auto:false overlay patch is skipped (a second bili-native entry would hard-fail dsh boot), and DSH mounts compaction in the agent preset where profile patches cannot reach it (#1772/#2360): dsh native compaction stays ARMED. Protection is bili's wire-level refusal of dsh compaction calls on all lanes (openai/anthropic/responses, #1729/#2193/#2360) — if you see 'compression substrate appears destroyed' or chained 'compress FAILED' errors, a dsh checkpoint has landed outside bili's knowledge.", + "bili: dsh native install detected — the launcher's compaction-basic auto:false overlay patch is skipped (a second bili-native entry would hard-fail dsh boot), and DSH mounts compaction in an agent preset whose nested rows no patch layer can address by id (#1772/#2360): dsh native compaction stays ARMED unless you apply the #2474 full-snapshot override of the preset-standard row in your profile's cordis.patch.yml (config replaces wholesale — see the plugin's boot warning for the exact recipe). Protection is bili's wire-level refusal of dsh compaction calls on all lanes (openai/anthropic/responses, #1729/#2193/#2360) — if you see 'compression substrate appears destroyed' or chained 'compress FAILED' errors, a dsh checkpoint has landed outside bili's knowledge.", ); } if (dshAcpPatch) clientArgs = dshArgsWithPatch(clientArgs, dshAcpPatch); diff --git a/tests/dsh-native.test.ts b/tests/dsh-native.test.ts index 3bfb0d0ecc..c9bf7ffeef 100644 --- a/tests/dsh-native.test.ts +++ b/tests/dsh-native.test.ts @@ -805,6 +805,13 @@ test("#1772 apply(): web-profile compaction caveat warns once in the durable log apply(ctx); assert.equal(warnLines().length, 1); assert.match(warnLines()[0], /#1772/); + // #2474: the caveat must point at the working exit (full-snapshot + // override of preset-standard via cordis.patch.yml), not end in a + // dead end — pin the pointer so the correction can't regress. + assert.match(warnLines()[0], /#2474/); + assert.match(warnLines()[0], /cordis\.patch\.yml/); + assert.match(warnLines()[0], /WHOLESALE/); + assert.match(warnLines()[0], /insert:/); // #1791: settle each apply's attach chain while the mock is still // open — a deferred probe settling against a closed mock runs the // spawn fallback mid-way through a LATER test and clobbers the From a64efdd601ac51cfae99bbe6f1a2071c3df2677b Mon Sep 17 00:00:00 2001 From: awork Date: Fri, 9 Oct 2026 15:17:37 +0800 Subject: [PATCH 2/2] docs(config): correct the refuted 'no patch layer reaches' claim left in the allowDshCompaction env-table rows (#1772/#2474) Review pass-fix for the #1772 conclusion correction in this PR: the BILI_ALLOW_DSH_COMPACTION rows in CONFIGURATION.md / CONFIGURATION.zh-CN.md still asserted the pre-#2474 dead-end ('no patch layer reaches the preset-nested instance'). Reworded to the corrected mechanism statement used elsewhere in this PR (the preset-nested row is not addressable by id from any patch layer) plus the #2474 escape hatch (profile-layer full-snapshot override of preset-standard). Docs-only, no behavior change; docs-sync + docs-coverage gates re-run locally green. --- CONFIGURATION.md | 2 +- CONFIGURATION.zh-CN.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/CONFIGURATION.md b/CONFIGURATION.md index 4fc29404f5..b8ff2c63cc 100644 --- a/CONFIGURATION.md +++ b/CONFIGURATION.md @@ -1719,7 +1719,7 @@ File keys resolve only when the matching env var is unset. Defaults in parenthes | `BILI_AFFINITY_SIMHASH` | Set `0` to turn OFF simhash chain-alignment adoption (#2265): anonymous requests whose exact hash chain was broken by a client-side pervasive decorative rewrite (e.g. Trae re-stamping model tags on every assistant message) re-attach the existing session with its compression state instead of minting fresh and re-folding from zero. Guards: ≥90% coverage within Hamming 10, ≥20% mutated-but-similar positions (point edits still fork, #629), ≥1 byte-identical user message, unique candidate only. Default ON. `"affinitySimhash": false` in the config file does the same; the env var wins. | | `BILI_RESUME_INHERITANCE` | Set `0` to turn OFF resume inheritance (ON by default) (#1486): when an identified client (sends its own session id, e.g. Claude Code's `x-claude-code-session-id`) resumes a conversation under a NEW session id while replaying the full transcript (`cc --resume` forks a fresh UUID), bili matches the incoming history byte-exactly against that client's tracked chains (≥8 messages, append-only tracking) and, on the resumed session's first request, inherits the parent's ref assignments — stale model citations then resolve to their ORIGINAL messages instead of mis-hitting renumbered ones — adopts the fully-present compression blocks (together with this inheritance, #1834: losing them on resume meant the folded originals came back on the wire and the upstream request ballooned; the old `forkAdoption` co-gate now applies only to anonymous forks, #629), and records the `derivedFrom` lineage. The parent is never modified and fresh messages number above the parent's ref space. A resume must strictly EXTEND the parent's history — an equal-depth byte-exact replay under another id is a duplicate, not a resume. Anonymous sessions are unaffected (they keep their own pfa-* world, #309). `"resumeInheritance": false` in the config file does the same; the env var wins. | | `BILI_STABLE_SYSTEM_ANCHOR` | Set `1` to enable stable-system anchoring (#1085) — a **best-effort wire-layer fallback** for prefix caching: the root fix belongs client-side (the client owns its history and decides how to present instruction changes), this only stops the proxy from letting a changed head invalidate the whole cached prefix. **Plain-proxy mode only**: plugin-mode agents (`x-bili-plugin`) own their context management and are never anchored, so clients that already inject cache-friendly updates (e.g. claude-code-style system reminders) are not double-processed. When enabled, bili remembers each session's first-seen head system/instructions block and keeps re-sending those exact bytes even when the client's system prompt later changes. A **localized** change (a file-style edit sharing ≥70% of lines with the version in effect so far) appends a trailing `[System context update] …` user note carrying a compact line diff (`-` removed / `+` added; each note composes sequentially onto the previous one). A **non-localized** change (structural reshuffle, tool-def churn, timestamped banners, heads over 400 lines) is adopted outright — one deliberate cache miss beats appending noise that would mislead the model about its instructions. Churn guard: more than 8 accumulated notes likewise replace the anchor with the newest text and clear the log. The anchor and note log persist with the session and survive compression/compaction (session metadata, not kernel state). Known residual limitation: client-placed `cache_control` breakpoints may still misalign after a head swap. Excluded from anchoring: title-gen micro-requests (OpenAI/Google), Responses compaction-trigger requests, auto-mode classifier requests. Clients implementing their own variant (stable prompt + in-history updates) get zero extra injection — such updates pass through as ordinary history. Default is OFF. `"stableSystemAnchor": true` in the config file does the same; the env var wins. | -| `BILI_ALLOW_DSH_COMPACTION` | Set `1` to let dsh's built-in auto-compaction run through bili (#2028). By default the wire-level guard (#1729) **refuses dsh native compaction calls locally** (403) on every lane bili serves — openai, anthropic, and responses (responses added by #2360; it was the lane the pre-#2360 whitelist short-circuited before the marker was ever examined, so dsh desktop's compaction calls passed silently): dsh's `compaction-basic` answers context pressure by replaying the conversation prefix plus a fixed summarization directive as the final user message, and when such a call LANDS its checkpoint durably shadows the raw history — irreversible, and it destroys the proxy's compression substrate. This switch lifts the refusal so dsh-native compaction can actually execute. Scope note: on non-web profiles the shipped bundle patch (`auto: false`) still suppresses AUTO-triggering, so only manual `/compact` benefits there; on web profiles (where no patch layer reaches the preset-nested instance, #1772) auto-triggering works as-is once allowed. The web config page exposes the same switch; the env var wins over the file. Set `"dsh": { "allowDshCompaction": true }` in the config file to the same effect (a bare top-level `"allowDshCompaction"` in an older file is auto-relocated there on load). | +| `BILI_ALLOW_DSH_COMPACTION` | Set `1` to let dsh's built-in auto-compaction run through bili (#2028). By default the wire-level guard (#1729) **refuses dsh native compaction calls locally** (403) on every lane bili serves — openai, anthropic, and responses (responses added by #2360; it was the lane the pre-#2360 whitelist short-circuited before the marker was ever examined, so dsh desktop's compaction calls passed silently): dsh's `compaction-basic` answers context pressure by replaying the conversation prefix plus a fixed summarization directive as the final user message, and when such a call LANDS its checkpoint durably shadows the raw history — irreversible, and it destroys the proxy's compression substrate. This switch lifts the refusal so dsh-native compaction can actually execute. Scope note: on non-web profiles the shipped bundle patch (`auto: false`) still suppresses AUTO-triggering, so only manual `/compact` benefits there; on web profiles no patch layer can address the preset-nested row by id (#1772), so auto-triggering works as-is once allowed unless you apply the #2474 full-snapshot override of preset-standard from your profile's cordis.patch.yml. The web config page exposes the same switch; the env var wins over the file. Set `"dsh": { "allowDshCompaction": true }` in the config file to the same effect (a bare top-level `"allowDshCompaction"` in an older file is auto-relocated there on load). | | `BILI_NO_CACHE_CONTROL` | Set `1` to disable bili's Anthropic-lane `cache_control` breakpoint stamping (#1637, shipped in #1639). On by default: Anthropic-style upstreams cache only what is explicitly breakpointed (max 4 per request, counted across system + tools + message blocks combined), so bili marks the system block plus up to 3 cumulative message marks — a marked message stays marked (byte-stable prefix), marks die only by folding, and the last 3 stable messages carry the advancing frontier. Any client-set `cache_control` (message blocks, tools entries) suppresses bili's stamps entirely — client-managed caching wins. Marks persist with the session. This switch is the escape hatch for upstreams that reject the field or relays with their own breakpoint policy. Plain-proxy Anthropic lane only; OpenAI/Responses lanes cache implicitly and are never stamped. Config-file twin: [`compat.noCacheControl`](#compat) — the env var wins. | | `BILI_CHAIN_CONTENT` | Set `1` to turn ON the ACP-artifact / `` checkpoint **body-content** detection of bili→bili chain awareness (#1086/#1421): when an inbound request carries compression artifacts (render tags / historical `acp_status`+`search_context` tool calls) or a digest-bearing checkpoint in its BODY but neither the `x-bili-hop` header nor local compression state for its session, bili records an advisory observation and/or applies first-processor-wins passthrough. **Default is OFF** (#1683 follow-up): by default ONLY the `x-bili-hop` header drives chain recognition, because scanning the request BODY can false-positive on CCR/file-introduced text and model-echoed tags that look like real markers. Enable it only for the narrow multi-bili relay case where an intermediate box strips `x-bili-hop` and you accept that false-positive risk. `"chainContentDetection": true` in the config file does the same; the env var wins. The `x-bili-hop` signal itself is unaffected by this switch. | | `BILI_CHAIN_STAMP` | Set `1` to turn ON egress emission of the **model-visible** `` chain-integrity checkpoint carrier (#1683, default OFF): when enabled, every request THIS instance actually processes leaves with a digest-bearing stamp so a downstream bili applies first-processor-wins even when the `x-bili-hop` header was stripped in transit (#1421). The carrier lands in a slot the terminal model also reads (a trailing `user` message on OpenAI/Responses, a trailing text part on Anthropic/Google), so models treat it as phantom user input and burn tokens commenting on it — which is why it is off by default. Enable it only for the narrow multi-bili relay case where `x-bili-hop` is stripped by an intermediate box and the digest-verified body-stamp is the sole guard against double-processing. Independent of `BILI_CHAIN_CONTENT` (inbound body-detection is also default OFF) and of the `x-bili-hop` passthrough, which works either way. `"chainEgressStamp": true` in the config file does the same; the env var wins. | diff --git a/CONFIGURATION.zh-CN.md b/CONFIGURATION.zh-CN.md index 9b5d47eda7..5fff67eda7 100644 --- a/CONFIGURATION.zh-CN.md +++ b/CONFIGURATION.zh-CN.md @@ -1715,7 +1715,7 @@ ACP 原生 agent(当前为 `pi` 扩展)会在每个进程内向代理上报 | `BILI_AFFINITY_SIMHASH` | 设为 `0` 关闭 simhash 链对齐收养(#2265):匿名请求的精确哈希链被客户端侧大面积装饰性改写(如 Trae 切模型后给每条 assistant 消息重打模型标签)打断时,重新挂回既有会话并保留压缩状态,而不是每次新铸会话、从零重折。护栏:覆盖率 ≥90%(Hamming ≤10)、变异位置 ≥20%(单点编辑仍走 fork,#629)、至少一条字节相同的用户消息、双候选歧义拒猜。默认开启。配置文件中设 `"affinitySimhash": false` 效果相同;环境变量优先。 | | `BILI_RESUME_INHERITANCE` | 设为 `0` 关闭 resume 继承(默认开启)(#1486):当带自有会话 id 的客户端(如 Claude Code 的 `x-claude-code-session-id`)以**新**会话 id 重放完整历史来续接会话时(`cc --resume` 会 fork 出新 UUID),bili 通过字节级前缀匹配(≥8 条消息、append-only 跟踪)识别出它与该客户端已跟踪历史的父子关系,并在续接会话的首个请求上继承父会话的 ref 分配 —— 模型引用的旧代际 refs 因此命中**原始**消息、而不是错配到重新编号的新消息 —— 同时继承源内容完整存在的压缩块(随本继承一并生效,#1834:resume 丢块会导致被折叠原文重新回到线上、上游请求膨胀;旧的 `forkAdoption` 联动门现仅作用于匿名 fork,#629),并记录 `derivedFrom` 血缘。父会话不受影响;新消息在父会话 ref 空间之上继续编号。resume 必须**严格扩展**父历史 —— 同深度的字节级重放(不同 id)视为重复会话而非 resume。匿名会话不受影响(保留自己的 pfa-* 世界,#309)。配置文件中设 `"resumeInheritance": false` 效果相同;环境变量优先。 | | `BILI_STABLE_SYSTEM_ANCHOR` | 设为 `1` 开启稳定 system 锚定(#1085)—— **wire 层兜底(best-effort)**:根治在客户端(会话历史与指令变更的呈现方式由客户端决定),本开关只是阻止代理因头部变化而使整个已缓存前缀失效。**仅限 plain-proxy 模式**:plugin-mode agent(`x-bili-plugin`)自管上下文、永不参与锚定,避免对已自带 cache-friendly 更新注入的客户端(如 claude-code 的 system-reminder)做双重处理。开启后,bili 按会话记住客户端首次发送的头部 system/instructions 块并持续原样重发。**局部变更**(文件式编辑,与当前生效版本共享 ≥70% 行)追加末尾 `[System context update] …` user 注记,内含紧凑行级 diff(`-` 删除 / `+` 新增;每条注记顺序叠加在前一条之上)。**非局部变更**(结构性重排、tool 定义增删、带时间戳的 banner、超 400 行的头部)直接采用新文本 —— 一次有意的缓存失效好过追加会误导模型的噪声 diff。防抖保护:累积超过 8 条注记同样直接替换锚点为最新文本并清空日志。锚点与注记日志随会话持久化,不受压缩/compaction 影响(session metadata 而非 kernel state)。已知残留限制:客户端自放的 `cache_control` 断点在换头后仍可能错位。不参与锚定的请求:标题生成微请求(OpenAI/Google)、Responses compaction-trigger 请求、auto-mode classifier 请求。客户端自身已实现同类机制(稳定 prompt + 历史内更新)时零额外注入 —— 这类更新作为普通历史透传。默认关闭。配置文件中设 `"stableSystemAnchor": true` 效果相同;环境变量优先。 | -| `BILI_ALLOW_DSH_COMPACTION` | 设为 `1` 放行 dsh 内置自动压缩(#2028)。默认由 wire 级守卫(#1729)**在本地拒绝 dsh 原生压缩调用**(403),覆盖 bili 服务的全部线路——openai、anthropic、responses(responses 由 #2360 补上:此前的协议白名单在检查标记之前就把 responses 短路了,而 dsh 桌面端的压缩恰好走这条线路,调用因此静默穿过):dsh 的 `compaction-basic` 应对上下文压力时会重放会话前缀、并把固定摘要指令作为最后一条 user 消息发出,此类调用一旦落地,其 checkpoint 会永久覆盖原始历史——不可逆,且摧毁代理的压缩基底。本开关解除该拒绝,让 dsh 原生压缩真正执行。作用范围:非 web profile 下随附 bundle patch(`auto: false`)仍抑制**自动**触发,因此那里只有手动 `/compact` 受益;web profile(patch 层够不到 preset 嵌套实例,#1772)下放行后自动触发照常工作。网页配置页提供同一开关;环境变量优先于文件。在配置文件的 `"dsh"` 段下设 `"allowDshCompaction": true` 效果相同(旧文件里裸写在顶层的 `"allowDshCompaction"` 会在加载时自动迁移到该位置)。 | +| `BILI_ALLOW_DSH_COMPACTION` | 设为 `1` 放行 dsh 内置自动压缩(#2028)。默认由 wire 级守卫(#1729)**在本地拒绝 dsh 原生压缩调用**(403),覆盖 bili 服务的全部线路——openai、anthropic、responses(responses 由 #2360 补上:此前的协议白名单在检查标记之前就把 responses 短路了,而 dsh 桌面端的压缩恰好走这条线路,调用因此静默穿过):dsh 的 `compaction-basic` 应对上下文压力时会重放会话前缀、并把固定摘要指令作为最后一条 user 消息发出,此类调用一旦落地,其 checkpoint 会永久覆盖原始历史——不可逆,且摧毁代理的压缩基底。本开关解除该拒绝,让 dsh 原生压缩真正执行。作用范围:非 web profile 下随附 bundle patch(`auto: false`)仍抑制**自动**触发,因此那里只有手动 `/compact` 受益;web profile 下任何 patch 层都无法按 id 直寻 preset 嵌套行(#1772),因此放行后自动触发照常工作——除非在你的 profile `cordis.patch.yml` 里按 #2474 施加对 preset-standard 的完整快照覆盖。网页配置页提供同一开关;环境变量优先于文件。在配置文件的 `"dsh"` 段下设 `"allowDshCompaction": true` 效果相同(旧文件里裸写在顶层的 `"allowDshCompaction"` 会在加载时自动迁移到该位置)。 | | `BILI_NO_CACHE_CONTROL` | 设为 `1` 关闭 bili 在 Anthropic 通道上的 `cache_control` 断点标注(#1637,随 #1639 落地)。默认开启:Anthropic 系上游只缓存被显式打断点的内容(每请求最多 4 个,按 system + tools + 消息块合并计数),因此 bili 会标注 system 块加上至多 3 个累积消息断点——被标注的消息保持标注(前缀字节稳定),断点只随折叠消亡,最近 3 条稳定消息承载推进前沿。客户端自设的任何 `cache_control`(消息块、tools 条目)都会完全抑制 bili 的标注——客户端自管缓存优先。断点随会话持久化。本开关是逃生阀:用于拒绝该字段的上游或有自己断点策略的中继。仅限 plain-proxy Anthropic 通道;OpenAI/Responses 通道隐式缓存,从不标注。配置文件对应项:[`compat.noCacheControl`](#compat) —— 环境变量优先。 | | `BILI_CHAIN_CONTENT` | 设为 `1` 开启 bili→bili 链感知的 ACP 产物 / `` 检查点**正文内容**检测(#1086/#1421):当入站请求的正文携带压缩产物(渲染标签 / 历史 `acp_status`+`search_context` 工具调用)或带摘要的检查点,但既无 `x-bili-hop` 头、本实例也无该会话的压缩状态时,bili 记录一次告警性观察和/或应用「首个处理器优先」透传。**默认关闭**(#1683 后续):默认下只有 `x-bili-hop` 头驱动链识别,因为扫描请求正文可能把 CCR/文件引入的文本和模型回声标签误判为真实标记。仅在中间盒子剥掉 `x-bili-hop`、且你接受该误判风险的狭窄多 bili 中继场景下才启用。配置文件中设 `"chainContentDetection": true` 效果相同;环境变量优先。`x-bili-hop` 信号本身不受此开关影响。 | | `BILI_CHAIN_STAMP` | 设为 `1` 开启**模型可见**的 `` 链完整性检查点载体的出站注入(#1683,默认关闭):开启后,本实例实际处理的每个请求都携带一个带摘要的戳,使下游 bili 即使 `x-bili-hop` 头在传输中被剥离也能应用「首个处理器优先」(first-processor-wins)(#1421)。该载体落在终端模型同样会读取的位置(OpenAI/Responses 上是一条尾部 `user` 消息,Anthropic/Google 上是尾部文本 part),因此模型会把它当作幽灵用户输入并花 token 去评论它——这正是它默认关闭的原因。仅在多 bili 中继、且中间盒子剥掉 `x-bili-hop`、带摘要校验的 body-stamp 是防止双重处理的唯一手段这一狭窄场景下才启用。与 `BILI_CHAIN_CONTENT`(入站正文检测同样默认关闭)及 `x-bili-hop` 透传相互独立(后者无论如何都生效)。配置文件中设 `"chainEgressStamp": true` 效果相同;环境变量优先。 |