@logictan/dsh-verbatim-compaction 0.5.0 → 0.5.2
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/README.md +5 -1
- package/lib/index.js +4 -2
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -59,7 +59,11 @@
|
|
|
59
59
|
|
|
60
60
|
空节直接删掉,不留 `(none)` 占位。实测一份真实提取块里 `## Asked` 和 `## Overturned` 都是 `(none)`,删掉后 312 → 271 字符;按 130 轮算,这些占位合计约 900 token 只是在记录「什么都没发生」。清理在代码里做(`pruneEmptySections`),不只依赖提示词——模型仍写了 `(none)` 也不会白花 token。判据是整节每一行去掉项目符号后都只是 `(none)` / `none` / `n/a` / `无` 之类的占位;`none of the tests passed`、`无法连接,改用代理` 这类真内容照原样保留。
|
|
61
61
|
|
|
62
|
-
`## Asked`
|
|
62
|
+
`## Asked` 记的是「**助手**向**用户**提了什么、给了哪些选项」。这一节最容易错成「把用户请求改写一遍」——真实一次压缩里,模型把用户那段中文请求翻成英文塞进了 `Asked`,而用户原话就在它上面逐字抄着,同一件事写了两遍。
|
|
63
|
+
|
|
64
|
+
原因之一在材料标签:原来写 `USER REQUEST:`,模型有理由读成「这一轮问了什么」,现在改成 `USER INSTRUCTION (already in the digest verbatim; never copy it into Asked)`。另一部分靠指令本身——`## Asked` 的定义写明「助手问、用户答」,并注明照抄用户请求是这一节最常见的出错方式。
|
|
65
|
+
|
|
66
|
+
正文为空的轮次(那个真实案例有 96 条助手消息、150 次工具调用却只有 156 字符正文)本来就没有提问可记,`## Asked` 和 `## Did` 一样走 `pruneEmptySections` 整节省略,不需要单独规则。实测 123 条真人消息里 43 条(35%)不超过 12 个字符——`3`、`1`、`同意`、`做`、`继续`——而 46% 是在回答上一轮助手的提问。只逐字保留「3」而不保留它在回答什么问题,等于记下一个决定却没记下决定的是什么。
|
|
63
67
|
|
|
64
68
|
模型用的是会话自己的路由(`session.requestHeader()?.config`),和宿主原生压缩同一个取法,不需要单独配置凭据。
|
|
65
69
|
|
package/lib/index.js
CHANGED
|
@@ -207,7 +207,9 @@ const EXTRACT_INSTRUCTION = [
|
|
|
207
207
|
'For EVERY item, emit exactly one block, introduced by `=== SLOT <key> ===` using that same key. Under each heading write at most two terse lines. OMIT a heading entirely when it has no real information — do not write "(none)" and do not invent. An item where nothing substantive happened may be omitted altogether.',
|
|
208
208
|
'',
|
|
209
209
|
'## Asked',
|
|
210
|
-
'- the
|
|
210
|
+
'- what the ASSISTANT asked the USER in this turn: the question it put, and the options it offered',
|
|
211
|
+
'- the next user message is usually the answer, so record the question, never the answer',
|
|
212
|
+
'- NEVER restate or translate the user request here. It is already in the digest verbatim, directly above this block; copying it is the single most common way this section goes wrong.',
|
|
211
213
|
'',
|
|
212
214
|
'## Did',
|
|
213
215
|
'- what was actually done, concretely',
|
|
@@ -711,7 +713,7 @@ export function buildExtractionMaterial(turn, prose) {
|
|
|
711
713
|
if (userRequest.length === 0 && prose.length === 0 && hints.length === 0)
|
|
712
714
|
return '';
|
|
713
715
|
return [
|
|
714
|
-
`USER
|
|
716
|
+
`USER INSTRUCTION (already in the digest verbatim; never copy it into Asked):\n${userRequest.slice(0, 4000) || '(none)'}`,
|
|
715
717
|
`ASSISTANT PROSE:\n${prose.slice(0, 6000) || '(none)'}`,
|
|
716
718
|
`TOOL TRACE:\n${hints || '(none)'}`,
|
|
717
719
|
].join('\n\n');
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@logictan/dsh-verbatim-compaction",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.2",
|
|
4
4
|
"description": "Deterministic compaction backend that keeps conversation prose verbatim in the checkpoint instead of re-summarizing it: user and assistant text survive word for word, tool results collapse to one-line pointers, reasoning is never read, and no model call is made.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "lib/index.js",
|