Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions docs/configuration.ja.md
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@
| `subagentSplit` | boolean | true | BILI_SUBAGENT_SPLIT | Claude Code サブエージェントは、メインセッションのキューに並ぶ代わりに、独自のセッション名前空間(<session>\|sub:<agent-id>)を取得します。Anthropic-wire 専用 — Responses wire ではこのスイッチは no-op です(`subagentSplit` / BOTH-mechanisms スコープ注記を参照)。 |
| `personaSplit` | boolean | true | BILI_PERSONA_SPLIT | 指示テキストが変更され、かつ受信履歴が追跡中のチェーンを継続していない場合、指示フィンガープリントでキー付けされた Responses-wire レーンを分割します(Claude Code の /v1/responses 経由; Codex ルートスレッド / 旧ビルド)。デフォルトで有効。環境変数 BILI_PERSONA_SPLIT=0 または personaSplit: false で無効化可能(環境変数が優先)。 |
| `forkAdoption` | boolean | false | BILI_FORK_ADOPTION | 匿名フォークは、フォークされたリクエストにソースコンテンツが完全に存在する親の圧縮ブロックを継承します。 |
| `degenerateRetry` | boolean | false | BILI_DEGENERATE_RETRY | エージェント向けプラグイン/プロキシレーンでの opt-in 退化ターン継続リトライ(#732/#821/#2303):ターンがゼロの可視出力で終わった場合、中立的な継続ナッジを付加してエージェント自身のリクエストを一度だけ再発行します。リトライ後も空だった場合はインバンドで #870 エラーで終了します。圧縮ループ内部のリトライは影響を受けません。degenerateRetry: true または環境変数 BILI_DEGENERATE_RETRY=1 で有効にします。 |
| `autoModeForge.enabled` | boolean | true | BILI_AUTO_MODE_FORGE | Claude Code の自動モードのセーフティ分類器呼び出しを、上流へ転送する代わりに、偽造された許可判定でローカルに回答します(#2740):そのレーンでは送信ゼロ、課金ゼロ。すべての偽造判定は監査ログに記録され、セッションには通知バッジが付与されます。false / 環境変数 0 で、実際の判定料金を支払うユーザー向けに純粋なパススルーに戻ります。 |
| `affinitySimhash` | boolean | true | BILI_AFFINITY_SIMHASH | 匿名クライアント向けの Simhash チェーン整合性採用(#2265):クライアント側の普遍的な装飾的書き換え(例:Trae がすべてのアシスタントメッセージにモデルタグを再スタンプする)が発生した場合、ゼロから新規発行して再折りたたむ代わりに、既存のセッションとその圧縮状態を再アタッチします。 |
| `resumeInheritance` | boolean | true | BILI_RESUME_INHERITANCE | 新しいセッション ID で再開する識別済みクライアントは、親の ref 割り当てと完全に存在する圧縮ブロックを継承します。 |
Expand Down Expand Up @@ -1956,6 +1957,7 @@ ACP ネイティブエージェント(現在は `pi` 拡張機能)は、プ
| `BILI_CODEX_COMPACT` | `codexCompact` | "intercept" |
| `BILI_DECODED_BODY_BYTES` | `network.decodedBodyBytes` | 10737418240 |
| `BILI_DECOMPRESS_TMP_CAP` | `decompressTmpCap` | 50 |
| `BILI_DEGENERATE_RETRY` | `degenerateRetry` | false |
| `BILI_DSH_AUTHORED_COMPACTION` | `dsh.authoredCompaction` | true (on, #3901 flip) |
| `BILI_DSH_CONTEXT_TAB` | `dsh.contextTab` | true |
| `BILI_DUMP_4XX` | `diagnostics.dump4xx` | false |
Expand Down
2 changes: 2 additions & 0 deletions docs/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ This index is generated from `website/config-reference/*.yaml` — edit the seed
| `subagentSplit` | boolean | true | BILI_SUBAGENT_SPLIT | Claude Code subagents get their own session namespace (<session>\|sub:<agent-id>) instead of queueing behind the main session. Anthropic-wire only — on the Responses wire this switch is a no-op (see the `subagentSplit` / BOTH-mechanisms scope note). |
| `personaSplit` | boolean | true | BILI_PERSONA_SPLIT | Split the Responses-wire lane keyed by the instructions fingerprint (Claude Code over /v1/responses; Codex root threads / older builds) when the instructions text changes AND the incoming history does not continue the tracked chain (default on). Opt out with env BILI_PERSONA_SPLIT=0 or personaSplit: false (env wins). |
| `forkAdoption` | boolean | false | BILI_FORK_ADOPTION | Anonymous forks inherit the parent's compression blocks whose source content is fully present in the forked request. |
| `degenerateRetry` | boolean | false | BILI_DEGENERATE_RETRY | Opt-in degenerate-turn continuation retry on the agent-facing plugin/proxy lanes (#732/#821/#2303): when a turn ends with zero visible output, re-issue the agent's own request once with a neutral continuation nudge appended; a second empty retry surfaces an in-band #870 error. The compress loop's internal retry is unaffected. Enable with degenerateRetry: true or env BILI_DEGENERATE_RETRY=1. |
| `autoModeForge.enabled` | boolean | true | BILI_AUTO_MODE_FORGE | Answer Claude Code auto-mode safety-classifier calls locally with a forged allow verdict instead of forwarding them upstream (#2740): zero egress, zero billing for that lane; every forged verdict is audit-logged and the session carries a notice badge. false / env 0 restores pure passthrough for users who pay for real verdicts. |
| `affinitySimhash` | boolean | true | BILI_AFFINITY_SIMHASH | Simhash chain-alignment adoption for anonymous clients (#2265): a client-side pervasive decorative rewrite (e.g. Trae re-stamping model tags on every assistant message) re-attaches the existing session with its compression state instead of minting fresh and re-folding from zero. |
| `resumeInheritance` | boolean | true | BILI_RESUME_INHERITANCE | Identified clients resuming under a new session id inherit the parent's ref assignments and fully-present compression blocks. |
Expand Down Expand Up @@ -1969,6 +1970,7 @@ File keys resolve only when the matching env var is unset. Defaults in parenthes
| `BILI_CODEX_COMPACT` | `codexCompact` | "intercept" |
| `BILI_DECODED_BODY_BYTES` | `network.decodedBodyBytes` | 10737418240 |
| `BILI_DECOMPRESS_TMP_CAP` | `decompressTmpCap` | 50 |
| `BILI_DEGENERATE_RETRY` | `degenerateRetry` | false |
| `BILI_DSH_AUTHORED_COMPACTION` | `dsh.authoredCompaction` | true (on, #3901 flip) |
| `BILI_DSH_CONTEXT_TAB` | `dsh.contextTab` | true |
| `BILI_DUMP_4XX` | `diagnostics.dump4xx` | false |
Expand Down
2 changes: 2 additions & 0 deletions docs/configuration.zh-CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@
| `subagentSplit` | boolean | true | BILI_SUBAGENT_SPLIT | Claude 子代理拥有独立会话命名空间(<session>\|sub:<agent-id>),不再排队在主会话锁后。仅 anthropic 线路 —— Responses 线路上本开关无效(见 `subagentSplit` / BOTH-mechanisms 作用域说明)。 |
| `personaSplit` | boolean | true | BILI_PERSONA_SPLIT | 当 instructions 文本变化且入站历史不连续时,把按 instructions 指纹分键的 Responses 车道(Claude Code over /v1/responses;Codex 根线程 / 旧版本构建)分叉出去(默认开)。用环境变量 BILI_PERSONA_SPLIT=0 或配置 personaSplit: false 关闭(环境变量优先)。 |
| `forkAdoption` | boolean | false | BILI_FORK_ADOPTION | 匿名 fork 会话继承父会话中源内容完整存在于本次请求里的压缩块。 |
| `degenerateRetry` | boolean | false | BILI_DEGENERATE_RETRY | 代理对外车道上的退化轮续传重试(#732/#821/#2303,默认关):一轮以零可见输出结束时,把客户端自己的请求附加中性续传提示后重发一次;重试仍为空则以带内 #870 错误收尾。压缩循环内部的重试不受此开关影响。用 degenerateRetry: true 或环境变量 BILI_DEGENERATE_RETRY=1 开启。 |
| `autoModeForge.enabled` | boolean | true | BILI_AUTO_MODE_FORGE | Claude Code auto mode 安全分类器请求由 bili 在本地代答放行判定,不再转发上游(#2740):该旁路零流出、零计费;每条代答写审计日志,会话带提示徽标。false / env 0 恢复纯透传(愿意付费要真判定的用户)。 |
| `affinitySimhash` | boolean | true | BILI_AFFINITY_SIMHASH | 匿名客户端的 simhash 链对齐收养(#2265):客户端侧大面积装饰性改写(如 Trae 切模型后给每条 assistant 消息重打模型标签)时,重新挂回既有会话并保留压缩状态,而不是每次新铸会话、从零重折。 |
| `resumeInheritance` | boolean | true | BILI_RESUME_INHERITANCE | 以新会话 id 恢复的已识别客户端继承父会话的引用编号与完整存在的压缩块。 |
Expand Down Expand Up @@ -1946,6 +1947,7 @@ ACP 原生 agent(当前为 `pi` 扩展)会在每个进程内向代理上报
| `BILI_CODEX_COMPACT` | `codexCompact` | "intercept" |
| `BILI_DECODED_BODY_BYTES` | `network.decodedBodyBytes` | 10737418240 |
| `BILI_DECOMPRESS_TMP_CAP` | `decompressTmpCap` | 50 |
| `BILI_DEGENERATE_RETRY` | `degenerateRetry` | false |
| `BILI_DSH_AUTHORED_COMPACTION` | `dsh.authoredCompaction` | true (on, #3901 flip) |
| `BILI_DSH_CONTEXT_TAB` | `dsh.contextTab` | true |
| `BILI_DUMP_4XX` | `diagnostics.dump4xx` | false |
Expand Down
1 change: 1 addition & 0 deletions docs/lifecycle.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
| `BILI_CHAIN_STAMP` | egress stamp | stripped-middlebox 场景的出口戳(默认 off) | 同上 | 默认 off |
| `BILI_STABLE_SYSTEM_ANCHOR` | stable-system-anchor 实验 | 每会话 system 锚点实验(默认 OFF) | 稳定性评估后转正或删 | opt-in(默认 OFF) |
| `BILI_FORK_ADOPTION` | fork-adoption 特性 | fork 继承实验(opt-in;禁用时提示从零开始,fork-adoption.ts:300) | 稳定后转正或退役 | opt-in(默认 off) |
| `BILI_DEGENERATE_RETRY` | #5897 | 空轮续跑 opt-in:开启后轮次零可见输出时自动带中性续跑提示重发一次(loop 车道与 plugin 管道都受管;默认关 = 空轮原样透传,不重发不注入) | 空轮续跑行为定型后转正或退役 | opt-in(默认 off) |
| `BILI_ALLOW_DSH_COMPACTION` | dsh compaction | dsh compaction opt-in(env 语义同 BILI_PERSIST 家族) | 转正后移 §2 | opt-in(`=1`) |
| `BILI_SNAPSHOT_SHADOW` | #3756 | snapshot-render 影子观测:每个 armed turn 计算快照视图但**不使用**(出站仍走 legacy 路径),与实际发送对比记 per-session 计数(面板 + `snapshot-shadow` 诊断话题)——render 引擎在 rollout 翻转前用真实流量证明健康(dry-run-then-flip,同存储 #2815 shadow→#3818 full 纪律) | render 车道转正(rollout 100% 且影子计数归稳)后退役 | 默认 on(render lane 本身 rollout 0%,纯观测) |
| `BILI_DSH_AUTHORED_COMPACTION` | #3733 | dsh 原生 compaction summarize 调用由 #1729 guard 拒绝改为**本地应答折叠快照**(零出账;dsh 记 checkpoint、会话文件收缩) | adoption 后按 #2028 模式转 file/web 开关,env 退役(file 键 `dsh.authoredCompaction` 已镜像) | 0.1.203 dogfood 站稳后默认 on;`=0` 回 #1729 拒绝路径 |
Expand Down
19 changes: 18 additions & 1 deletion src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1078,6 +1078,18 @@ export type ProxyOptions = {
* BILI_PERSONA_SPLIT=0 or `personaSplit: false` in the config file
* (env wins). */
personaSplit?: boolean;
/** Opt-in degenerate-turn continuation retry on the agent-facing plugin and
* proxy chat lanes (#732/#821/#2303; default OFF): when a turn ends with
* zero visible output (reasoning-only silent stop, or output that is
* nothing but a render-tag echo), re-issue the agent's own request ONCE
* with a neutral continuation nudge appended; if the retry is also empty,
* the client gets an in-band #870 error instead of a silently empty turn.
* OFF by default: the nudge re-bills the full request, and on sessions
* already deep in degeneration the retry just degenerates again. The
* compress loop's internal retry is NOT governed by this switch (it
* heals the proxy's own fold requests and stays on).
* Enable with `degenerateRetry: true` or env BILI_DEGENERATE_RETRY=1. */
degenerateRetry?: boolean;
/** Opt-in fork block-adoption (#629, default off). ANONYMOUS clients
* (prefix-affinity) that fork their history inherit the parent's
* fully-present compression blocks instead of restarting at zero.
Expand Down Expand Up @@ -1827,6 +1839,7 @@ export function loadOptions(env: NodeJS.ProcessEnv = process.env): ProxyOptions
subagentSplit: (env.BILI_SUBAGENT_SPLIT ?? (fileConfig.subagentSplit === false ? "0" : "1")) !== "0",
personaSplit: (env.BILI_PERSONA_SPLIT ?? (fileConfig.personaSplit === false ? "0" : "1")) !== "0",
forkAdoption: (env.BILI_FORK_ADOPTION ?? (fileConfig.forkAdoption === true ? "1" : "0")) !== "0",
degenerateRetry: (env.BILI_DEGENERATE_RETRY ?? (fileConfig.degenerateRetry === true ? "1" : "0")) !== "0",
affinitySimhash: (env.BILI_AFFINITY_SIMHASH ?? (fileConfig.affinitySimhash === false ? "0" : "1")) !== "0",
resumeInheritance: (env.BILI_RESUME_INHERITANCE ?? (fileConfig.resumeInheritance === false ? "0" : "1")) !== "0",
chainContentDetection: (env.BILI_CHAIN_CONTENT ?? (fileConfig.chainContentDetection === true ? "1" : "0")) !== "0",
Expand Down Expand Up @@ -2098,6 +2111,10 @@ type FileConfig = {
* BILI_CHAIN_STAMP=1 wins over the file). Independent of
* chainContentDetection. */
chainEgressStamp?: boolean;
/** #732/#821/#2303 opt-in: re-issue a zero-output terminal turn once with
* a continuation nudge on the plugin/proxy lanes. Default false; env
* BILI_DEGENERATE_RETRY=1 or config `degenerateRetry: true` enables. */
degenerateRetry?: boolean;
/** Set `true` to enable the sticky head-system anchor (#1085, default
* OFF; env BILI_STABLE_SYSTEM_ANCHOR wins). */
stableSystemAnchor?: boolean;
Expand Down Expand Up @@ -2528,7 +2545,7 @@ const KNOWN_TOP_LEVEL_KEYS = new Set([
"upstreamProxy", "upstreamProxyMode",
"logFile", "compress", "promptCache", "mitm", "maskHosts",
"subagentSplit", "personaSplit", "forkAdoption", "affinitySimhash", "resumeInheritance",
"chainContentDetection", "chainEgressStamp", "stableSystemAnchor",
"chainContentDetection", "chainEgressStamp", "stableSystemAnchor", "degenerateRetry",
"rollout",
"dsh",
"compat", "imageBilling", "imageTokenCap", "claude", "native", "resign",
Expand Down
9 changes: 7 additions & 2 deletions src/degenerate-retry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,14 @@ function releaseThrottleErrorReader(reader: ReadableStreamDefaultReader<Uint8Arr
// Wording covers BOTH retry shapes: the empty-turn shape (#732/#821) and the
// draft-tail shape (#2303, visible prose ending in a compression-draft closing
// tag) — both are "ended without a tool call", and both need the same push:
// issue the pending action or state the final answer explicitly.
// produce the turn's actual output, whichever form it takes. The wording is
// deliberately neutral: it must NOT steer the model toward calling a tool it
// never planned (the old "issue the tool call you were about to make" presumed
// an agentic lane) nor toward wrapping up early ("state your final answer"
// read as an instruction to conclude the task) — the earlier phrasing did
// both, and on long degenerate sessions it pushed the model the wrong way.
export const DEGENERATE_RETRY_NUDGE =
"[billion-context] Your previous response ended without a tool call. Continue now: take your next concrete action — issue the tool call you were about to make, or state your final answer explicitly.";
"[billion-context] Your previous response produced no visible output. Continue now: send your actual response for this turn — the tool call you intended, or your reply text to the user.";

/** The retry body: the forwarded body with the continuation nudge appended as a
* trailing user turn. Null when the body cannot carry one. */
Expand Down
3 changes: 2 additions & 1 deletion src/degenerate-turn.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,8 @@ export function degenerateTurnWarning(o: TurnOutcome): string | null {
}
return (
`[degenerate-turn] ${o.wire}: turn ended ${o.terminalReason} with zero visible text and zero tool calls (${bits.join("; ")}) ` +
`— the agent receives an empty turn and may stall until nudged (#673)`
`— the agent receives an empty turn and may stall until nudged (#673). ` +
`Pass-through is the default; enable degenerateRetry: true / BILI_DEGENERATE_RETRY=1 to auto-retry once with a continuation nudge`
);
}

Expand Down
Loading
Loading