@logictan/dsh-verbatim-compaction 0.5.0 → 0.5.1
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 +3 -1
- package/lib/index.js +11 -2
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -59,7 +59,9 @@
|
|
|
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)`;正文为空的 slot 会显式带上 `ASKED: omit — this turn produced no assistant prose`,因为那一轮有 96 条助手消息、150 次工具调用却只有 156 字符正文,模型无米可炊就只好改写用户请求。实测 123 条真人消息里 43 条(35%)不超过 12 个字符——`3`、`1`、`同意`、`做`、`继续`——而 46% 是在回答上一轮助手的提问。只逐字保留「3」而不保留它在回答什么问题,等于记下一个决定却没记下决定的是什么。
|
|
63
65
|
|
|
64
66
|
模型用的是会话自己的路由(`session.requestHeader()?.config`),和宿主原生压缩同一个取法,不需要单独配置凭据。
|
|
65
67
|
|
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',
|
|
@@ -710,9 +712,16 @@ export function buildExtractionMaterial(turn, prose) {
|
|
|
710
712
|
const hints = collectHints(turn);
|
|
711
713
|
if (userRequest.length === 0 && prose.length === 0 && hints.length === 0)
|
|
712
714
|
return '';
|
|
715
|
+
// Say it explicitly when there is no prose. A turn with 150 tool calls and 156
|
|
716
|
+
// characters of prose gives the model nothing to quote, and a real run filled
|
|
717
|
+
// Asked with a translation of the user request instead of omitting it.
|
|
718
|
+
const asked = prose.length === 0
|
|
719
|
+
? 'ASKED: omit — this turn produced no assistant prose, so it asked the user nothing'
|
|
720
|
+
: 'ASKED: record only what the assistant asked the user';
|
|
713
721
|
return [
|
|
714
|
-
`USER
|
|
722
|
+
`USER INSTRUCTION (already in the digest verbatim; never copy it into Asked):\n${userRequest.slice(0, 4000) || '(none)'}`,
|
|
715
723
|
`ASSISTANT PROSE:\n${prose.slice(0, 6000) || '(none)'}`,
|
|
724
|
+
asked,
|
|
716
725
|
`TOOL TRACE:\n${hints || '(none)'}`,
|
|
717
726
|
].join('\n\n');
|
|
718
727
|
}
|
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.1",
|
|
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",
|