Skip to content
Merged
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
1 change: 1 addition & 0 deletions docs/configuration.ja.md
Original file line number Diff line number Diff line change
Expand Up @@ -289,6 +289,7 @@
| `compress.nudgeDecisionMaxTokens` | number | 200 | — | nudgeModelDecided が使用するモデル決定サイドコールの出力予算(トークン数)。0 より大きい必要がある。 |
| `compress.requireNudge` | boolean | off (unset) | — | 無促のモデル主導圧縮の禁止 (#5683/#5943):NUDGE CREDIT がライブでない限り、compress 呼び出しは拒否される — 最後にモデルに実際に到達した圧縮ナッジ(助言、決定ディレクティブ、緊急注入はすべて発行;"gated"/"vetoed"/"skipped" は発行しない)によって発行された 20 モデルラウンドのウィンドウ。各新しい注入で更新され、ナッジされないモデルラウンドごとに 1 ずつ減衰する(非モデルリクエスト形状はそれをオープンに保つ)。成功した折りたたみはクレジットを消費しないため、ナッジの推奨クリーンアップを複数ラウンドにわたって完了することは依然として合法である。拒否は、折りたたむ代わりにモデルにエラーレシートを送る。bili 自身のオーバーフローバックストップ折りたたみは免除される。自分で折りたたむモデル(例: qwen 27b)向け;プロバイダー/モデルごとにスコープを限定できる。明示的に有効化されない限りオフ。 |
| `compress.requireRecommendation` | boolean | off (unset) | — | 範囲外のモデル主導圧縮の禁止 (#5683):提出されたすべての範囲は、bili が現在折りたたみを推奨している範囲内に留まらなければならない — ナッジテキストと acp_status が示すのと同じライブ折りたたみ可能セット(存在する場合、このリクエストの準備時オファー、それ以外の場合はライブ再計算)。判定はカバレッジによる:推奨スパンの細分化は合格し、アクティブなブロックにすでに折りたたまれたメッセージ(既存のサマリーを更新する再折りたたみ)は免除される。他のライブメッセージを含む範囲は、問題のあるスパンを特定するエラーレシートとともに全体として拒否される。明示的に有効化されない限りオフ。 |
| `compress.postComPressTail` | boolean | off (unset) | — | 圧縮成功レシート内での「続けて折りたたむ」推奨 (#7318):残り折りたたみ可能範囲リストと『Uncovered history remains』監査ノートを印刷するのは有効化時のみ;デフォルト OFF では両方とも出ない(コンテキスト最小停止シグナルには影響なし)。有効化時は、未カバー履歴ノットはナッジ注入サイクルごとに最大 1 回のみ発火し、新しい注入が再オープンする (#6522/#6526)。レシート毎の再推奨が明示的な停止要求を無視した無限折りたたみループを誘発したためデフォルト OFF。 |
| `compress.streamSummary` | boolean | false (unset) | — | 事前チェックの要約を、最初の試行からストリーミング(SSE)コールとして実行することを強制する。エラー駆動の自己学習は、ストリーミングを強制するアップストリームを独自に処理する(非ストリーミング要約での 400 はワンショット SSE プローブをトリガーする、#2494)が、ゲートウェイタイムアウト(例: Cloudflare HTTP 524)では決してアームしない:bili とオリジンの間にそのようなゲートウェイがある場合にこれを設定するか、単に 1 回のプローブ往復をスキップするために設定する。 |
| `compress.preserveRecentMessages` | number | 3 | — | 最新のメッセージは、折りたたみからソフト保護される。 |
| `compress.preserveRecentTokens` | number | kernel ≈5000 | — | 最新のトークンはフォールドからソフト保護される。 |
Expand Down
1 change: 1 addition & 0 deletions docs/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -292,6 +292,7 @@ This index is generated from `website/config-reference/*.yaml` — edit the seed
| `compress.nudgeDecisionMaxTokens` | number | 200 | — | Output budget (tokens) of the model-decision side call used by nudgeModelDecided. Must be > 0. |
| `compress.requireNudge` | boolean | off (unset) | — | Forbid UNPROMPTED model-initiated compression (#5683/#5943): a compress call is refused unless a NUDGE CREDIT is live — a window of 20 MODEL rounds minted by the last compression nudge that actually reached the model (advisory, decide-directive and emergency injections all mint; "gated"/"vetoed"/"skipped" never do), refreshed by each new injection and decayed one per un-nudged model round (non-model request shapes hold it open). Successful folds do NOT consume the credit, so finishing a nudge's recommended cleanup over several rounds stays legal. Refusal sends the model an error receipt instead of folding; bili's own overflow backstop folds are exempt. For models that fold on their own (e.g. qwen 27b); can be scoped per provider/model. Off unless explicitly enabled. |
| `compress.requireRecommendation` | boolean | off (unset) | — | Forbid OUT-OF-BOUNDS model-initiated compression (#5683): every submitted range must stay within what bili currently recommends folding — the same live compressible set the nudge text and acp_status show (this request's prepare-time offer when present, else a live recompute). Judgment is by COVERAGE: subdividing a recommended span passes, and messages already folded into active blocks (refolds updating an existing summary) are exempt. A range carrying any other live message is refused whole with an error receipt naming the offending span(s). Off unless explicitly enabled. |
| `compress.postComPressTail` | boolean | off (unset) | — | Recommend 'fold more' inside the SUCCESS compress receipt (#7318): the remaining-offer range list and the 'Uncovered history remains' audit note are printed only when enabled; off by default the receipt carries neither (the context-minimum stop signal is unaffected). When enabled, the uncovered-history note fires at most once per nudge-injection cycle and a fresh injection re-opens it (#6522/#6526). Off because per-receipt re-recommendation drove models into endless fold loops against explicit stop requests. |
| `compress.streamSummary` | boolean | false (unset) | — | Force preflight summarization to run as a streaming (SSE) call from the first attempt. The error-driven self-learn handles stream-mandating upstreams on its own (any 400 on a non-streaming summary triggers a one-shot SSE probe, #2494) but NEVER arms on gateway timeouts (e.g. Cloudflare HTTP 524): set this where such a gateway sits between bili and the origin, or simply to skip the one probe round-trip. |
| `compress.preserveRecentMessages` | number | 3 | — | The most recent messages stay soft-protected from folds. |
| `compress.preserveRecentTokens` | number | kernel ≈5000 | — | The most recent tokens stay soft-protected from folds. |
Expand Down
1 change: 1 addition & 0 deletions docs/configuration.zh-CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -292,6 +292,7 @@
| `compress.nudgeDecisionMaxTokens` | number | 200 | — | nudgeModelDecided 所用模型决策 side call 的输出预算(token)。必须 > 0。 |
| `compress.requireNudge` | boolean | off (unset) | — | 禁止未提示的模型主动压缩(#5683/#5943):只有 nudge 信用存活时才允许 compress——即距最近一次真正送达模型的压缩提醒不超过 20 个 MODEL 轮的窗口(advisory、模型自决指令、紧急提醒都算铸券;"gated"/"vetoed"/"skipped" 不算);每次新注入刷新窗口,每个未提示的模型轮衰减 1(非模型请求形态既不刷新也不衰减)。成功折叠**不消耗**信用,分几轮压完 nudge 推荐的剩余范围仍然合法。否则拒绝并回错误回执;bili 自己的溢出兜底折叠不受影响。针对会自行乱压的模型(如 qwen 27b),可按 provider/model 单独开启。默认关闭。 |
| `compress.requireRecommendation` | boolean | off (unset) | — | 禁止越界的模型主动压缩(#5683):提交的每个范围必须落在 bili 当前推荐折叠的集合内——即 nudge 文案与 acp_status 展示的同一份实时可压缩列表(有本轮 prepare 快照用快照,否则实时重算)。按「覆盖」判定而非精确相等:把推荐跨度拆小段通过;已折进活跃块的消息豁免(重折已有块更新摘要合法)。范围里含任何其他仍存活的消息则整体拒绝,回执点名越界跨度并指向 acp_status。默认关闭。 |
| `compress.postComPressTail` | boolean | off (unset) | — | 在压缩成功回执里推荐「继续压缩」(#7318):剩余可折叠范围列表与「Uncovered history remains」审计提示仅在开启时打印;默认关闭时两者都不出现(上下文已到底的停止信号不受影响)。开启后,未覆盖历史提示每个 nudge 注入周期最多发一次,新注入会重新打开(#6522/#6526)。之所以默认关闭:回执里反复推荐曾驱使模型无视用户停止指令无限折叠。 |
| `compress.streamSummary` | boolean | false (unset) | — | 强制 preflight 摘要从首次尝试起就走流式(SSE)请求。要求流式的上游现在由错误驱动自学习自动处理(非流式摘要的任何 400 都会触发一次性 SSE 探测,#2494),但网关超时(如 Cloudflare HTTP 524)永远无法触发自学习:在此类网关位于 bili 与源站之间时设置此项,或用于省去一次探测往返。 |
| `compress.preserveRecentMessages` | number | 3 | — | 最近的消息软保护、免于折叠。 |
| `compress.preserveRecentTokens` | number | kernel ≈5000 | — | 最近的 token 软保护、免于折叠。 |
Expand Down
1 change: 1 addition & 0 deletions src/compress-settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ export function mergeCompress(
nudgeDecisionMaxTokens: pick("nudgeDecisionMaxTokens"),
requireNudge: pick("requireNudge"),
requireRecommendation: pick("requireRecommendation"),
postComPressTail: pick("postComPressTail"),
preserveRecentMessages: pick("preserveRecentMessages"),
preserveRecentTokens: pick("preserveRecentTokens"),
minCompressRangeChars: rangeOf(model) ?? rangeOf(provider) ?? rangeOf(global),
Expand Down
23 changes: 21 additions & 2 deletions src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -339,6 +339,23 @@ export type CompressSettings = {
* offending span(s). Host-only; off unless explicitly enabled at some
* level. Deepest level wins PER FIELD across global → provider → model. */
requireRecommendation?: boolean;
/** #7318: the model-visible "fold more" recommendation in the SUCCESS
* compress receipt — the remaining-offer range list (with the one-call
* hint) after a partial fold, and the "Uncovered history remains" audit
* note, which fires at most once per nudge-injection cycle (#6522). When
* false or absent (DEFAULT) the success receipt carries no fold
* recommendation at all: only the verbatim "No compressible ranges
* remain" stop signal when the offer is genuinely exhausted (and honest
* silence while material uncovered mass remains, #4331). Off by default
* because per-receipt re-recommendation drove models into endless fold
* loops against explicit user stop requests (#7318: 200+ folds in one
* night; #6522/#5872 same family), each fold rewriting the context
* prefix and re-billing the prompt-cache tail. The per-turn growth nudge
* (KDD #8, `compress.injectNudge`) is a separate channel and is NOT
* affected by this knob. Host-only (never passed to the kernel); opt-in.
* Deepest level wins PER FIELD across global → provider → model, like
* every other compress field. */
postComPressTail?: boolean;
/** Trailing messages never offered for compression
* (kernel `preserveRecentMessages`). */
preserveRecentMessages?: number;
Expand Down Expand Up @@ -2564,7 +2581,7 @@ const KNOWN_TOP_LEVEL_KEYS = new Set([
const COMPRESS_SETTING_FIELDS = new Set([
"modelContextLimit", "maxContextLimit", "emergencyThresholdPercent",
"nudgeGrowthTokens", "minPressureBenefitTokens", "requireUsageSampleForPressure", "maxEstimateHoldRounds", "tierNudgeTokens", "nudgeModelDecided", "nudgeDecisionMaxTokens",
"requireNudge", "requireRecommendation",
"requireNudge", "requireRecommendation", "postComPressTail",
"preserveRecentMessages", "preserveRecentTokens",
"minCompressRange", "minCompressRangeChars",
"outputHeadroomMaxPct", "tiers", "protectedLatestTools", "protectedTools",
Expand Down Expand Up @@ -3343,7 +3360,9 @@ export function parseCompressSettings(v: unknown): (CompressSettings & { injectT
}
// #5683: unprompted/out-of-bounds compression policy gates — plain booleans,
// off unless explicitly set (an explicit false at a deeper level disables).
for (const key of ["requireNudge", "requireRecommendation"] as const) {
// #7318: postComPressTail is the same species — plain boolean, off unless
// explicitly enabled (default-off recommendation surface).
for (const key of ["requireNudge", "requireRecommendation", "postComPressTail"] as const) {
if (!(key in obj)) continue;
if (typeof obj[key] !== "boolean") ok = false;
else out[key] = obj[key];
Expand Down
15 changes: 15 additions & 0 deletions src/server/handle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3394,8 +3394,23 @@ async function handleRequest(
nudgeInjected: prepared.nudgeOutcome === "injected",
requireNudge: preparedCs?.requireNudge === true,
requireRecommendation: preparedCs?.requireRecommendation === true,
postComPressTail: preparedCs?.postComPressTail === true,
modelRound: !countTokens && !responsesCompact && !prepared.codexForge && !prepared.threadsLane,
});
// #6522: an ACTUAL injection re-opens the uncovered-history note
// latch (postCompressTail, src/stream.ts). A fresh nudge is a new
// "context is big enough — compress while you are at it" moment,
// so the receipt may note the uncovered runs once more in this
// cycle; folds without a new injection stay silent (anti-nag,
// #6522 loop). Only the post-gate delivery fact "injected"
// resets — the same fact that mints the nudge credit above;
// "gated"/"vetoed"/"skipped" never reached the model and never
// re-open the note. The note itself only exists while
// compress.postComPressTail is on (#7318) — with it off this
// latch is inert.
if (prepared.nudgeOutcome === "injected") {
session.uncoveredReceiptNoted = false;
}
// A locally-served codex compaction forge never reaches an
// upstream: preflight would burn summarization rounds for a
// reply that is already forged (#3008 prompt form).
Expand Down
12 changes: 12 additions & 0 deletions src/session.ts
Original file line number Diff line number Diff line change
Expand Up @@ -717,6 +717,18 @@ export type Session = {
* model keeps re-fetching. Bounded by trimRetrieveCounts; lost on restart
* (advisory signal only). */
retrieveCountsByRef?: Map<string, number>;
/** #6522 in-memory only (NOT persisted): the "Uncovered history remains"
* receipt note has already fired in the current nudge-injection cycle.
* The note fires once per cycle — repeating it after every successful
* fold drove models into an infinite compress→note loop (#6522). Each
* ACTUAL nudge injection (nudgeOutcome === "injected", stamped in
* src/server/handle.ts) re-opens the latch: a fresh nudge is a new
* "big enough, compress while you are at it" moment. The same detail
* stays available on demand via acp_status(scope:"uncompressed").
* Lost on restart (at most one extra note). #7318: only read while
* compress.postComPressTail is on; with the recommendation off the note
* never fires and the latch is inert. */
uncoveredReceiptNoted?: boolean;
/** In-memory only (NOT persisted): request-only injections riding the
* nudge channel. Since the GHSA jc6g v2 rework, acp_retrieve delivers its
* full text in the tool result itself — this carrier now only serves
Expand Down
Loading
Loading