mirror of
https://github.com/ranxianglei/billion-context.git
synced 2026-11-23 01:58:16 +08:00
merge: sync master into #2977 branch; resolve conflict + kernel version collision
Catch-up merge of origin/master (c800ed1) into the #2977 branch to clear the
merge_conflict. Conflicts were only in src/server/handle.ts and
tests/conflict-remediation.test.ts — neither is touched by this PR (#2970),
so both take master's side.
Kernel version collision: master independently consumed acp-kernel 0.0.122
(#3058 preserveRecentMessages 5->3); this branch had also bumped 0.0.121 ->
0.0.122 for #2970. Per the repo convention ("master took N via another PR"),
bump past master's number to 0.0.123 so each changeset keeps its own marker.
Updated kernel/package.json + root lockfile packages[kernel]; left
kernel/package-lock.json as-is (repo convention: not kept in sync).
PR core files (src/config.ts, src/loop/core.ts, kernel hide-consumed/types/
compress + their tests) are byte-identical to the pre-merge head — verified.
This commit is contained in:
+3
-3
@@ -199,7 +199,7 @@ This index is generated from `website/config-reference/*.yaml` — edit the seed
|
||||
| `fakeCompletion` | object | {} (all defaults) | — | Retry loop that re-requests when a final chunk arrives truncated. |
|
||||
| `fakeCompletion.retries` | number | 0 (opt-in) | BILI_FAKE_COMPLETION_RETRIES | How many times a truncated final completion may be re-requested; 0 disables the loop. |
|
||||
| `fakeCompletion.bufCapBytes` | number | 16777216 | BILI_FAKE_BUF_CAP | Buffer size cap for the retry loop's accumulated stream. |
|
||||
| `codexCompact` | "intercept" \| "pass" | "intercept" | BILI_CODEX_COMPACT | Handle Codex's explicit compaction requests (compaction_trigger + /responses/compact) inside bili (intercept, default) or forward them upstream (pass); codex's client-side auto-compaction never transits the proxy — detected + rebased post-hoc (#2372). |
|
||||
| `codexCompact` | "intercept" \| "pass" | "intercept" | BILI_CODEX_COMPACT | Handle Codex's compaction requests inside bili (intercept, default) or forward them upstream (pass): the explicit forms (compaction_trigger + /responses/compact) and the inline auto-compact that transits as an ordinary turn, detected by its SUMMARIZATION_PROMPT template (#3008) — a user-overridden compact_prompt falls out of detection and transits verbatim; a compaction bili only observed (pass/gate) is rebased post-hoc (#2372). |
|
||||
| `ccrRetrievalTtlMs` | number | 600000 (0 disables retrieval) | BILI_CCR_RETRIEVAL_TTL_MS | Lifetime of CCR retrieval pointers before originals stop being fetchable via acp_retrieve. |
|
||||
| `decompressTmpCap` | number | 50 | BILI_DECOMPRESS_TMP_CAP | Size cap (blocks) for temporary decompressed content held in-session. |
|
||||
|
||||
@@ -216,7 +216,7 @@ This index is generated from `website/config-reference/*.yaml` — edit the seed
|
||||
| `compress.nudgeModelDecided` | boolean | off (unset) | — | Model-decided nudge timing (#2228): an armed tier-1 nudge first asks the model — via a short side call over the session's cached prefix — whether compressing NOW helps the current task. A strict-JSON "yes" injects an explicit directive with a program-finalized span; "no", a malformed answer, or a timeout injects nothing this round. EMERGENCY arms and tier≥2 distillation always keep the legacy advisory. Off unless explicitly enabled. |
|
||||
| `compress.nudgeDecisionMaxTokens` | number | 200 | — | Output budget (tokens) of the model-decision side call used by nudgeModelDecided. Must be > 0. |
|
||||
| `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 | kernel ≈5 | — | The most recent messages stay soft-protected from folds. |
|
||||
| `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. |
|
||||
| `compress.minCompressRangeChars` | number (deprecated alias: minCompressRange) | kernel ≈5000 | — | Smallest foldable range, in characters; shorter ranges never fold. |
|
||||
| `compress.reconcile` | "off" \| "warn" \| "repair" | "repair" | BILI_FOLD_RECONCILE | Reconcile folded state when the client rewinds or rewrites history between turns. |
|
||||
@@ -1214,7 +1214,7 @@ For each request, the proxy resolves the settings by longest-URL-prefix match (t
|
||||
#### `preserveRecentMessages`
|
||||
|
||||
- **Type:** `number`
|
||||
- **Default:** *(kernel default, typically `5`)*
|
||||
- **Default:** *(kernel default, `3`; tuned from `5` in #3058)*
|
||||
- **Status:** ACTIVE
|
||||
- **Description:** Number of most-recent messages that are never offered for compression. Protects the active working set so the model retains the latest turns verbatim. Maps to the kernel field `preserveRecentMessages`.
|
||||
|
||||
|
||||
@@ -199,7 +199,7 @@
|
||||
| `fakeCompletion` | object | {} (all defaults) | — | 末块被截断时重新发起请求的重试环。 |
|
||||
| `fakeCompletion.retries` | number | 0 (opt-in) | BILI_FAKE_COMPLETION_RETRIES | 被截断的末块完成可被重新请求的次数;0 禁用该重试环。 |
|
||||
| `fakeCompletion.bufCapBytes` | number | 16777216 | BILI_FAKE_BUF_CAP | 重试环累积流缓冲的大小上限。 |
|
||||
| `codexCompact` | "intercept" \| "pass" | "intercept" | BILI_CODEX_COMPACT | 在 bili 内处理 Codex 的显式压缩请求(compaction_trigger + /responses/compact,intercept,默认)还是转给上游(pass);codex 的客户端自动压缩不过代理 —— 事后检测 + rebase(#2372)。 |
|
||||
| `codexCompact` | "intercept" \| "pass" | "intercept" | BILI_CODEX_COMPACT | 在 bili 内处理 Codex 的压缩请求(intercept,默认)还是转给上游(pass):覆盖显式形态(compaction_trigger + /responses/compact)与以普通请求形态过线的内联自动压缩(按 SUMMARIZATION_PROMPT 模板检测,#3008)—— 用户自定义 compact_prompt 后锚点失配、按原样转发;bili 仅旁路观察到的压缩(pass/安全阀放行)走事后 rebase(#2372)。 |
|
||||
| `ccrRetrievalTtlMs` | number | 600000 (0 disables retrieval) | BILI_CCR_RETRIEVAL_TTL_MS | CCR 回取指针的有效期,过期后原文不再可通过 acp_retrieve 取回。 |
|
||||
| `decompressTmpCap` | number | 50 | BILI_DECOMPRESS_TMP_CAP | 会话内临时展开内容的大小上限(按块计)。 |
|
||||
|
||||
@@ -216,7 +216,7 @@
|
||||
| `compress.nudgeModelDecided` | boolean | off (unset) | — | 模型自决的压缩时机(#2228):tier-1 提醒触发时,先通过一次走会话缓存前缀的短 side call 问模型——以当前任务为前提,现在压缩是否划算。严格 JSON 的 "yes" 会注入带程序最终确定范围的明确压缩指令;"no"、格式错误或超时则本轮不注入任何内容。EMERGENCY 档与 tier≥2 蒸馏始终保留原有 advisory。默认关闭,需显式开启。 |
|
||||
| `compress.nudgeDecisionMaxTokens` | number | 200 | — | nudgeModelDecided 所用模型决策 side call 的输出预算(token)。必须 > 0。 |
|
||||
| `compress.streamSummary` | boolean | false (unset) | — | 强制 preflight 摘要从首次尝试起就走流式(SSE)请求。要求流式的上游现在由错误驱动自学习自动处理(非流式摘要的任何 400 都会触发一次性 SSE 探测,#2494),但网关超时(如 Cloudflare HTTP 524)永远无法触发自学习:在此类网关位于 bili 与源站之间时设置此项,或用于省去一次探测往返。 |
|
||||
| `compress.preserveRecentMessages` | number | kernel ≈5 | — | 最近的消息软保护、免于折叠。 |
|
||||
| `compress.preserveRecentMessages` | number | 3 | — | 最近的消息软保护、免于折叠。 |
|
||||
| `compress.preserveRecentTokens` | number | kernel ≈5000 | — | 最近的 token 软保护、免于折叠。 |
|
||||
| `compress.minCompressRangeChars` | number (deprecated alias: minCompressRange) | kernel ≈5000 | — | 可折叠片段的最小字符数;更短的永不折叠。 |
|
||||
| `compress.reconcile` | "off" \| "warn" \| "repair" | "repair" | BILI_FOLD_RECONCILE | 客户端在轮次之间回退或改写历史时校准已折叠状态。 |
|
||||
@@ -1217,7 +1217,7 @@ ACP 原生 agent(当前为 `pi` 扩展)会在每个进程内向代理上报
|
||||
#### `preserveRecentMessages`
|
||||
|
||||
- **类型:** `number`
|
||||
- **默认值:** *(内核默认值,通常为 `5`)*
|
||||
- **默认值:** *(内核默认值 `3`;由 `5` 调整,见 #3058)*
|
||||
- **状态:** ACTIVE
|
||||
- **说明:** 永远不会被纳入压缩的最新消息条数。用于保护活跃工作集,使模型逐字保留最近的几轮对话。映射到内核字段 `preserveRecentMessages`。
|
||||
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "acp-kernel",
|
||||
"version": "0.0.122",
|
||||
"version": "0.0.123",
|
||||
"description": "Framework-agnostic context-compression engine (model-driven, 3-tier LSM). Pure core: no host dependency.",
|
||||
"license": "MIT",
|
||||
"author": "ranxianglei",
|
||||
|
||||
@@ -29,7 +29,9 @@ export function defaultConfig(
|
||||
},
|
||||
protectedTools: [],
|
||||
protectedLatestTools: [],
|
||||
preserveRecentMessages: 5,
|
||||
// #3058: 5 → 3 — owner-tuned: 3 keeps the active turn + previous exchange
|
||||
// verbatim while older history folds earlier (tighter context reclaim).
|
||||
preserveRecentMessages: 3,
|
||||
preserveRecentTokens: 5000,
|
||||
modelContextLimit,
|
||||
absorb: {
|
||||
|
||||
Generated
+1
-1
@@ -48,7 +48,7 @@
|
||||
},
|
||||
"kernel": {
|
||||
"name": "acp-kernel",
|
||||
"version": "0.0.122",
|
||||
"version": "0.0.123",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"devDependencies": {
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
".": "./dist/agent/dsh-native.js",
|
||||
"./server": "./dist/agent/opencode-native.js",
|
||||
"./dsh": "./dist/agent/dsh-native.js",
|
||||
"./package.json": "./package.json",
|
||||
"./dsh/package.json": "./package.json",
|
||||
"./client": "./dist/agent/dsh-native-client.js"
|
||||
},
|
||||
|
||||
@@ -48,6 +48,48 @@ export function hasCompactionTrigger(input: unknown): boolean {
|
||||
return last?.type === "compaction_trigger";
|
||||
}
|
||||
|
||||
// #3008: codex's local inline auto-compact (compact.rs
|
||||
// run_inline_auto_compact_task, observed rust-v0.162.1) travels as an
|
||||
// ORDINARY turn — full history + the SUMMARIZATION_PROMPT template as the
|
||||
// last user message. No trigger field, no dedicated endpoint: the only wire
|
||||
// signature is the prompt text itself. Anchor on the immutable first line of
|
||||
// codex's built-in template (prompts/templates/compact/prompt.md, versioned
|
||||
// here like the #2372 summary prefix). A user-overridden compact_prompt no
|
||||
// longer matches and falls back to verbatim passthrough (documented, not
|
||||
// silently wrong).
|
||||
export const CODEX_COMPACT_PROMPT_ANCHOR = "You are performing a CONTEXT CHECKPOINT COMPACTION.";
|
||||
|
||||
function messageItemText(content: unknown): string | undefined {
|
||||
if (typeof content === "string") return content;
|
||||
if (!Array.isArray(content)) return undefined;
|
||||
const parts: string[] = [];
|
||||
for (const part of content) {
|
||||
const p = part as { type?: unknown; text?: unknown } | null;
|
||||
if (p && typeof p === "object" && typeof p.text === "string" &&
|
||||
(p.type === "input_text" || p.type === "output_text" || p.type === "text" || p.type === undefined)) {
|
||||
parts.push(p.text);
|
||||
}
|
||||
}
|
||||
return parts.length > 0 ? parts.join("") : undefined;
|
||||
}
|
||||
|
||||
// True when the LAST message item in input[] is a user message opening with
|
||||
// the built-in auto-compact template. Scanning backwards keeps mid-history
|
||||
// quotes out: only the final user message can be the live compaction turn
|
||||
// (the template is recorded as the last input item before the request is
|
||||
// sent). A trailing non-user message (assistant/developer) disqualifies.
|
||||
export function hasCompactionPrompt(input: unknown): boolean {
|
||||
if (!Array.isArray(input)) return false;
|
||||
for (let i = input.length - 1; i >= 0; i--) {
|
||||
const item = input[i] as { type?: unknown; role?: unknown; content?: unknown } | undefined;
|
||||
if (!item || typeof item !== "object" || item.type !== "message") continue;
|
||||
if (item.role !== "user") return false;
|
||||
const text = messageItemText(item.content);
|
||||
return typeof text === "string" && text.trimStart().startsWith(CODEX_COMPACT_PROMPT_ANCHOR);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
// #2372: codex's LOCAL auto-compaction (rollout event type:"compacted") never
|
||||
// transits the proxy — no compaction_trigger item, no /responses/compact
|
||||
// call. The proxy only sees the aftermath: the next request replays
|
||||
@@ -182,6 +224,53 @@ export function buildTriggerForgeBody(
|
||||
return { body: frame1 + frame2, contentType: "text/event-stream" };
|
||||
}
|
||||
|
||||
// Forged reply for the PROMPT form (#3008): the auto-compact request is a
|
||||
// normal POST /v1/responses whose completion codex records item-by-item
|
||||
// (session/turn.rs drain_to_completed — every output_item.done becomes a
|
||||
// history item, then response.completed carries usage). The summary codex
|
||||
// adopts = the last ASSISTANT message in that history, so we answer with
|
||||
// exactly one assistant message item carrying bili's captured fold
|
||||
// summaries. Codex then assembles its compacted payload as its own
|
||||
// SUMMARY_PREFIX + this text — we must NOT pre-prefix it.
|
||||
export function buildPromptForgeBody(
|
||||
summaryText: string,
|
||||
usage: { inputTokens: number; outputTokens: number; totalTokens: number },
|
||||
stream: boolean,
|
||||
): { body: string; contentType: string } {
|
||||
const id = `resp_bili_${randomUUID()}`;
|
||||
const messageId = `msg_bili_${randomUUID()}`;
|
||||
const messageItem = {
|
||||
type: "message",
|
||||
id: messageId,
|
||||
role: "assistant",
|
||||
status: "completed",
|
||||
content: [{ type: "output_text", text: summaryText, annotations: [] }],
|
||||
};
|
||||
const usageJson = {
|
||||
input_tokens: usage.inputTokens,
|
||||
output_tokens: usage.outputTokens,
|
||||
total_tokens: usage.totalTokens,
|
||||
};
|
||||
if (!stream) {
|
||||
return {
|
||||
body: JSON.stringify({ id, object: "response", output: [messageItem], usage: usageJson }),
|
||||
contentType: "application/json",
|
||||
};
|
||||
}
|
||||
const frame = (obj: unknown) => `data: ${JSON.stringify(obj)}\n\n`;
|
||||
let body = "";
|
||||
body += frame({ type: "response.created", response: { id, status: "in_progress" } });
|
||||
body += frame({ type: "response.output_item.added", output_index: 0, item: { ...messageItem, status: "in_progress" } });
|
||||
body += frame({ type: "response.content_part.added", item_id: messageId, output_index: 0, content_index: 0, part: { type: "output_text", text: "", annotations: [] } });
|
||||
body += frame({ type: "response.output_text.delta", item_id: messageId, output_index: 0, content_index: 0, delta: summaryText });
|
||||
body += frame({ type: "response.output_text.done", item_id: messageId, output_index: 0, content_index: 0, text: summaryText });
|
||||
body += frame({ type: "response.content_part.done", item_id: messageId, output_index: 0, content_index: 0, part: { type: "output_text", text: summaryText, annotations: [] } });
|
||||
body += frame({ type: "response.output_item.done", output_index: 0, item: messageItem });
|
||||
body += frame({ type: "response.completed", response: { id, status: "completed", usage: usageJson } });
|
||||
body += "data: [DONE]\n\n";
|
||||
return { body, contentType: "text/event-stream" };
|
||||
}
|
||||
|
||||
// The kernel renders block summaries as system messages with this header
|
||||
// (acp-kernel SUMMARY_HEADER). Reuse the exact format so the model reads a
|
||||
// captured handoff summary the same way it reads a live kernel-rendered one.
|
||||
|
||||
@@ -110,7 +110,7 @@ export function conflictRemediation(client: string | undefined): string {
|
||||
case "claude":
|
||||
return "launch through bili claude (it aligns CLAUDE_CODE_AUTO_COMPACT_WINDOW automatically), or set CLAUDE_CODE_AUTO_COMPACT_WINDOW to bili's effective window yourself";
|
||||
case "codex":
|
||||
return "codex's client-side auto-compaction never transits the proxy — bili detects it and rebases ACP state onto the compacted history (#2372); BILI_CODEX_COMPACT only governs codex's explicit compaction requests (/compact, /responses/compact), intercepted by default — if you set pass, remove the override";
|
||||
return "BILI_CODEX_COMPACT=intercept by default: bili intercepts codex compaction in every form — explicit (/compact, /responses/compact, compaction_trigger) and the inline auto-compact that transits as an ordinary turn detected by its SUMMARIZATION_PROMPT template (#3008) — if you set pass, remove the override; a compaction bili merely observed (pass/gate) is rebased post-hoc (#2372)";
|
||||
case "pi":
|
||||
case "omp":
|
||||
return "the bili extension cancels the client's native auto-compaction while it carries the conversation — seeing this suggests missing carriage evidence or an old version; report client + bili version";
|
||||
|
||||
+1
-1
@@ -2989,7 +2989,7 @@ export function writeDshClientShimFiles(shimDir: string, hostBundle: string, cli
|
||||
name: "billion-context",
|
||||
version,
|
||||
type: "module",
|
||||
exports: { ".": "./index.js", "./dsh": "./index.js", "./dsh/package.json": "./package.json", "./client": "./bundle.js" },
|
||||
exports: { ".": "./index.js", "./dsh": "./index.js", "./package.json": "./package.json", "./dsh/package.json": "./package.json", "./client": "./bundle.js" },
|
||||
dsh: { client: { platform: "web" } },
|
||||
})}\n`,
|
||||
);
|
||||
|
||||
+1
-1
@@ -1362,7 +1362,7 @@ export type Prepared = {
|
||||
/** Set when a codex native-compaction request was intercepted and a
|
||||
* success response was forged locally (BILI_CODEX_COMPACT=intercept +
|
||||
* gate passed). forward() serves `body` without contacting upstream. */
|
||||
codexForge?: { kind: "endpoint" | "trigger"; body: string; contentType: string };
|
||||
codexForge?: { kind: "endpoint" | "trigger" | "prompt"; body: string; contentType: string };
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -34,6 +34,11 @@ import { emitPreflightError } from "../stream-error.js";
|
||||
import { agentProviderRecipes } from "../agent-providers.js";
|
||||
import { affinityToken, conversationHeaderSource, claudeSubagentAgentId, claudeSubagentSplit, clientConversationHeader, codexTurnIdentity, dshPersonaFingerprintApplies, instructionsFingerprintApplies, openaiSystemTextForPersona, preferPromptCacheKeyIdentity } from "../session-id.js";
|
||||
import { personaConversationOrder } from "../session-resolve.js";
|
||||
// #3060: the google-lane call site below still uses the v1 resolver (it is
|
||||
// the one lane ddf366b4 did not migrate); the import was dropped with the
|
||||
// rest of the v1 wiring, which broke typecheck and threw ReferenceError at
|
||||
// runtime on the google dsh-persona path. Restore it until that lane is
|
||||
// deliberately migrated to personaConversationOrder.
|
||||
import { personaNamespace } from "../persona-anchor.js";
|
||||
import { prefixAffinity, type AnonymousAffinity } from "../prefix-affinity.js";
|
||||
import { buildAnonymousProvenance, type AnonymousProvenance } from "../anon-provenance.js";
|
||||
@@ -2077,7 +2082,10 @@ async function handleRequest(
|
||||
degradeAvailable: opts.compress.injectTool && !knobNoInjectTool(),
|
||||
}, log);
|
||||
}
|
||||
if (!countTokens && !responsesCompact) {
|
||||
// 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).
|
||||
if (!countTokens && !responsesCompact && !prepared.codexForge) {
|
||||
const outcome = await preflightCompressIfNeeded(
|
||||
prepared,
|
||||
runPrepare,
|
||||
|
||||
@@ -27,7 +27,7 @@ import { estimateCoreMessages, estimateCoreMessagesUpper } from "../preflight.js
|
||||
import { hoistTrappedToolItems } from "../tool-pair-order.js";
|
||||
import { isStrictReasoningEcho, modelIdOf, normalizeStrictEchoResponsesInput } from "../strict-echo.js";
|
||||
import { reconcileSystemAnchor } from "../system-anchor.js";
|
||||
import { buildTriggerForgeBody, carriesCodexLocalCompactionSummary, codexCompactGate, codexCompactGatePre, codexCompactMode, hasCompactionTrigger, isCodexClient, mergeForgedSummaries, replaceBiliCompactionItems, stripBiliCompactionItems, CODEX_COMPACT_HEALTH_RATIO, CODEX_LOCAL_COMPACTION_MIN_MISSING } from "../codex-compact.js";
|
||||
import { buildPromptForgeBody, buildTriggerForgeBody, carriesCodexLocalCompactionSummary, codexCompactGate, codexCompactGatePre, codexCompactMode, hasCompactionPrompt, hasCompactionTrigger, isCodexClient, mergeForgedSummaries, replaceBiliCompactionItems, stripBiliCompactionItems, CODEX_COMPACT_HEALTH_RATIO, CODEX_LOCAL_COMPACTION_MIN_MISSING } from "../codex-compact.js";
|
||||
import type { ConversationIdentity } from "../session-id.js";
|
||||
import { logRawStripCounts, markerArtifactCount, stripRawStage } from "../marker/engine.js";
|
||||
import { keepResponseId as knobKeepResponseId, noCompressPrompt as knobNoCompressPrompt, noInjectTool as knobNoInjectTool, renderNone as knobRenderNone } from "../knobs.js";
|
||||
@@ -452,16 +452,24 @@ export async function prepareResponses(
|
||||
processedMessages = [];
|
||||
}
|
||||
|
||||
// E2 trigger form: codex's native remote-compaction request (final input item
|
||||
// is compaction_trigger). When the kill-switch is on, the client is codex, and
|
||||
// the safety gate passes, forge a success SSE (one compaction item +
|
||||
// response.completed) and skip upstream — a deterministic handoff to the ACP
|
||||
// state instead of a foreign compaction blob.
|
||||
// E2 compaction forms: codex's native remote-compaction request (final
|
||||
// input item is compaction_trigger) — and, since #3008, the LOCAL inline
|
||||
// auto-compact that travels as an ordinary turn opening with codex's
|
||||
// SUMMARIZATION_PROMPT template (prompt form). When the kill-switch is
|
||||
// on, the client is codex, and the safety gate passes, forge a success
|
||||
// reply and skip upstream — a deterministic handoff to the ACP state
|
||||
// instead of a foreign compaction blob (the prompt form alone otherwise
|
||||
// re-caches the full unfolded history, 720k tokens in the #3008 incident).
|
||||
const compactForm: "trigger" | "prompt" | undefined = hasCompactionTrigger(parsed.input)
|
||||
? "trigger"
|
||||
: hasCompactionPrompt(parsed.input)
|
||||
? "prompt"
|
||||
: undefined;
|
||||
let codexForge: Prepared["codexForge"] | undefined;
|
||||
if (transformOk
|
||||
&& compactForm !== undefined
|
||||
&& codexCompactMode() === "intercept"
|
||||
&& isCodexClient(req.headers)
|
||||
&& hasCompactionTrigger(parsed.input)
|
||||
&& codexCompactGate(session, config.modelContextLimit, transformOk)) {
|
||||
const summaries = session.state.blocks.filter((b) => b.active).map((b) => b.summary);
|
||||
const prevForged = session.metadata.codexForgedSummaries as string[] | undefined;
|
||||
@@ -472,16 +480,20 @@ export async function prepareResponses(
|
||||
}
|
||||
// Codex recomputes its ledger from the next real request, but the
|
||||
// usage we mint here must not read as an empty context: fall back to
|
||||
// estimating the trigger payload itself when lastInputTokens is
|
||||
// stale/zero. The reply honors parsed.stream (JSON body when not
|
||||
// streaming).
|
||||
// estimating the payload itself when lastInputTokens is stale/zero.
|
||||
// The reply honors parsed.stream (JSON body when not streaming).
|
||||
const est = defaultCountTokens(typeof parsed.input === "string" ? parsed.input : JSON.stringify(parsed.input ?? ""));
|
||||
const total = Math.max(session.stats.lastInputTokens, est, 1);
|
||||
codexForge = {
|
||||
kind: "trigger",
|
||||
...buildTriggerForgeBody(summaries.join("\n\n"), { inputTokens: total, outputTokens: 0, totalTokens: total }, stream),
|
||||
};
|
||||
log("info", `[${sessionId}] codex compact intercepted (trigger); forged SSE with ${summaries.length} block summary(s), upstream not contacted`);
|
||||
codexForge = compactForm === "trigger"
|
||||
? {
|
||||
kind: "trigger",
|
||||
...buildTriggerForgeBody(summaries.join("\n\n"), { inputTokens: total, outputTokens: 0, totalTokens: total }, stream),
|
||||
}
|
||||
: {
|
||||
kind: "prompt",
|
||||
...buildPromptForgeBody(summaries.join("\n\n"), { inputTokens: total, outputTokens: 0, totalTokens: total }, stream),
|
||||
};
|
||||
log("info", `[${sessionId}] codex compact intercepted (${compactForm} form); forged ${stream ? "SSE" : "JSON"} with ${summaries.length} block summary(s), upstream not contacted`);
|
||||
}
|
||||
|
||||
// #1479: Responses-wire twin of the #762 repair — fold + kernel round-trip
|
||||
|
||||
+1
-1
@@ -1840,7 +1840,7 @@ export const WEB_CLIENT = `(function () {
|
||||
try { draft = JSON.parse(fe && fe.value ? fe.value : "{}"); if (!draft || typeof draft !== "object" || Array.isArray(draft)) draft = {}; } catch (e) { return; }
|
||||
function compressOf(d) { return (d.compress && typeof d.compress === "object" && !Array.isArray(d.compress)) ? d.compress : null; }
|
||||
const NUDGE_DEFAULT = 50000, NUDGE_STEP = 5000, NUDGE_LOW = 20000, NUDGE_HIGH = 100000;
|
||||
const PRM_KERNEL_DEFAULT = 5;
|
||||
const PRM_KERNEL_DEFAULT = 3;
|
||||
const brokenNote = document.createElement("div");
|
||||
brokenNote.style.cssText = "min-height:16px;font-size:12px;color:#cf222e";
|
||||
box.appendChild(brokenNote);
|
||||
|
||||
@@ -557,3 +557,93 @@ for (const variant of [
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// #3008: prompt-form auto-compact. Codex's LOCAL inline auto-compact travels
|
||||
// as an ordinary turn — full history + SUMMARIZATION_PROMPT template as the
|
||||
// last user message (no trigger field, no /responses/compact endpoint). The
|
||||
// only wire signature is the prompt text. When the gate passes, bili forges
|
||||
// the completion (one assistant message = codex's summary_suffix) and skips
|
||||
// upstream — otherwise the request re-caches the full unfolded history
|
||||
// (720k tokens in the #3008 incident) and, if the model returns no assistant
|
||||
// content, codex adopts a placeholder summary (template + old message).
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
import { CODEX_COMPACT_PROMPT_ANCHOR } from "../src/codex-compact.ts";
|
||||
|
||||
function promptFormBody(sessionId: string) {
|
||||
return {
|
||||
model: "gpt-resp",
|
||||
stream: true,
|
||||
session_id: sessionId,
|
||||
instructions: "You are the test coding agent.",
|
||||
input: [
|
||||
...conversation(),
|
||||
{ type: "message", role: "user", content: [{ type: "input_text", text: `${CODEX_COMPACT_PROMPT_ANCHOR} Create a handoff summary for another LLM that will resume the task.` }] },
|
||||
],
|
||||
};
|
||||
}
|
||||
|
||||
test("prompt-form auto-compact is intercepted and forged locally (#3008)", async () => {
|
||||
await withHarness({ firstTurnTokens: 100, mode: "intercept" }, async (h) => {
|
||||
const after = await setupCompressedSession(h);
|
||||
const response = await fetch(h.url, {
|
||||
method: "POST",
|
||||
headers: { "content-type": "application/json", "user-agent": CODEX_UA },
|
||||
body: JSON.stringify(promptFormBody(SESSION)),
|
||||
});
|
||||
assert.equal(response.status, 200);
|
||||
const text = await response.text();
|
||||
assert.match(response.headers.get("content-type")!, /text\/event-stream/);
|
||||
assert.ok(text.includes("MAIN-SUMMARY-SETUP-CONTEXT-FOLDED"), "forged assistant message carries the block summary");
|
||||
assert.match(text, /"type":"response\.output_item\.done"/, "codex records this item as its compaction output");
|
||||
assert.match(text, /"type":"response\.completed"/, "codex parser requires completed with id + usage");
|
||||
await new Promise((r) => setTimeout(r, 60));
|
||||
assert.equal(h.bodies.length, after, "upstream not contacted for the intercepted auto-compact");
|
||||
const s = listSessions().find((x) => x.meta.label === SESSION);
|
||||
assert.ok(s, "session tracked");
|
||||
const captured = s!.metadata.codexForgedSummaries as string[] | undefined;
|
||||
assert.ok(captured && captured.length > 0, "summaries captured for post-compaction re-injection");
|
||||
});
|
||||
});
|
||||
|
||||
test("prompt-form auto-compact passes through when no block exists to hand off (#3008)", async () => {
|
||||
await withHarness({ firstTurnTokens: 100, mode: "intercept" }, async (h) => {
|
||||
const response = await fetch(h.url, {
|
||||
method: "POST",
|
||||
headers: { "content-type": "application/json", "user-agent": CODEX_UA },
|
||||
body: JSON.stringify(promptFormBody("prompt-form-no-blocks")),
|
||||
});
|
||||
assert.equal(response.status, 200);
|
||||
await response.text();
|
||||
assert.ok(await reachesUpstreamRequests(h, 1, 2_000), "gate failed (no active block) → forwarded verbatim");
|
||||
});
|
||||
});
|
||||
|
||||
test("prompt-form auto-compact passes through in pass mode (#3008)", async () => {
|
||||
await withHarness({ firstTurnTokens: 100, mode: "pass" }, async (h) => {
|
||||
const after = await setupCompressedSession(h);
|
||||
const response = await fetch(h.url, {
|
||||
method: "POST",
|
||||
headers: { "content-type": "application/json", "user-agent": CODEX_UA },
|
||||
body: JSON.stringify(promptFormBody("prompt-form-pass")),
|
||||
});
|
||||
assert.equal(response.status, 200);
|
||||
await response.text();
|
||||
assert.ok(await reachesUpstreamRequests(h, after + 1, 2_000), "kill-switch pass → forwarded");
|
||||
});
|
||||
});
|
||||
|
||||
test("prompt-form detection is codex-only: same template from a non-codex client forwards", async () => {
|
||||
await withHarness({ firstTurnTokens: 100, mode: "intercept" }, async (h) => {
|
||||
const body = promptFormBody("prompt-form-not-codex");
|
||||
const response = await fetch(h.url, {
|
||||
method: "POST",
|
||||
headers: { "content-type": "application/json", "user-agent": "openai-node/3.0" },
|
||||
body: JSON.stringify(body),
|
||||
});
|
||||
assert.equal(response.status, 200);
|
||||
await response.text();
|
||||
assert.ok(await reachesUpstreamRequests(h, 1, 2_000), "non-codex UA → ordinary turn");
|
||||
});
|
||||
});
|
||||
|
||||
@@ -228,3 +228,60 @@ test("mergeForgedSummaries: append active, skip inactive, dedup, accumulate acro
|
||||
assert.equal(merged[2], "[Compressed conversation section]\nSUMMARY-D");
|
||||
assert.deepEqual(mergeForgedSummaries(undefined, []), []);
|
||||
});
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// #3008: prompt-form auto-compact detection + forge
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
import {
|
||||
hasCompactionPrompt,
|
||||
buildPromptForgeBody,
|
||||
CODEX_COMPACT_PROMPT_ANCHOR,
|
||||
} from "../src/codex-compact.ts";
|
||||
|
||||
const PROMPT_TEXT = `${CODEX_COMPACT_PROMPT_ANCHOR} Create a handoff summary for another LLM that will resume the task.`;
|
||||
|
||||
test("hasCompactionPrompt: last user message opening with the built-in template (#3008)", () => {
|
||||
const user = (text: string) => ({ type: "message", role: "user", content: [{ type: "input_text", text }] });
|
||||
assert.equal(hasCompactionPrompt([user("hi"), user(PROMPT_TEXT)]), true, "template as last user message");
|
||||
assert.equal(hasCompactionPrompt([user(PROMPT_TEXT)]), true, "string content form");
|
||||
assert.equal(hasCompactionPrompt([user("hi")]), false, "ordinary last user message");
|
||||
assert.equal(hasCompactionPrompt([user(PROMPT_TEXT), { type: "message", role: "assistant", content: "x" }]), false, "assistant after the template disqualifies");
|
||||
assert.equal(hasCompactionPrompt([user("hi"), user(`Before you start: ${PROMPT_TEXT}`)]), false, "anchor must open the message, not appear mid-text");
|
||||
assert.equal(hasCompactionPrompt([user(PROMPT_TEXT), user("hi")]), false, "mid-history template (not last) is not the compaction turn");
|
||||
assert.equal(hasCompactionPrompt([{ type: "compaction_trigger" }]), false, "trigger form is not the prompt form");
|
||||
assert.equal(hasCompactionPrompt([]), false);
|
||||
assert.equal(hasCompactionPrompt("a string"), false);
|
||||
assert.equal(hasCompactionPrompt([{ type: "message", role: "user", content: [{ type: "input_text", text: " " + PROMPT_TEXT }] }]), true, "leading whitespace tolerated");
|
||||
// A user-overridden compact_prompt (config.compact_prompt in codex) no
|
||||
// longer matches the built-in anchor → falls back to passthrough.
|
||||
assert.equal(hasCompactionPrompt([user("My own custom compaction instructions.")]), false, "overridden template falls out of detection");
|
||||
});
|
||||
|
||||
test("buildPromptForgeBody: one assistant message codex adopts as its summary (#3008)", () => {
|
||||
const summary = "MAIN-SUMMARY-SETUP-CONTEXT-FOLDED";
|
||||
const stream = buildPromptForgeBody(summary, { inputTokens: 725_892, outputTokens: 0, totalTokens: 725_892 }, true);
|
||||
assert.equal(stream.contentType, "text/event-stream");
|
||||
assert.ok(stream.body.includes("response.created"), "created first");
|
||||
const doneMatch = stream.body.match(/data: (\{"type":"response\.output_item\.done".*})\n/);
|
||||
assert.ok(doneMatch, "output_item.done present");
|
||||
const doneItem = JSON.parse(doneMatch![1]!) as { item: { type: string; role: string; status: string; content: { type: string; text: string }[] } };
|
||||
assert.equal(doneItem.item.type, "message");
|
||||
assert.equal(doneItem.item.role, "assistant");
|
||||
assert.equal(doneItem.item.status, "completed");
|
||||
assert.equal(doneItem.item.content[0]!.type, "output_text");
|
||||
assert.equal(doneItem.item.content[0]!.text, summary, "codex's summary_suffix = this text");
|
||||
const completedMatch = stream.body.match(/data: (\{"type":"response\.completed".*})\n/);
|
||||
assert.ok(completedMatch, "response.completed present (codex parser requires id + usage)");
|
||||
const completed = JSON.parse(completedMatch![1]!) as { response: { id: string; usage: { input_tokens: number } } };
|
||||
assert.equal(completed.response.usage.input_tokens, 725_892);
|
||||
assert.ok(stream.body.trimEnd().endsWith("data: [DONE]"), "SSE terminator");
|
||||
|
||||
const json = buildPromptForgeBody(summary, { inputTokens: 10, outputTokens: 0, totalTokens: 10 }, false);
|
||||
assert.equal(json.contentType, "application/json");
|
||||
const parsed = JSON.parse(json.body) as { id: string; output: { type: string; role: string; content: { text: string }[] }[]; usage: { total_tokens: number } };
|
||||
assert.equal(parsed.output.length, 1);
|
||||
assert.equal(parsed.output[0]!.role, "assistant");
|
||||
assert.equal(parsed.output[0]!.content[0]!.text, summary);
|
||||
assert.equal(parsed.usage.total_tokens, 10);
|
||||
});
|
||||
|
||||
@@ -66,8 +66,9 @@ test("conflictRemediation: one line per known client, generic fallback for the r
|
||||
assert.ok(cl.includes("CLAUDE_CODE_AUTO_COMPACT_WINDOW"), cl);
|
||||
assert.ok(cl.includes("bili claude"), cl);
|
||||
const cx = conflictRemediation("codex");
|
||||
// #3008 reworded this hint (intercept is now the default) — pin the env-var reference, not the stale `=intercept` literal
|
||||
assert.ok(cx.includes("BILI_CODEX_COMPACT"), cx);
|
||||
assert.ok(cx.includes("BILI_CODEX_COMPACT=intercept"), cx);
|
||||
assert.ok(cx.includes("#3008"), cx);
|
||||
assert.ok(!cx.includes("never transits"), "#3008: the inline auto-compact DOES transit as an ordinary turn — the old copy was false");
|
||||
assert.equal(conflictRemediation("pi"), conflictRemediation("omp"), "pi and omp share the carriage-evidence hint");
|
||||
assert.ok(conflictRemediation("pi").includes("report client + bili version"));
|
||||
const gen = conflictRemediation(undefined);
|
||||
|
||||
@@ -962,6 +962,18 @@ test("#2125: the manifest declares no dsh.client.inject (pre-0.2 dsh compat)", (
|
||||
assert.equal(pkg.dsh?.client?.inject ?? null, null, "dsh.client.inject would break pre-0.2 dsh clients");
|
||||
});
|
||||
|
||||
test("#3043: the published manifest exposes ./package.json so dsh's client scanner can locate the package root", () => {
|
||||
const pkg = JSON.parse(fs.readFileSync(new URL("../package.json", import.meta.url), "utf8")) as {
|
||||
exports?: Record<string, unknown>;
|
||||
};
|
||||
// Node's `exports` map is closed once declared — an unlisted subpath throws
|
||||
// ERR_PACKAGE_PATH_NOT_EXPORTED. dsh's client scanner resolves
|
||||
// "<pkg>/package.json" to find the package root before reading dsh.client;
|
||||
// the self-mapping below looks redundant but is load-bearing: drop it and
|
||||
// the scanner swallows the throw, so the browser half never registers.
|
||||
assert.equal(pkg.exports?.["./package.json"], "./package.json");
|
||||
});
|
||||
|
||||
test("#2448: embed face adapts the data tables to a narrow host panel (CSS pins)", () => {
|
||||
// The embed iframe lives inside a dsh settings column (400-760px), not a
|
||||
// browser tab — the standalone-page table floors (940px/520px + fixed
|
||||
|
||||
@@ -80,12 +80,12 @@
|
||||
"foldAt": 9,
|
||||
"editedAt": 12,
|
||||
"summaryFrom": 9,
|
||||
"stateDigest": "e47a82482ed9d3fc1201562c2c539f5432873acb264862e055c5569396040aac",
|
||||
"stateDigest": "858ed1c3988c25280181c34a9b30ddf78c86b4237eb5076ab311456a3001c322",
|
||||
"sectionDigests": {
|
||||
"state": "285aa622a037321b",
|
||||
"blockContents": "b3a9c59b22ec1a3a",
|
||||
"stats": "4271a6483e02458a",
|
||||
"metadata": "f582165dae264d64"
|
||||
"metadata": "32e9f789c44286ca"
|
||||
},
|
||||
"stateKeyDigests": {
|
||||
"blocks": "8a3021f39f1f2eb8",
|
||||
|
||||
@@ -80,12 +80,12 @@
|
||||
"foldAt": 9,
|
||||
"editedAt": 12,
|
||||
"summaryFrom": 9,
|
||||
"stateDigest": "3a6d4239e182ebb6fe02a99faf40324a963d5f74f9bb0be0b1752f47bee65497",
|
||||
"stateDigest": "7488de3b6fbb1f061c1fdc7e83b2b99009a936aef04dc36624e21fc161159903",
|
||||
"sectionDigests": {
|
||||
"state": "6e905e4ae1e678b8",
|
||||
"blockContents": "dd2de296a5bc6160",
|
||||
"stats": "ed7d3e3f253e0942",
|
||||
"metadata": "1f78ed1b58e4a77e"
|
||||
"metadata": "59f40d0ef9c2755e"
|
||||
},
|
||||
"stateKeyDigests": {
|
||||
"blocks": "bdde93b0e100e13e",
|
||||
|
||||
@@ -80,12 +80,12 @@
|
||||
"foldAt": 9,
|
||||
"editedAt": 12,
|
||||
"summaryFrom": 9,
|
||||
"stateDigest": "91d1cdd51aed493c3f1c1e4857e4a768cd43be23cc69647ca3f2376f4270e74a",
|
||||
"stateDigest": "65929f00d8a26805ef859fd9ab9197d605e0531bccb17813c3457019c617ad54",
|
||||
"sectionDigests": {
|
||||
"state": "0725cfe81690b748",
|
||||
"blockContents": "4cc83a808a659f28",
|
||||
"stats": "096da9a1f61d84d0",
|
||||
"metadata": "a615198f56928645"
|
||||
"metadata": "0fb314268fb92034"
|
||||
},
|
||||
"stateKeyDigests": {
|
||||
"blocks": "9adb53303cd4b786",
|
||||
|
||||
@@ -80,12 +80,12 @@
|
||||
"foldAt": 9,
|
||||
"editedAt": 12,
|
||||
"summaryFrom": 9,
|
||||
"stateDigest": "bbb968638e19d82d097871d73240d0dbabdbd3978fb7b6e140960c232e1de1bb",
|
||||
"stateDigest": "c326a242c21c86ec70b0c148fc8c4951cb31f449e125f97a970a7130444a1ec4",
|
||||
"sectionDigests": {
|
||||
"state": "7194736468931151",
|
||||
"blockContents": "1727e2e1faf79b55",
|
||||
"stats": "062b6eaaeb325945",
|
||||
"metadata": "cd0990da20e0f33c"
|
||||
"metadata": "3b76417727dbe3d0"
|
||||
},
|
||||
"stateKeyDigests": {
|
||||
"blocks": "0458e9c8a7bb1a99",
|
||||
|
||||
@@ -1647,7 +1647,7 @@
|
||||
},
|
||||
"protectedTools": [],
|
||||
"protectedLatestTools": [],
|
||||
"preserveRecentMessages": 5,
|
||||
"preserveRecentMessages": 3,
|
||||
"preserveRecentTokens": 5000,
|
||||
"modelContextLimit": 100000,
|
||||
"absorb": {
|
||||
|
||||
+10
-1
@@ -9,6 +9,7 @@ type SymlinkKind = "dir" | "file" | "junction";
|
||||
import net from "node:net";
|
||||
import os from "node:os";
|
||||
import path from "node:path";
|
||||
import { createRequire } from "node:module";
|
||||
import {
|
||||
claimStartingMarker,
|
||||
readStartingMarker,
|
||||
@@ -3722,7 +3723,7 @@ test("writeDshClientShimFiles + dshPluginEntry: resolvable shim yields the bare
|
||||
assert.equal(writeDshClientShimFiles(shimDir, hostBundle, clientBundle, "0.1.169"), true);
|
||||
const shimPkg = JSON.parse(fs.readFileSync(path.join(shimDir, "package.json"), "utf8"));
|
||||
assert.equal(shimPkg.name, "billion-context");
|
||||
assert.deepEqual(shimPkg.exports, { ".": "./index.js", "./dsh": "./index.js", "./dsh/package.json": "./package.json", "./client": "./bundle.js" });
|
||||
assert.deepEqual(shimPkg.exports, { ".": "./index.js", "./dsh": "./index.js", "./package.json": "./package.json", "./dsh/package.json": "./package.json", "./client": "./bundle.js" });
|
||||
assert.equal(shimPkg.dsh.client.platform, "web");
|
||||
// The bundles are SYMLINKS into bili's live dist — an auto-update that
|
||||
// moves dist self-heals on the next launch without rewriting the shim.
|
||||
@@ -3733,6 +3734,14 @@ test("writeDshClientShimFiles + dshPluginEntry: resolvable shim yields the bare
|
||||
// lands on the host module itself ⇒ the bare entry.
|
||||
assert.equal(dshPluginEntry(home), "billion-context");
|
||||
|
||||
// #3043: dsh's client scanner locates the package root via
|
||||
// require.resolve("billion-context/package.json") before reading dsh.client.
|
||||
// Node's closed `exports` map throws ERR_PACKAGE_PATH_NOT_EXPORTED for any
|
||||
// unlisted subpath — omit "./package.json" here (as in the published pkg)
|
||||
// and the scanner swallows the throw, so the browser half never registers.
|
||||
const shimRequire = createRequire(path.join(home, "probe.cjs"));
|
||||
assert.equal(shimRequire.resolve("billion-context/package.json"), path.join(shimDir, "package.json"));
|
||||
|
||||
// A shim whose root "." export points elsewhere (e.g. a real install
|
||||
// whose root is the CLI entry, not the dsh host half) must NOT claim
|
||||
// the bare lane: importing the root would boot the CLI inside dsh.
|
||||
|
||||
@@ -94,14 +94,14 @@ entries:
|
||||
site_zh: "强制摘要从首次起走流式(SSE)——要求流式的上游现在通过任何非流式 400 上的一次性 SSE 探测自愈(#2494);保留作为会掐断长非流式调用的网关(如 Cloudflare 524)的逃生通道(自学习无法感知该场景),也可用于省去一次探测往返。"
|
||||
- key: compress.preserveRecentMessages
|
||||
type: number
|
||||
default: "kernel ≈5"
|
||||
default: "3"
|
||||
group: compress
|
||||
id: cw.prm
|
||||
render: compress-row
|
||||
desc_en: "The most recent messages stay soft-protected from folds."
|
||||
desc_zh: "最近的消息软保护、免于折叠。"
|
||||
site_en: "Kernel default ≈5: the most recent messages stay soft-protected from folds."
|
||||
site_zh: "内核默认约 5:最近消息软保护、免于折叠。"
|
||||
site_en: "Kernel default 3 (tuned 5 → 3, #3058): the most recent messages stay soft-protected from folds."
|
||||
site_zh: "内核默认 3(5 → 3,#3058):最近消息软保护、免于折叠。"
|
||||
- key: compress.preserveRecentTokens
|
||||
type: number
|
||||
default: "kernel ≈5000"
|
||||
|
||||
@@ -127,10 +127,10 @@ entries:
|
||||
group: diagnostics
|
||||
id: tt.ccx
|
||||
site_group: adv
|
||||
desc_en: "Handle Codex's explicit compaction requests (compaction_trigger + /responses/compact) inside bili (intercept, default) or forward them upstream (pass); codex's client-side auto-compaction never transits the proxy — detected + rebased post-hoc (#2372)."
|
||||
desc_zh: "在 bili 内处理 Codex 的显式压缩请求(compaction_trigger + /responses/compact,intercept,默认)还是转给上游(pass);codex 的客户端自动压缩不过代理 —— 事后检测 + rebase(#2372)。"
|
||||
site_en: "<code>codexCompact</code> — intercept | pass (default intercept): handle Codex's explicit compaction requests inside bili or forward upstream; client-side auto-compaction never transits the proxy (#2372)."
|
||||
site_zh: "<code>codexCompact</code> —— intercept | pass(默认 intercept):在 bili 内处理 Codex 显式压缩请求或转给上游;客户端自动压缩不过代理(#2372)。"
|
||||
desc_en: "Handle Codex's compaction requests inside bili (intercept, default) or forward them upstream (pass): the explicit forms (compaction_trigger + /responses/compact) and the inline auto-compact that transits as an ordinary turn, detected by its SUMMARIZATION_PROMPT template (#3008) — a user-overridden compact_prompt falls out of detection and transits verbatim; a compaction bili only observed (pass/gate) is rebased post-hoc (#2372)."
|
||||
desc_zh: "在 bili 内处理 Codex 的压缩请求(intercept,默认)还是转给上游(pass):覆盖显式形态(compaction_trigger + /responses/compact)与以普通请求形态过线的内联自动压缩(按 SUMMARIZATION_PROMPT 模板检测,#3008)—— 用户自定义 compact_prompt 后锚点失配、按原样转发;bili 仅旁路观察到的压缩(pass/安全阀放行)走事后 rebase(#2372)。"
|
||||
site_en: "<code>codexCompact</code> — intercept | pass (default intercept): handle Codex's compaction requests in bili or forward upstream — explicit forms plus the inline auto-compact transiting as an ordinary turn (prompt-form detection, #3008; overridden compact_prompt transits verbatim)."
|
||||
site_zh: "<code>codexCompact</code> —— intercept | pass(默认 intercept):在 bili 内处理 Codex 压缩请求或转给上游 —— 显式形态 + 以普通请求形态过线的内联自动压缩(prompt 文本检测,#3008;自定义 compact_prompt 按原样转发)。"
|
||||
- key: ccrRetrievalTtlMs
|
||||
type: number
|
||||
default: "600000 (0 disables retrieval)"
|
||||
|
||||
@@ -187,7 +187,7 @@ qwen / mcode / aider / copilot / amp / goose (full list: bili --help)</code
|
||||
<tr><td class="mono">nudgeModelDecided</td><td class="mech">boolean</td><td data-i18n="cw.nmd">Model-decided nudge timing (off by default): an armed tier-1 nudge first asks the model, over the session's cached prefix, whether compressing now helps the current task; a strict-JSON yes injects a directive with a program-finalized span, anything else injects nothing this round.</td></tr>
|
||||
<tr><td class="mono">nudgeDecisionMaxTokens</td><td class="mech">number</td><td data-i18n="cw.ndmt">Output budget (tokens) of the model-decision side call (default 200). Must be > 0.</td></tr>
|
||||
<tr><td class="mono">streamSummary</td><td class="mech">boolean</td><td data-i18n="cw.ssm">Force streaming (SSE) summarization from the first attempt — stream-mandating upstreams now self-heal via a one-shot SSE probe on any non-streaming 400 (#2494); kept as the escape hatch for gateways that time out long non-streaming calls (e.g. Cloudflare 524), which the self-learn cannot detect, or to skip the one probe round-trip.</td></tr>
|
||||
<tr><td class="mono">preserveRecentMessages</td><td class="mech">number</td><td data-i18n="cw.prm">Kernel default ≈5: the most recent messages stay soft-protected from folds.</td></tr>
|
||||
<tr><td class="mono">preserveRecentMessages</td><td class="mech">number</td><td data-i18n="cw.prm">Kernel default 3 (tuned 5 → 3, #3058): the most recent messages stay soft-protected from folds.</td></tr>
|
||||
<tr><td class="mono">preserveRecentTokens</td><td class="mech">number</td><td data-i18n="cw.prt">Kernel default ≈5000: the most recent tokens stay soft-protected from folds.</td></tr>
|
||||
<tr><td class="mono">minCompressRangeChars</td><td class="mech">number (deprecated alias: minCompressRange)</td><td data-i18n="cw.mrc">Smallest foldable range, in characters (kernel default ≈5000) — shorter ranges never fold.</td></tr>
|
||||
<tr><td class="mono">reconcile</td><td class="mech">"off" | "warn" | "repair"</td><td data-i18n="cw.rec">"off" | "warn" | "repair" (default repair): reconcile folded state when the client rewinds or rewrites history between turns.</td></tr>
|
||||
@@ -291,7 +291,7 @@ qwen / mcode / aider / copilot / amp / goose (full list: bili --help)</code
|
||||
<li data-i18n-html="tt.advisory"><code>advisoryCheck</code> / <code>advisoryUrl</code> — critical-defect advisory watcher (on by default; force-installs the recommended fix when your version is affected).</li>
|
||||
<li data-i18n-html="tt.rnotes"><code>releaseNotesCheck</code> / <code>releaseNotesUrl</code> — release-notes feed for the panel (on by default; fetch + cache only, never installs).</li>
|
||||
<li class="tg" data-i18n-html="tg.adv"><strong>Advanced scalars</strong></li>
|
||||
<li data-i18n-html="tt.ccx"><code>codexCompact</code> — intercept | pass (default intercept): handle Codex's explicit compaction requests inside bili or forward upstream; client-side auto-compaction never transits the proxy (#2372).</li>
|
||||
<li data-i18n-html="tt.ccx"><code>codexCompact</code> — intercept | pass (default intercept): handle Codex's compaction requests in bili or forward upstream — explicit forms plus the inline auto-compact transiting as an ordinary turn (prompt-form detection, #3008; overridden compact_prompt transits verbatim).</li>
|
||||
<li data-i18n-html="ttl.ttl"><code>ccrRetrievalTtlMs</code> — lifetime of CCR retrieval pointers (default 600000; 0 disables retrieval).</li>
|
||||
<li data-i18n-html="ttl.tmp"><code>decompressTmpCap</code> — size cap for temporary decompressed blocks (default 50).</li>
|
||||
<li data-i18n-html="tt.nat"><code>native.attachExternal</code> — let launcher-less native plugins attach to an external daemon (off by default).</li>
|
||||
|
||||
+4
-4
@@ -70,7 +70,7 @@
|
||||
"cw.nmd": "Model-decided nudge timing (off by default): an armed tier-1 nudge first asks the model, over the session's cached prefix, whether compressing now helps the current task; a strict-JSON yes injects a directive with a program-finalized span, anything else injects nothing this round.",
|
||||
"cw.ndmt": "Output budget (tokens) of the model-decision side call (default 200). Must be > 0.",
|
||||
"cw.ssm": "Force streaming (SSE) summarization from the first attempt — stream-mandating upstreams now self-heal via a one-shot SSE probe on any non-streaming 400 (#2494); kept as the escape hatch for gateways that time out long non-streaming calls (e.g. Cloudflare 524), which the self-learn cannot detect, or to skip the one probe round-trip.",
|
||||
"cw.prm": "Kernel default ≈5: the most recent messages stay soft-protected from folds.",
|
||||
"cw.prm": "Kernel default 3 (tuned 5 → 3, #3058): the most recent messages stay soft-protected from folds.",
|
||||
"cw.prt": "Kernel default ≈5000: the most recent tokens stay soft-protected from folds.",
|
||||
"cw.mrc": "Smallest foldable range, in characters (kernel default ≈5000) — shorter ranges never fold.",
|
||||
"cw.rec": "\"off\" | \"warn\" | \"repair\" (default repair): reconcile folded state when the client rewinds or rewrites history between turns.",
|
||||
@@ -119,7 +119,7 @@
|
||||
"tg.adv": "<strong>Advanced scalars</strong>",
|
||||
"tt.diag": "<code>diagnostics</code> — local troubleshooting knobs: <span class='mech'>dumpBody false · dumpReq true · rawDumpDir · dump4xx false (+MaxBytes 2 MiB) · renderNone/noInjectTool/noCompressPrompt false · countTokensPassthrough false · compressProtocol \"tools\"</span>.",
|
||||
"tt.fake": "<code>fakeCompletion</code> — retry loop for truncated final chunks: <span class='mech'>retries 0 (opt-in) · bufCapBytes 16 MiB</span>.",
|
||||
"tt.ccx": "<code>codexCompact</code> — intercept | pass (default intercept): handle Codex's explicit compaction requests inside bili or forward upstream; client-side auto-compaction never transits the proxy (#2372).",
|
||||
"tt.ccx": "<code>codexCompact</code> — intercept | pass (default intercept): handle Codex's compaction requests in bili or forward upstream — explicit forms plus the inline auto-compact transiting as an ordinary turn (prompt-form detection, #3008; overridden compact_prompt transits verbatim).",
|
||||
"ttl.ttl": "<code>ccrRetrievalTtlMs</code> — lifetime of CCR retrieval pointers (default 600000; 0 disables retrieval).",
|
||||
"ttl.tmp": "<code>decompressTmpCap</code> — size cap for temporary decompressed blocks (default 50).",
|
||||
"tt.network": "<code>network</code> — transport timeouts & replays: <span class='mech'>upstreamTimeoutMs 720000 · requestWatchdogMs 2× · replayRetryMax 3 · replayRetryBaseMs 1500 · keepAliveTimeoutMs 5000 · clientErrorBackstopMs 30000 · exposureLogIntervalMs 3600000 · streamKeepAliveMs 15000 · preflightHoldMs 30000 · preflightDeadEndCooldownMs 300000 · proxyKeepAliveMaxMs 55000</span>.",
|
||||
@@ -306,7 +306,7 @@
|
||||
"cw.nmd": "模型自决的压缩时机(默认关闭):tier-1 提醒触发时,先通过会话缓存前缀上的短 side call 问模型现在压缩是否划算;严格 JSON 的 yes 注入带程序最终确定范围的指令,其余情况本轮不注入。",
|
||||
"cw.ndmt": "模型决策 side call 的输出预算(token,默认 200)。必须 > 0。",
|
||||
"cw.ssm": "强制摘要从首次起走流式(SSE)——要求流式的上游现在通过任何非流式 400 上的一次性 SSE 探测自愈(#2494);保留作为会掐断长非流式调用的网关(如 Cloudflare 524)的逃生通道(自学习无法感知该场景),也可用于省去一次探测往返。",
|
||||
"cw.prm": "内核默认约 5:最近消息软保护、免于折叠。",
|
||||
"cw.prm": "内核默认 3(5 → 3,#3058):最近消息软保护、免于折叠。",
|
||||
"cw.prt": "内核默认约 5000:最近的 token 软保护、免于折叠。",
|
||||
"cw.mrc": "可折叠片段的最小字符数(内核默认约 5000),更短的永不折叠。",
|
||||
"cw.rec": "\"off\" | \"warn\" | \"repair\"(默认 repair):客户端在轮次之间回退或改写历史时校准已折叠状态。",
|
||||
@@ -355,7 +355,7 @@
|
||||
"tg.adv": "<strong>高级标量</strong>",
|
||||
"tt.diag": "<code>diagnostics</code> —— 本地排障旋钮:<span class='mech'>dumpBody false · dumpReq true · rawDumpDir · dump4xx false (+MaxBytes 2 MiB) · renderNone/noInjectTool/noCompressPrompt false · countTokensPassthrough false · compressProtocol \"tools\"</span>。",
|
||||
"tt.fake": "<code>fakeCompletion</code> —— 被截断末块的补完成重试环:<span class='mech'>retries 0 (可选) · bufCapBytes 16 MiB</span>。",
|
||||
"tt.ccx": "<code>codexCompact</code> —— intercept | pass(默认 intercept):在 bili 内处理 Codex 显式压缩请求或转给上游;客户端自动压缩不过代理(#2372)。",
|
||||
"tt.ccx": "<code>codexCompact</code> —— intercept | pass(默认 intercept):在 bili 内处理 Codex 压缩请求或转给上游 —— 显式形态 + 以普通请求形态过线的内联自动压缩(prompt 文本检测,#3008;自定义 compact_prompt 按原样转发)。",
|
||||
"ttl.ttl": "<code>ccrRetrievalTtlMs</code> —— CCR 回取指针有效期(默认 600000;0 禁用回取)。",
|
||||
"ttl.tmp": "<code>decompressTmpCap</code> —— 临时展开块的大小上限(默认 50)。",
|
||||
"tt.network": "<code>network</code> —— 传输超时与重放:<span class='mech'>upstreamTimeoutMs 720000 · requestWatchdogMs 2× · replayRetryMax 3 · replayRetryBaseMs 1500 · keepAliveTimeoutMs 5000 · clientErrorBackstopMs 30000 · exposureLogIntervalMs 3600000 · streamKeepAliveMs 15000 · preflightHoldMs 30000 · preflightDeadEndCooldownMs 300000 · proxyKeepAliveMaxMs 55000</span>。",
|
||||
|
||||
Reference in New Issue
Block a user