Skip to content

Commit cbf6c0f

Browse files
committed
feat(summarize): 蒸馏思考强度设置项 summarizeReasoningEffort(#315)
- 新增配置键 summarizeReasoningEffort(off/low/medium/high/none,默认 none = 不发送字段,行为不变),settings 白名单注册 - 思考型模型蒸馏时推理烧光输出预算 → 总结空/截断(#9 同款失败面), off/low 封顶推理 - 档位被拒收时去掉字段重试一次:复用 dream 的 withEffortFallback, 拒收判别式提为导出常量 EFFORT_REJECT_RE 单一来源;蒸馏流失败以 aborted 结果返回,effort 型失败折叠成 undefined 走既有甄别分支 - 面板:自动总结行下新增档位下拉(opt-in 语义对齐实体抽取),i18n 中英成对 - 回归 +5(test/summarize-reasoning-effort.test.js);api.test.js effective 计数锁同步;双 README 徽章 1384→1389
1 parent 38fdbfa commit cbf6c0f

15 files changed

Lines changed: 337 additions & 24 deletions

‎README.md‎

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@
1010
<a href="LICENSE"><img src="https://img.shields.io/badge/license-MIT-3E63DD?style=flat-square" alt="license"></a>
1111
<a href="https://github.com/slow-stack/mneme/actions"><img src="https://img.shields.io/github/actions/workflow/status/slow-stack/mneme/ci.yml?style=flat-square&label=CI" alt="CI"></a>
1212
<a href="https://nodejs.org"><img src="https://img.shields.io/badge/node-22%2B-3E63DD?style=flat-square&logo=nodedotjs&logoColor=white" alt="node"></a>
13-
<a href="https://github.com/slow-stack/mneme"><img src="https://img.shields.io/badge/tests-1370%20passed-3E63DD?style=flat-square" alt="tests"></a>
14-
<a href="https://github.com/slow-stack/mneme"><img src="https://img.shields.io/badge/tests-1370%20passed-3E63DD?style=flat-square" alt="tests"></a>
13+
<a href="https://github.com/slow-stack/mneme"><img src="https://img.shields.io/badge/tests-1389%20passed-3E63DD?style=flat-square" alt="tests"></a>
14+
<a href="https://github.com/slow-stack/mneme"><img src="https://img.shields.io/badge/tests-1389%20passed-3E63DD?style=flat-square" alt="tests"></a>
1515
<a href="https://codecov.io/gh/slow-stack/mneme"><img src="https://img.shields.io/codecov/c/github/slow-stack/mneme/main?style=flat-square" alt="coverage"></a>
1616
<a href="https://github.com/awesome-dsh-plugin/awesome-dsh-plugin"><img src="https://awesome-dsh-plugin.com/badge.svg" alt="Awesome"></a>
1717
</p>
@@ -183,8 +183,8 @@ dsh web
183183

184184
```bash
185185
cd dsh-mneme && npm install
186-
npm test # 1342 个测试
187-
npm test # 1342 个测试
186+
npm test # 1389 个测试
187+
npm test # 1389 个测试
188188
npm run stress # 三轴线压测
189189
npm run sync # src → lib 同步
190190
```
@@ -366,8 +366,8 @@ The plugin ships a zero-dependency stdio MCP server (standalone npm package **`m
366366

367367
```bash
368368
cd dsh-mneme && npm install
369-
npm test # 1342 tests
370-
npm test # 1342 tests
369+
npm test # 1389 tests
370+
npm test # 1389 tests
371371
npm run stress # three-axis stress test
372372
npm run sync # src → lib sync
373373
```

‎dsh-mneme/CHANGELOG.md‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,8 @@
7979

8080
## 🆕 新增
8181

82+
- **蒸馏思考强度设置项(issue #315)**:蒸馏(会话总结提炼)LLM 新增 `summarizeReasoningEffort`(`off`/`low`/`medium`/`high`/`none`,默认 `none` = 不发送字段、服务商默认生效,行为与此前一致)。思考型模型蒸馏时推理会烧光输出预算、总结为空或截断(#9 同款失败面,此前仅巩固/睡眠/实体抽取三链路有档位控制),配 `off`/`low` 可封顶推理。档位被模型拒收时自动去掉字段重试一次(与巩固/睡眠同一降级策略,`withEffortFallback` 共享、拒收判别式 `EFFORT_REJECT_RE` 提为单一来源);面板「功能开关 → 自动总结」下新增档位下拉(opt-in 语义与实体抽取 `entityExtractionReasoning` 对齐,settings 白名单注册)。新增回归 5 条(`test/summarize-reasoning-effort.test.js`)。
83+
8284
- **压缩边缘双落点(issue #249 N3)**:上下文即将被宿主压缩前抢救「正在做什么」,新增
8385
opt-in 键 `continuityRescueEnabled`(注入父开关 `autoInject` 的子项,默认关;`lightMode`
8486
强制关)。**必须是双落点**:①落一条连续性提案到新表 `continuity_proposals`(脱离对话

‎dsh-mneme/README.md‎

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
[![npm version](https://img.shields.io/npm/v/@modusensus/dsh-mneme?color=blue&label=npm)](https://www.npmjs.com/package/@modusensus/dsh-mneme)
66
[![license](https://img.shields.io/badge/license-MIT-green)](LICENSE)
77
[![Awesome](https://awesome-dsh-plugin.com/badge.svg)](https://github.com/awesome-dsh-plugin/awesome-dsh-plugin)
8-
[![tests](https://img.shields.io/badge/tests-1370%20passed-success)](https://github.com/slow-stack/mneme)
9-
[![tests](https://img.shields.io/badge/tests-1370%20passed-success)](https://github.com/slow-stack/mneme)
8+
[![tests](https://img.shields.io/badge/tests-1389%20passed-success)](https://github.com/slow-stack/mneme)
9+
[![tests](https://img.shields.io/badge/tests-1389%20passed-success)](https://github.com/slow-stack/mneme)
1010
[![CI](https://img.shields.io/github/actions/workflow/status/slow-stack/mneme/ci.yml)](https://github.com/slow-stack/mneme/actions)
1111
[![node](https://img.shields.io/badge/node-22%2B-blue)](https://nodejs.org)
1212
[![npm downloads](https://img.shields.io/npm/d18m/@modusensus/dsh-mneme.svg?color=blue&label=downloads)](https://www.npmjs.com/package/@modusensus/dsh-mneme)
@@ -582,8 +582,8 @@ src/
582582
├── api.js # HTTP 路由(Web 面板数据通道,含 /conflicts 冲突队列)
583583
└── index.js # 插件接线
584584
lib/ # src 的同步分发产物(npm run sync;发布前由 root prepack 的 check-sync.js 校验一致性;唯一手写例外 lib/client.js——Web 面板 bundle,sync 不覆盖)
585-
test/ # 1342 个 node:test 测试(审计与三轴线压测不变量;src↔lib 一致性由 scripts/check-sync.js 发布闸门校验)
586-
test/ # 1342 个 node:test 测试(审计与三轴线压测不变量;src↔lib 一致性由 scripts/check-sync.js 发布闸门校验)
585+
test/ # 1389 个 node:test 测试(审计与三轴线压测不变量;src↔lib 一致性由 scripts/check-sync.js 发布闸门校验)
586+
test/ # 1389 个 node:test 测试(审计与三轴线压测不变量;src↔lib 一致性由 scripts/check-sync.js 发布闸门校验)
587587
scripts/ # e2e-dsh.js 端到端演示 · stress-dsh.js 三轴线压测 · sync-lib.js 同步 · check-sync.js 发布闸门 · benchmark-recall.js / benchmark-embed.js / benchmark-rerank.js 基准 · sync-test-badge.mjs 测试徽章 · build-runtime-manifest.mjs 运行时清单
588588
```
589589
@@ -592,8 +592,8 @@ scripts/ # e2e-dsh.js 端到端演示 · stress-dsh.js 三轴线压
592592
```bash
593593
cd dsh-mneme
594594
npm install # 安装 peer 依赖(以 devDependencies 形式,用于本地测试)
595-
npm test # 运行 1342 个测试
596-
npm test # 运行 1342 个测试
595+
npm test # 运行 1389 个测试
596+
npm test # 运行 1389 个测试
597597
npm run stress # 三轴线压测:长会话检索 / 冲突仲裁 / 多 Agent 并发(离线 mock LLM)
598598
npm run sync # 把 src/ 同步到 lib/(发布时由 prepack 钩子自动执行)
599599
```

‎dsh-mneme/lib/client.js‎

Lines changed: 33 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -397,6 +397,12 @@ window.__ModuleLoader__.load({
397397
"memory.features.entityExtractionReasoning.low": "低",
398398
"memory.features.entityExtractionReasoning.medium": "中",
399399
"memory.features.entityExtractionReasoning.high": "高",
400+
"memory.features.summarizeReasoningEffort": "蒸馏思考强度",
401+
"memory.features.summarizeReasoningEffort.none": "跟随默认",
402+
"memory.features.summarizeReasoningEffort.low": "低",
403+
"memory.features.summarizeReasoningEffort.medium": "中",
404+
"memory.features.summarizeReasoningEffort.high": "高",
405+
"memory.features.summarizeReasoningEffort.hint": "思考型模型建议选低档,避免推理烧光输出预算导致总结失败;改后重启 DSH 生效",
400406
"memory.features.entityExtractionModelHint": "Provider/模型留空 = 跟随主对话模型;思考强度 none = 服务商默认",
401407
"memory.features.codingRetrospect": "编码记忆蒸馏",
402408
"memory.features.codingRetrospect.hint": "用完整转录(含工具调用与报错)提炼踩坑、约束与被否决方案",
@@ -787,6 +793,12 @@ window.__ModuleLoader__.load({
787793
"memory.features.entityExtractionReasoning.low": "Low",
788794
"memory.features.entityExtractionReasoning.medium": "Medium",
789795
"memory.features.entityExtractionReasoning.high": "High",
796+
"memory.features.summarizeReasoningEffort": "Distill reasoning effort",
797+
"memory.features.summarizeReasoningEffort.none": "Follow default",
798+
"memory.features.summarizeReasoningEffort.low": "Low",
799+
"memory.features.summarizeReasoningEffort.medium": "Medium",
800+
"memory.features.summarizeReasoningEffort.high": "High",
801+
"memory.features.summarizeReasoningEffort.hint": "Prefer low for thinking models so reasoning cannot drain the output budget; takes effect after a DSH restart",
790802
"memory.features.entityExtractionModelHint": "Provider / model empty = follow the main conversation model; reasoning none = provider default",
791803
"memory.features.codingRetrospect": "Coding retrospection",
792804
"memory.features.codingRetrospect.hint": "Distill pitfalls, constraints and rejected solutions from full transcripts (tools and errors included)",
@@ -1949,7 +1961,8 @@ window.__ModuleLoader__.load({
19491961
const FEATURE_STRINGS = ["dreamProvider", "dreamModel", "sleepProvider", "sleepModel", "entityExtractionProvider", "entityExtractionModel", "localEmbedModel", "ollamaBaseUrl", "ollamaModel"];
19501962
const EMBED_PROVIDERS = ["openai", "local", "ollama"];
19511963
// 实体抽取思考强度(issue #109):与后端 FEATURE_FLAG_ENUMS 枚举对齐。
1952-
const ENTITY_REASONING = ["none", "low", "medium", "high"];
1964+
// #315 起蒸馏思考强度共用同一组档位(后端枚举多一个 off,一样可发)。
1965+
const REASONING_OPTIONS = ["none", "low", "medium", "high"];
19531966

19541967
function FeatureRow({ name, hint, on, disabled, onToggle, sub }) {
19551968
return h("div", { className: "mneme-featrow", style: sub ? { paddingLeft: 18, opacity: 0.86 } : undefined },
@@ -2230,11 +2243,28 @@ window.__ModuleLoader__.load({
22302243
disabled: busy,
22312244
onChange: (e) => put({ entityExtractionReasoning: e.target.value })
22322245
},
2233-
ENTITY_REASONING.map((r) => h("option", { key: r, value: r }, t(`memory.features.entityExtractionReasoning.${r}`))))
2246+
REASONING_OPTIONS.map((r) => h("option", { key: r, value: r }, t(`memory.features.entityExtractionReasoning.${r}`))))
22342247
),
22352248
h("div", { className: "mneme-featsubhint" }, t("memory.features.entityExtractionModelHint"))
22362249
);
22372250

2251+
// 蒸馏思考强度(issue #315):autoSummarize 开着才展开,档位与实体抽取
2252+
// 同款枚举下拉、即时提交。蒸馏没有独立 provider/model 路由键(跟随会话
2253+
// 头或 config 文件的 summarizeProvider/summarizeModel),不上连通性测试。
2254+
const summarizeSub = eff.autoSummarize && h("div", { className: "mneme-featsub" },
2255+
h("div", { className: "mneme-featnum" },
2256+
h("span", { className: "mneme-featnumlabel" }, t("memory.features.summarizeReasoningEffort")),
2257+
h("select", {
2258+
className: "mneme-select",
2259+
value: eff.summarizeReasoningEffort || "none",
2260+
disabled: busy,
2261+
onChange: (e) => put({ summarizeReasoningEffort: e.target.value })
2262+
},
2263+
REASONING_OPTIONS.map((r) => h("option", { key: r, value: r }, t(`memory.features.summarizeReasoningEffort.${r}`))))
2264+
),
2265+
h("div", { className: "mneme-featsubhint" }, t("memory.features.summarizeReasoningEffort.hint"))
2266+
);
2267+
22382268
if (error && !state) return h("section", { className: "mneme-set-card" },
22392269
h("div", { className: "mneme-set-title" }, t("memory.features.title")),
22402270
h("div", { className: "mneme-set-hint" }, error));
@@ -2252,6 +2282,7 @@ window.__ModuleLoader__.load({
22522282
FEATURE_GROUPS.map((g) => h(react.Fragment, { key: g.key },
22532283
h("div", { className: "mneme-featgroup" }, t(`memory.features.${g.key}`)),
22542284
g.items.map(flagRow),
2285+
g.key === "group.core" && h(react.Fragment, null, summarizeSub),
22552286
g.key === "group.enhance" && h(react.Fragment, null, embedSub, entitySub),
22562287
g.key === "group.dream" && h(react.Fragment, null, dreamSub, sleepSub)
22572288
)),

‎dsh-mneme/lib/config.js‎

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -492,6 +492,23 @@ export const Config = z.object({
492492
z.const("high"),
493493
z.const("none")
494494
]).description("同 dreamReasoningEffort:sleep 各阶段 LLM 的推理档位,未配置 = 自动取模型支持的最低档;显式 'none' = 不发送字段、用服务商自带默认。"),
495+
// Pass-through reasoning effort for the distill (summarize) LLM call
496+
// (issue #315). Mirrors entityExtractionReasoning rather than dream: the
497+
// default 'none' omits the field entirely (provider default), so current
498+
// behavior is unchanged until the user opts in — no auto-lowest resolution
499+
// here, distill failures are retried at the window level anyway. off/low/
500+
// medium/high are forwarded verbatim; a provider that rejects the effort
501+
// retries once without it (withEffortFallback), so opting in is safe to
502+
// experiment with. The failure being addressed is the #9 shape on the
503+
// distill path: a thinking model drains the output budget on reasoning and
504+
// the summary comes back empty/truncated.
505+
summarizeReasoningEffort: z.union([
506+
z.const("off"),
507+
z.const("low"),
508+
z.const("medium"),
509+
z.const("high"),
510+
z.const("none")
511+
]).default("none").description("蒸馏(会话总结提炼)LLM 的推理档位:默认 'none' = 不发送字段、用服务商自带默认;off/low/medium/high 原样传递,被模型拒收时自动去掉字段重试一次(与巩固/睡眠同款降级,#315)。思考型模型建议 off/low,避免推理烧光输出预算。"),
495512
// Issue #257:sleep 冲突/模式两阶段的输出预算(原硬编码 2048)。实测默认档
496513
// 每对裁决约 90 token、24 对 2097——2048 恰好压在边界(53 次运行 48 败);
497514
// full 档六分支实测约 290 token/对、24 对 6967,2048 必然截断。默认 8192

‎dsh-mneme/lib/dream.js‎

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -341,6 +341,9 @@ async function runAuditedLlm(ctx, service, config, spec, body) {
341341
* accepted → reasoning capped; rejected → provider default (old behavior),
342342
* logged so the rejection is observable.
343343
*/
344+
// Issue #315:effort 拒收判别式的单一来源。summarize 的流失败以 aborted 结果
345+
// 返回,需在折叠成 undefined 前用同一甄别(各处手写会漂移)。
346+
export const EFFORT_REJECT_RE = /reasoning[\s_]*effort|UNSUPPORTED_REASONING_EFFORT/i;
344347
async function withEffortFallback(ctx, effort, attempt, fallback, getStreamError) {
345348
if (!effort || effort === "none") return attempt();
346349
try {
@@ -351,7 +354,7 @@ async function withEffortFallback(ctx, effort, attempt, fallback, getStreamError
351354
// on the chunk's failure reason here or the retry below is dead code
352355
// for the stream path.
353356
const reason = String(getStreamError?.() ?? "");
354-
if (/reasoning[\s_]*effort|UNSUPPORTED_REASONING_EFFORT/i.test(reason)) {
357+
if (EFFORT_REJECT_RE.test(reason)) {
355358
ctx.logger?.warn?.(`dsh-mneme dream: reasoningEffort "${effort}" rejected via stream (${reason}); retrying without it`);
356359
return fallback();
357360
}
@@ -361,7 +364,7 @@ async function withEffortFallback(ctx, effort, attempt, fallback, getStreamError
361364
const message = String(error?.message ?? error);
362365
// matches both "reasoning effort" (natural language) and the bare
363366
// "UNSUPPORTED_REASONING_EFFORT" error code (underscore).
364-
if (!/reasoning[\s_]*effort/i.test(message)) throw error;
367+
if (!EFFORT_REJECT_RE.test(message)) throw error;
365368
ctx.logger?.warn?.(`dsh-mneme dream: reasoningEffort "${effort}" rejected (${message}); retrying without it`);
366369
return fallback();
367370
}

‎dsh-mneme/lib/settings.js‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,9 @@ const FEATURE_FLAG_ENUMS = {
172172
recallFusion: ["blend", "rrf", "minmax"],
173173
// 实体抽取思考强度(issue #109):与 dreamReasoningEffort 枚举对齐。
174174
entityExtractionReasoning: ["low", "medium", "high", "none"],
175+
// 蒸馏思考强度(issue #315):与 entityExtractionReasoning 枚举对齐,
176+
// 多一个 off(显式关思考,思考型模型蒸馏防推理烧预算)。
177+
summarizeReasoningEffort: ["off", "low", "medium", "high", "none"],
175178
// Issue #127:落库前去重档位(off 默认,等同现状)。
176179
summarizeDedupeMode: ["off", "title", "vector"],
177180
// Issue #126:sleep 冲突阶段的动作集(conflict 默认 = 现状;full = 六分支)。

0 commit comments

Comments
 (0)