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
4 changes: 2 additions & 2 deletions kernel/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion kernel/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "acp-kernel",
"version": "0.0.187",
"version": "0.0.189",
"description": "Framework-agnostic context-compression engine (model-driven, 3-tier LSM). Pure core: no host dependency.",
"license": "MIT",
"author": "ranxianglei",
Expand Down
185 changes: 142 additions & 43 deletions kernel/src/relocate-compress.ts

Large diffs are not rendered by default.

280 changes: 178 additions & 102 deletions kernel/tests/relocate-compress.test.ts

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -663,7 +663,9 @@ export type CompressSettings = {
* and state are untouched; identical layout is recomputed every turn.
* Env BILI_COMPRESS_AT_FOLD_POINT wins over every level;
* applyCompressSettings resolves it per request. Maps to kernel
* Config.compressAtFoldPoint (acp-kernel >= 0.0.177). */
* Config.compressAtFoldPoint (acp-kernel >= 0.0.177; v2 semantics since
* 0.0.188 — summary text relocated to the fold point, pair kept in slot
* with pointer args). */
compressAtFoldPoint?: boolean;
/** Second opt-in riding on compressAtFoldPoint (default OFF): also drop
* the contiguous run of UNSIGNED reasoning cores immediately preceding a
Expand Down
5 changes: 3 additions & 2 deletions src/plugin-render.ts
Original file line number Diff line number Diff line change
Expand Up @@ -136,8 +136,9 @@ export async function handlePluginRender(req: http.IncomingMessage, res: http.Se
// Fold-point carrier relocation mirror (switch A): with the knob on, move
// still-visible compress pairs from their original slot to their fold point
// — the same view-only transform the kernel node applies on processTurn,
// so the rendered prefix and steady turns agree. S4 has no per-request
// strictness context, so move-only (no thinking clear here).
// so the rendered prefix and steady turns agree (v2: summary text relocated
// to the fold point, pair kept in slot with pointer args). S4 has no
// per-request strictness context, so no thinking clear here.
// KNOWN ASYMMETRY (v1, #5470 review): the knob is read from env + the
// global `compress` file section only, while steady turns resolve through
// the full cascade — a key set at a provider/model tier moves pairs on
Expand Down
10 changes: 6 additions & 4 deletions src/server/relay.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2262,10 +2262,12 @@ async function forwardCaptured(
// against them drops the only cross-turn summary carrier and breaks the byte-prefix
// at the fold anchor (post-fold cache floor reset to the stable head).
const outBase = [...stripKernelSummaries(viewed as BiliMessage[], turn.state), ...(records as BiliMessage[])] as BiliMessage[];
// Fold-point carrier relocation round-2 mirror (switch A): with the
// switch on, pairs sit at their fold point instead of being
// tail-appended onto the re-request. Idempotent when processTurn's
// node already moved them (view-only + deterministic transform).
// Fold-point summary relocation round-2 mirror (switch A): with
// the switch on, each still-visible compress pair keeps its
// chronological slot but its SUMMARY TEXT is re-emitted at its
// fold point (call args become a pointer — v2 semantics).
// Idempotent when processTurn's node already relocated them
// (view-only + deterministic transform).
const out = loopConfig.compressAtFoldPoint
? relocateCompressCarriers(outBase as unknown as CoreMessage[], turn.state, {
isCompressTool: loopConfig.isCompressTool,
Expand Down
8 changes: 4 additions & 4 deletions src/web/i18n.ts
Original file line number Diff line number Diff line change
Expand Up @@ -578,8 +578,8 @@ export const MESSAGES: Record<Locale, Record<string, string>> = {
"cfg.q_dsh_ctxtab_label": "DSH「上下文」标签页名称(dsh.contextTabLabel)——留空用内置名「上下文」,可改名避免与其他插件重名",
"cfg.q_absorb": "工具结果即时蒸馏(absorb)——大工具结果到达时由模型即时蒸馏,原文隐藏到下一轮折叠前(默认关)",
"cfg.q_absorb_hint": "默认只吸含图结果(#3422);mediaOnly: false 可恢复吸全文。子项(minToolTokens、contextThresholdPct、excludeTools)请在下方 JSON 编辑框写",
"cfg.q_cafp": "压缩折叠是否原位置替换(compressAtFoldPoint,默认关)——把折叠产生的 compress 调用对放到它自己的折叠点处替换,而不是留在历史尾部",
"cfg.q_cafp_hint": "针对 qwen3-27b 这类注意力机制有问题的小模型很有用:避免模型把历史尾部的工具交换误读成新命令;取消勾选 = 回到旧版布局(字节级一致)。可选的“清未签名思考”开关(clearThinking)只能走 env / JSON",
"cfg.q_cafp": "压缩摘要前置到折叠点(compressAtFoldPoint,默认关)——把每次压缩产生的摘要文本以纯文本形式放到它描述的折叠点处,原 compress 调用对留在原时间位置、参数替换成指针,不再是可执行的完整压缩命令",
"cfg.q_cafp_hint": "针对 qwen3-27b 这类注意力机制有问题的小模型很有用:避免历史中部一整墙“完整形状”的 compress 交互被误读成继续压缩的示范/新命令;取消勾选 = 回到旧版布局(字节级一致)。可选的“清未签名思考”开关(clearThinking)只能走 env / JSON",
"cfg.q_require_nudge": "禁止未提示压缩(compress.requireNudge)——只在 bili 实际注入压缩提醒的同一轮允许模型调用 compress,其余一律拒绝并回错误回执(默认关)",
"cfg.q_require_nudge_hint": "针对会自行乱压的模型(如 qwen 27b)。bili 自己的溢出兜底折叠不受影响;也可只对特定 provider/model 开启(JSON 编辑框)",
"cfg.q_require_rec": "禁止越界压缩(compress.requireRecommendation)——只允许压缩 bili 当前推荐的范围,越界即拒(默认关)",
Expand Down Expand Up @@ -1324,8 +1324,8 @@ export const MESSAGES: Record<Locale, Record<string, string>> = {
"cfg.q_dsh_ctxtab_label": "Label of the DSH Context tab (dsh.contextTabLabel) — empty keeps the built-in name \"Context\"; rename to avoid clashing with another plugin's tab",
"cfg.q_absorb": "Instant tool-result absorption (absorb) — large tool results are distilled by the model on arrival; originals hidden until the next fold round (default off)",
"cfg.q_absorb_hint": "by default only image-bearing results are absorbed (#3422); set mediaOnly: false to absorb full text. Sub-fields (minToolTokens, contextThresholdPct, excludeTools) go in the JSON editor below",
"cfg.q_cafp": "Fold replacement in place (compressAtFoldPoint, default off) — the fold's compress call/result pair replaces the region at its own fold point instead of staying tail-adjacent",
"cfg.q_cafp_hint": "very useful for small models with attention issues such as qwen3-27b: stops them misreading the trailing tool exchange as a fresh command; uncheck = byte-identical legacy layout. The optional clear-thinking companion (clearThinking) stays env/JSON-only",
"cfg.q_cafp": "Summary text relocated to the fold point (compressAtFoldPoint, default off) — each fold's summary text is re-emitted as plain text at the fold point it describes, while the compress call/result pair keeps its chronological slot with its args replaced by a pointer (no longer a fully-shaped compress command)",
"cfg.q_cafp_hint": "very useful for small models with attention issues such as qwen3-27b: stops a mid-history wall of fully-shaped compress interactions from reading as an invitation to keep compressing; uncheck = byte-identical legacy layout. The optional clear-thinking companion (clearThinking) stays env/JSON-only",
"cfg.q_require_nudge": "Forbid unprompted compression (compress.requireNudge) — compress may only be called in a round where a nudge was actually injected; anything else is refused with an error receipt (default off)",
"cfg.q_require_nudge_hint": "for models that fold on their own (e.g. qwen 27b). bili's own overflow backstop folds are unaffected; can also be scoped per provider/model in the JSON editor",
"cfg.q_require_rec": "Forbid out-of-bounds compression (compress.requireRecommendation) — only ranges bili currently recommends may be folded; anything else is refused (default off)",
Expand Down
Loading