dsh-lean-router 2.2.7 → 2.2.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/docs/changelog.en.md +12 -1
- package/docs/changelog.md +12 -1
- package/lib/lean/history-budget.js +8 -2
- package/package.json +1 -1
- package/test/history-budget.test.mjs +5 -3
package/docs/changelog.en.md
CHANGED
|
@@ -1,6 +1,17 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
-
> English version of [changelog.md](./changelog.md). Versions follow package.json (currently 2.2.
|
|
3
|
+
> English version of [changelog.md](./changelog.md). Versions follow package.json (currently 2.2.8).
|
|
4
|
+
|
|
5
|
+
## 2.2.8 (2026-11-30)
|
|
6
|
+
|
|
7
|
+
### Fixed
|
|
8
|
+
|
|
9
|
+
- **history_budget threshold lowered from 12000 to 4000**: reading a real session back showed the 12000 threshold introduced in 2.2.4 **never fired** — the host's `tool-result-pruner` first compresses any tool result over 8192 characters into 4096 + marker + 1024 = 5159 characters. On the live session surface, 183 of 204 tool results were already under 200 characters and the largest was exactly 5159, so nothing could ever reach 12000. At 4000 (head 2400 + tail 1600, 400-character tail floor unchanged) this module now runs before the host pruner. A measured 41889-character sample collapses to 4000 (-90.5%).
|
|
10
|
+
- Recorded as a hard constraint: after shipping any size-cap optimization, read a real session back and confirm the number of **times it fired**; a passing unit test is not evidence that it took effect.
|
|
11
|
+
|
|
12
|
+
### Tests
|
|
13
|
+
|
|
14
|
+
- 269 tests, 268 passing, 0 failing, 1 skipped; `verify` passes.
|
|
4
15
|
|
|
5
16
|
## 2.2.7 (2026-11-30)
|
|
6
17
|
|
package/docs/changelog.md
CHANGED
|
@@ -1,6 +1,17 @@
|
|
|
1
1
|
# 变更记录(changelog)
|
|
2
2
|
|
|
3
|
-
> 中文为主,英文版:[changelog.en.md](./changelog.en.md)。版本号遵循 package.json(当前 2.2.
|
|
3
|
+
> 中文为主,英文版:[changelog.en.md](./changelog.en.md)。版本号遵循 package.json(当前 2.2.8)。
|
|
4
|
+
|
|
5
|
+
## 2.2.8 (2026-11-30)
|
|
6
|
+
|
|
7
|
+
### 修复
|
|
8
|
+
|
|
9
|
+
- **history_budget 阈值从 12000 下调到 4000**:真机回读发现 2.2.4 引入的 12000 阈值**从未触发过**——宿主的 `tool-result-pruner` 会先把超过 8192 字符的工具结果压成 4096 + 标记 + 1024 = 5159 字符,实测当前会话表面上 204 条工具结果里 183 条已短于 200 字符、最大正好 5159,没有任何一条能超过 12000。降到 4000(头 2400 + 尾 1600,尾部下限 400 不变)后,本模块才会先于宿主生效。实测 41889 字符样本压到 4000(-90.5%)。
|
|
10
|
+
- 这个教训登记为硬约束:体积上限类优化上线后必须回读真实会话确认**触发次数**,不得以单测通过代替生效验证。
|
|
11
|
+
|
|
12
|
+
### 测试
|
|
13
|
+
|
|
14
|
+
- 全量 269 项、268 通过、0 失败、1 skip,verify 全 PASS。
|
|
4
15
|
|
|
5
16
|
## 2.2.7 (2026-11-30)
|
|
6
17
|
|
|
@@ -32,8 +32,14 @@
|
|
|
32
32
|
// 零依赖、同步、纯函数:不读会话、不碰宿主上下文,可脱离宿主单测。
|
|
33
33
|
// 注意:本模块只产出「模型可见文本」,值的处理在其调用方(lib/toolface/executor.js)。
|
|
34
34
|
|
|
35
|
-
/**
|
|
36
|
-
|
|
35
|
+
/**
|
|
36
|
+
* 默认体积预算(字符数,按 UTF-16 code unit 计,与 String#length 同口径)。
|
|
37
|
+
*
|
|
38
|
+
* 必须**低于**宿主 `tool-result-pruner` 的 8192 阈值,否则永远轮不到本模块生效:
|
|
39
|
+
* 宿主会先把超 8192 的结果压成 4096 + marker + 1024 = 5159 字符。实测(GT-27/GT-28)
|
|
40
|
+
* 在 12000 阈值下本模块一次都没触发过,表面上工具结果最大正好 5159。
|
|
41
|
+
*/
|
|
42
|
+
export const HISTORY_BUDGET_CHARS = 4000;
|
|
37
43
|
|
|
38
44
|
/** 头部保留比例:0.6。 */
|
|
39
45
|
export const HEAD_RATIO = 0.6;
|
package/package.json
CHANGED
|
@@ -12,7 +12,7 @@ import {
|
|
|
12
12
|
} from "../lib/lean/history-budget.js";
|
|
13
13
|
|
|
14
14
|
// ===== 公共样例 =====
|
|
15
|
-
// 2000 行 × 约 63 字符 ≈ 126k 字符:远超默认预算
|
|
15
|
+
// 2000 行 × 约 63 字符 ≈ 126k 字符:远超默认预算 4000,且每行都不同,
|
|
16
16
|
// 因此 output-slim 的「相邻重复行折叠」对它无效——这正是 budget 要处理的形状。
|
|
17
17
|
|
|
18
18
|
/** 一行普通输出(刻意不含任何错误 / 路径关键字)。 */
|
|
@@ -31,8 +31,10 @@ function elidedCount(text) {
|
|
|
31
31
|
return match === null ? null : Number(match[1]);
|
|
32
32
|
}
|
|
33
33
|
|
|
34
|
-
|
|
35
|
-
|
|
34
|
+
// 4000 是硬性下界选择:必须低于宿主 tool-result-pruner 的 8192,否则永远不会先于宿主触发
|
|
35
|
+
// (实测 12000 阈值下一次都没触发过)。改这个数字前先回读真实会话确认触发次数。
|
|
36
|
+
test("预算与标记的默认值:4000 字符、marker 带 {elided} 占位符", () => {
|
|
37
|
+
assert.equal(HISTORY_BUDGET_CHARS, 4000);
|
|
36
38
|
assert.ok(DEFAULT_MARKER_TEMPLATE.includes(ELIDED_PLACEHOLDER), "默认模板留了占位符");
|
|
37
39
|
assert.ok(/offset\/limit/.test(DEFAULT_MARKER_TEMPLATE), "marker 提示恢复方式");
|
|
38
40
|
});
|