dsh-think-effort 0.5.1 → 0.7.0
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/CHANGELOG.md +26 -0
- package/README.md +79 -2
- package/client.js +206 -2
- package/cordis.patch.yml +24 -0
- package/docs/DETAIL.en.md +37 -0
- package/docs/DETAIL.zh.md +37 -0
- package/docs/adaptive-overlay.png +0 -0
- package/docs/adaptive-settings.png +0 -0
- package/index.js +124 -3
- package/locale/en.json +1 -1
- package/locale/zh.json +1 -1
- package/package.json +7 -3
- package/src/adaptive.js +205 -0
- package/src/parallel.js +52 -0
- package/src/policy.js +60 -7
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,31 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.7.0 — 2026-11-27
|
|
4
|
+
|
|
5
|
+
- **并行工作策略(实验,默认关闭)**:新增 `parallelEnabled` 开关。打开后通过 `ctx.systemPrompt.section()` 注入一段策略(order 700),提示模型在合适时把任务拆成互不阻塞的单元:
|
|
6
|
+
- 1–2 个独立单元 → 同一步多个 `subagent` 调用(并发执行);
|
|
7
|
+
- 3 个以上 → `workflow` 的 `parallel()` / `pipeline()`,每个 child 写清目标、允许修改的文件、验证命令和返回 JSON;
|
|
8
|
+
- 写路径不重叠、共享文件单写者、有依赖走顺序阶段;
|
|
9
|
+
- 写任务扇出上限 `parallelWriteFanout`(默认 4)、只读 `parallelReadFanout`(默认 8);
|
|
10
|
+
- 父代理负责集成与验证后才汇报;长全量测试用 `run_in_background`;
|
|
11
|
+
- 明确不用 subagent/workflow 跑测试;子代理只完成自己的单元,不再递归拆分。
|
|
12
|
+
- **独立于档位策略**:不改写任何模型请求、不增加工具权限、不额外发请求;`text` 读取 volatile 配置并在关闭时返回空串,所以开关在**下一次请求装配**生效,不需要重启/重挂。
|
|
13
|
+
- 设置页新增「并行工作(实验)」区块(总开关、写扇出、只读扇出);README / DETAIL(中英)与 `cordis.patch.yml` 同步。
|
|
14
|
+
- 测试:`node --test` **61 项全绿**(新增并行策略文本/开关/扇出 clamp、Host 注入与客户端双语文案测试)。
|
|
15
|
+
- 说明:上一轮验证用的用户全局 `~/.dsh/AGENTS.md` 策略已迁移进插件开关,不再全局常开。
|
|
16
|
+
|
|
17
|
+
## 0.6.0 — 2026-11-26
|
|
18
|
+
|
|
19
|
+
- **自动难度(实验,默认关闭)**:新增 `adaptiveEnabled` 总开关。打开后只对模型选择器里的 `Auto` 生效:
|
|
20
|
+
- **探索阶段降档**(镜像 Reasonix v1.38.1 的 reasoning governor):先按默认档跑一轮;触发条件成立且本轮还没出现写文件/本地执行时,后续请求降到 `adaptiveExplorationLevel`(默认 `low`);第一次写/执行即退出探索、恢复默认档。状态按会话隔离、每轮重置。
|
|
21
|
+
- **触发方式**:`adaptiveTrigger` 默认 `auto`——供应商上报 reasoning tokens 时用阈值(`adaptiveReasoningThreshold`,默认 1500),否则退回轮次(`adaptiveMinRounds`,默认 1)。实测当前网关的 `assistant/message.usage` 不返回 reasoning tokens,若只按阈值会完全失效,因此加入轮次回退;也可强制 `rounds` / `reasoning`。
|
|
22
|
+
- **计划模式映射**:`planMode` 激活时 Auto 落到 `adaptivePlanLevel`(默认 `high`),可关。
|
|
23
|
+
- **优先级写死**:廉价调用 → 固定 `subagentLevel` → 自动策略 → Auto 默认;用户显式选的档位永远原样透传,自动策略不介入;所有自动档位 clamp 到模型已声明词表。
|
|
24
|
+
- **可观测**:调试悬浮窗新增「探索 / 计划」原因徽标,journal 记录 `reason`/`phase`;设置页新增「自动难度(实验)」区块(6 个字段,全部 volatile)。
|
|
25
|
+
- **未做**(按 P1 范围):失败升档、按深度/preset 的多层映射;不按提示词/工具名猜难度。
|
|
26
|
+
- 文档:README / DETAIL(中英)新增自动难度说明与「为什么默认关闭」;`cordis.patch.yml` 与配置表补 6 个字段。
|
|
27
|
+
- 测试:`node --test` **54 项全绿**(新增 8 项自适应状态机、3 项策略/配置归一化、3 项 Host 集成(含 agent 作用域 planMode)、客户端双语文案守卫)。
|
|
28
|
+
|
|
3
29
|
## 0.5.1 — 2026-11-25
|
|
4
30
|
|
|
5
31
|
- **修复 Desktop 上悬浮窗一直「读取调试日志失败:Failed to fetch」**:DSH Desktop 的页面从 `dsh-app://app/` 加载,`__DSH_TRANSPORT__.streamBaseUrl` 指向 `http://127.0.0.1:<port>`。上一版把调试路由拼成这个绝对地址,浏览器把它当成跨源请求,而插件路由没有 CORS 响应头,于是被浏览器拒绝(`TypeError: Failed to fetch`),只有浏览器里打开的 Web GUI 能用。
|
package/README.md
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
**中文(默认)** · [English](#english)
|
|
4
4
|
|
|
5
|
-
给 DeepSeek Harness(DSH)加一套**声明式自动思考档位**:模型选择器里出现 `Auto`,普通步骤落到模型声明的默认档(DeepSeek 为 `high`),会话标题、上下文压缩、自动复审这类由 Harness 自己发起的廉价调用自动用 `low
|
|
5
|
+
给 DeepSeek Harness(DSH)加一套**声明式自动思考档位**:模型选择器里出现 `Auto`,普通步骤落到模型声明的默认档(DeepSeek 为 `high`),会话标题、上下文压缩、自动复审这类由 Harness 自己发起的廉价调用自动用 `low`。打开调试开关后,每次请求的档位决策会实时出现在会话界面的悬浮窗里,子代理的决策也在其中。另有可选的**并行工作策略**开关:打开后提示模型在合适时把任务拆给并行的 subagent / workflow,而不是全部串行。
|
|
6
6
|
|
|
7
7
|
## 快速开始
|
|
8
8
|
|
|
@@ -91,6 +91,37 @@ DSH Desktop → **插件市场**搜索 `dsh-think-effort` 安装;或 **插件
|
|
|
91
91
|
|
|
92
92
|
窗口位置与展开状态记在浏览器本地,刷新页面后保持原样;「设置更新」「能力声明」也会作为事件出现在日志里,方便确认保存是否生效。
|
|
93
93
|
|
|
94
|
+
### 自动难度(实验)
|
|
95
|
+
|
|
96
|
+
默认**关闭**。打开后只对模型选择器里的 `Auto` 生效,不会覆盖你显式选的 `Low / High / Max`:
|
|
97
|
+
|
|
98
|
+
- **探索阶段降档**:先按默认档跑一轮;若这一轮思考很贵(`reasoningTokens ≥ 1500`,可调)且本轮还没开始写文件/执行命令,**后续请求降到 `Low`**;一旦出现写/执行就恢复默认档。状态按会话隔离,每轮重置。
|
|
99
|
+
触发方式默认「自动」:供应商上报 reasoning tokens 时按阈值,**不上报时退回按轮次**(默认第一轮后触发)——很多 OpenAI 兼容网关不返回 reasoning tokens,这样才不会失效;也可以强制「按轮次」或「按思考 token」。
|
|
100
|
+
- **计划模式**:计划模式是显式信号,Auto 会落到 `High`(可改为别的档),避免规划时被降档。
|
|
101
|
+
- **不猜难度**:不看提示词、工具名或参数大小;只看“是否在探索”“上一轮思考多贵”“是否计划模式”这些确定性信号。
|
|
102
|
+
- **优先级**:廉价调用 → 固定子代理档位 → 自动策略 → Auto 默认;自动档位一律 clamp 到模型已声明词表。
|
|
103
|
+
|
|
104
|
+
设置页「自动难度(实验)」:总开关、探索降档开关/档位/触发方式/阈值/轮次、计划模式开关/档位。默认值 `auto / 1500 / 1 / Low / High`,建议先按默认跑几组任务,观察 HUD 里的「探索」标记再调。
|
|
105
|
+
|
|
106
|
+

|
|
107
|
+
|
|
108
|
+

|
|
109
|
+
|
|
110
|
+
> 这是从 Reasonix 的实验性 reasoning governor 移植过来的机制(其 v1.39.11 已退役 enforcement,只留 shadow 遥测),所以这里也默认关闭、标注实验:纯思考型任务在探索阶段降档可能降低质量。失败升档、按子代理深度/preset 的多层映射不在本版本范围。
|
|
111
|
+
|
|
112
|
+
### 并行工作(实验)
|
|
113
|
+
|
|
114
|
+
默认**关闭**,与档位策略独立:打开后向每个会话的系统提示注入一段“先拆分、再并行”的规则。它只改变模型的行为,不增加工具权限,也不额外发请求;开关是 volatile 的,**下一次请求就生效,不需要重启**。
|
|
115
|
+
|
|
116
|
+
- **1–2 个独立单元**:提示模型在同一个 step 里发多个 `subagent` 调用(它们并发执行);
|
|
117
|
+
- **3 个以上**:提示模型用 `workflow` 的 `parallel()` / `pipeline()`,每个 child 写清目标、允许改的文件、验证命令,并返回 JSON;
|
|
118
|
+
- **写范围**:共享文件(lockfile、snapshot、生成文件、迁移)只能一个写者;有依赖用顺序阶段;
|
|
119
|
+
- **扇出上限**:写任务 `parallelWriteFanout`(默认 4),只读任务 `parallelReadFanout`(默认 8);
|
|
120
|
+
- **集成**:父代理等全部 child 结束,检查 diff/冲突,跑合并后的验证(优先 affected 测试)后才汇报;长全量测试用 `run_in_background`;
|
|
121
|
+
- **明确不要**:用 subagent/workflow 跑测试;小任务、同文件耦合、共享状态无隔离时不要并行。
|
|
122
|
+
|
|
123
|
+
设置页「并行工作(实验)」:总开关、写扇出上限、只读扇出上限。适合“一个前端工程很多独立 spec/模块”这类任务;如果发现模型拆得太碎,先把上限调小或关掉。
|
|
124
|
+
|
|
94
125
|
### 本插件的第一次使用
|
|
95
126
|
|
|
96
127
|
装上后不需要额外配置:`Auto` 与档位由插件自动声明。选中 `Auto` 即按默认档运行;选 `Low / High / Max` 即固定该档;不选(原生「提供方默认」)在普通步骤上与 `Auto` 等效。
|
|
@@ -138,6 +169,17 @@ DSH Desktop → **插件市场**搜索 `dsh-think-effort` 安装;或 **插件
|
|
|
138
169
|
auxLevel: low
|
|
139
170
|
autoScope: all
|
|
140
171
|
subagentLevel: inherit
|
|
172
|
+
adaptiveEnabled: false
|
|
173
|
+
adaptiveExploration: true
|
|
174
|
+
adaptiveExplorationLevel: low
|
|
175
|
+
adaptiveTrigger: auto
|
|
176
|
+
adaptiveReasoningThreshold: 1500
|
|
177
|
+
adaptiveMinRounds: 1
|
|
178
|
+
adaptivePlanMode: true
|
|
179
|
+
adaptivePlanLevel: high
|
|
180
|
+
parallelEnabled: false
|
|
181
|
+
parallelWriteFanout: 4
|
|
182
|
+
parallelReadFanout: 8
|
|
141
183
|
debugOverlay: false
|
|
142
184
|
trace: false
|
|
143
185
|
```
|
|
@@ -157,6 +199,9 @@ DSH Desktop → **插件市场**搜索 `dsh-think-effort` 安装;或 **插件
|
|
|
157
199
|
| `auxLevel` | `low` | 廉价调用用的档位 |
|
|
158
200
|
| `autoScope` | `all` | `all` / `declared` / `off` |
|
|
159
201
|
| `subagentLevel` | `inherit` | 子代理档位:`inherit` / `auto` / `low`…`max`;固定档会覆盖子代理自身或继承的选择 |
|
|
202
|
+
| `parallelEnabled` | `false` | 注入并行工作策略(实验;只改模型行为) |
|
|
203
|
+
| `parallelWriteFanout` | `4` | 策略里写任务的扇出上限(1–8) |
|
|
204
|
+
| `parallelReadFanout` | `8` | 策略里只读任务的扇出上限(1–12) |
|
|
160
205
|
| `debugOverlay` | `false` | 在会话界面显示实时档位切换日志(只记录,不改请求) |
|
|
161
206
|
| `trace` | `false` | 把决策写到 stderr(排查用) |
|
|
162
207
|
|
|
@@ -257,6 +302,36 @@ Turn on **Debug → Show the live effort-switch log in the conversation** and a
|
|
|
257
302
|
|
|
258
303
|
The window's position and open state persist in the browser, so a page refresh keeps them. Settings updates and capability declarations also appear as events, which makes a save's effect easy to confirm.
|
|
259
304
|
|
|
305
|
+
### Automatic difficulty (experimental)
|
|
306
|
+
|
|
307
|
+
Off by default. When on it applies only to the selector's `Auto`; an explicit `Low / High / Max` is never overridden:
|
|
308
|
+
|
|
309
|
+
- **Exploration downgrade**: the first round runs at the default depth; if that round thought expensively (`reasoningTokens ≥ 1500`, configurable) and the turn has not written or executed anything yet, **later requests drop to `Low`**. The first write or local execution restores the default. State is per Session and resets every turn. The trigger defaults to `auto`: the reasoning threshold when the provider reports reasoning tokens, otherwise assistant rounds (most OpenAI-compatible gateways report none); `rounds` and `reasoning` force one rule.
|
|
310
|
+
- **Plan mode**: an explicit signal, so Auto maps to `High` (configurable) instead of being downgraded while planning.
|
|
311
|
+
- **No difficulty guessing**: prompt text, tool names, and argument sizes are never inspected; only deterministic signals (exploring, previous round's reasoning spend, plan mode) are used.
|
|
312
|
+
- **Precedence**: cheap calls → fixed subagent depth → adaptive policy → Auto default; every adaptive depth is clamped to the model's declared vocabulary.
|
|
313
|
+
|
|
314
|
+
Settings → Automatic thinking depth → **Automatic difficulty (experimental)**: master switch, exploration switch/depth/trigger/threshold/rounds, plan-mode switch/depth. Defaults are `auto / 1500 / 1 / Low / High`; run a few tasks with the HUD open and watch the `explore` badge before tuning.
|
|
315
|
+
|
|
316
|
+

|
|
317
|
+
|
|
318
|
+

|
|
319
|
+
|
|
320
|
+
> This ports Reasonix's experimental reasoning governor (v1.39.11 retired its enforcement path and kept only shadow telemetry), so it stays opt-in and marked experimental: downgrading pure-reasoning tasks during exploration can hurt quality. Failure escalation and depth/preset maps are out of scope for this release.
|
|
321
|
+
|
|
322
|
+
### Parallel work (experimental)
|
|
323
|
+
|
|
324
|
+
Off by default and independent of the depth policy: when on, a short “split first, run independent units in parallel” rule is injected into every session's system prompt. It only changes model behavior; it grants no tool permissions and sends no extra requests. The switch is volatile, so the **next request** picks it up without a restart.
|
|
325
|
+
|
|
326
|
+
- **1–2 independent units**: the model is told to emit several `subagent` calls in the same step (they run concurrently);
|
|
327
|
+
- **3+ units**: use `workflow` with `parallel()` / `pipeline()`; every child gets a goal, allowed files, a verification command, and returns JSON;
|
|
328
|
+
- **Write scopes**: shared files (lockfiles, snapshots, generated files, migrations) have exactly one writer; dependent work uses ordered stages;
|
|
329
|
+
- **Fan-out caps**: `parallelWriteFanout` (default 4) for writes, `parallelReadFanout` (default 8) for read-only work;
|
|
330
|
+
- **Integration**: the parent waits for every child, reviews diffs/conflicts, runs the merged verification (affected tests first), and only then reports done; long full suites go to `run_in_background`;
|
|
331
|
+
- **Explicitly not**: using subagent/workflow to run tests; small tasks, same-file coupling, or shared state without isolation.
|
|
332
|
+
|
|
333
|
+
Settings → Parallel work (experimental): master switch, write fan-out cap, read-only fan-out cap. Designed for tasks like a frontend project with many independent specs/modules; if the model splits too aggressively, lower the caps or turn it off.
|
|
334
|
+
|
|
260
335
|
### Features
|
|
261
336
|
|
|
262
337
|
- Declares `reasoningEfforts` for DeepSeek models that carry none (gateway aliases included), so the selector finally has levels.
|
|
@@ -265,10 +340,12 @@ The window's position and open state persist in the browser, so a page refresh k
|
|
|
265
340
|
- Cheap host-owned calls (`session-title`, `compaction`, `auto-review`) drop to `low` only when the model declares it, regardless of the session's own choice.
|
|
266
341
|
- Idempotent: a second boot writes nothing; unload restores the original adapter registrations and retires a durable `auto`.
|
|
267
342
|
- **Live debug window**: an opt-in, bounded, in-memory journal served over a Host route and rendered as a movable log over the conversation, subagent decisions included.
|
|
343
|
+
- **Automatic difficulty (experimental)**: an opt-in exploration downgrade and plan-mode elevation for `Auto`, with explicit selections, cheap calls, and fixed subagent depths always taking precedence.
|
|
344
|
+
- **Parallel work (experimental)**: an independent opt-in system-prompt policy that tells the model when to split a task across parallel subagents/workflow, with write-scope, dependency, fan-out and integration rules.
|
|
268
345
|
|
|
269
346
|
### Configuration
|
|
270
347
|
|
|
271
|
-
Override the `think-effort` row in the profile's `cordis.patch.yml`; the fields are listed in the Chinese section above. `declareCapability`, `efforts`, `defaultEffort`, `auxPurposes`, `auxLevel`, `autoScope`, `subagentLevel`, `debugOverlay` and `trace` are the ones most often changed. Most users should use the visual settings page instead of editing this file.
|
|
348
|
+
Override the `think-effort` row in the profile's `cordis.patch.yml`; the fields are listed in the Chinese section above. `declareCapability`, `efforts`, `defaultEffort`, `auxPurposes`, `auxLevel`, `autoScope`, `subagentLevel`, `adaptiveEnabled`, `debugOverlay` and `trace` are the ones most often changed. Most users should use the visual settings page instead of editing this file.
|
|
272
349
|
|
|
273
350
|
### Compatibility
|
|
274
351
|
|
package/client.js
CHANGED
|
@@ -62,6 +62,8 @@ window.__ModuleLoader__.load({
|
|
|
62
62
|
unsaved: '有未保存的改动。',
|
|
63
63
|
invalidPattern: '模型 ID 正则需要是合法的 JavaScript 正则。',
|
|
64
64
|
invalidEfforts: '至少保留一个档位。',
|
|
65
|
+
adaptiveThresholdInvalid: '触发阈值必须是非负数字。',
|
|
66
|
+
adaptiveRoundsInvalid: '触发轮次必须是至少 1 的整数。',
|
|
65
67
|
effortPicker: '自动思考档位',
|
|
66
68
|
sectionPurpose: '档位分配',
|
|
67
69
|
sectionPurposeHint: '每一类请求各自决定用什么强度;显式选择的具体档位不会被“普通步骤”覆盖。',
|
|
@@ -91,6 +93,36 @@ window.__ModuleLoader__.load({
|
|
|
91
93
|
patternHint: '网关别名用,例如 ^deepseek;不区分大小写。',
|
|
92
94
|
declareModelsRow: '额外声明',
|
|
93
95
|
declareModelsHint: '每行一个 provider/model,或一个模型 ID 正则;用于没有匹配到上面两条规则的网关。',
|
|
96
|
+
sectionAdaptive: '自动难度(实验)',
|
|
97
|
+
adaptiveSectionHint: '默认关闭。只对模型选择器里的 Auto 生效:显式选的档位永远优先,也不会根据提示词或工具名猜难度。',
|
|
98
|
+
adaptiveEnabledRow: '启用自动难度',
|
|
99
|
+
adaptiveEnabledHint: '打开后才按下面的规则升降档;关闭时与原行为完全一致。',
|
|
100
|
+
adaptiveExplorationRow: '探索阶段降档',
|
|
101
|
+
adaptiveExplorationHint: '先按默认档跑一轮;若这一轮思考很贵且还没开始写文件或执行命令,后续请求降到探索档;一旦出现写/执行就恢复默认档。',
|
|
102
|
+
adaptiveExplorationLevelRow: '探索阶段使用的档位',
|
|
103
|
+
adaptiveThresholdRow: '触发阈值(上一轮 reasoning tokens)',
|
|
104
|
+
adaptiveThresholdHint: '默认 1500;仅当触发方式使用思考 token 时生效。',
|
|
105
|
+
adaptiveTriggerRow: '触发方式',
|
|
106
|
+
adaptiveTriggerHint: '自动:供应商上报 reasoning tokens 时按阈值,否则按轮次(多数网关不报 reasoning tokens);轮次:只看本轮助手消息数;思考 token:只按 reasoning tokens。',
|
|
107
|
+
adaptiveTriggerAuto: '自动(优先思考 token)',
|
|
108
|
+
adaptiveTriggerRounds: '按轮次',
|
|
109
|
+
adaptiveTriggerReasoning: '按思考 token',
|
|
110
|
+
adaptiveMinRoundsRow: '触发轮次(本轮助手消息数)',
|
|
111
|
+
adaptiveMinRoundsHint: '默认 1:第一轮之后、仍在探索时降档。',
|
|
112
|
+
adaptivePlanRow: '计划模式使用高档',
|
|
113
|
+
adaptivePlanHint: '计划模式下显式提高档位,避免把“探索”误降;不想要可以关闭。',
|
|
114
|
+
adaptivePlanLevelRow: '计划模式使用的档位',
|
|
115
|
+
sectionParallel: '并行工作(实验)',
|
|
116
|
+
parallelSectionHint: '独立于档位策略:开启后向每个会话的系统提示注入一段“先拆分、再并行”的规则,让模型在合适时用 subagent / workflow 并行,而不是串行做完所有事。',
|
|
117
|
+
parallelEnabledRow: '启用并行工作策略',
|
|
118
|
+
parallelEnabledHint: '默认关闭;切换后下一步请求即生效,不需要重启。只改变模型行为,不给额外工具权限。',
|
|
119
|
+
parallelWriteFanoutRow: '写任务扇出上限',
|
|
120
|
+
parallelWriteFanoutHint: '建议 2–4;策略会提示模型不要超过这个数量,避免同文件/共享状态冲突。',
|
|
121
|
+
parallelReadFanoutRow: '只读任务扇出上限',
|
|
122
|
+
parallelReadFanoutHint: '建议 4–8;只读调研/审查可以比写任务更宽。',
|
|
123
|
+
parallelFanoutInvalid: '扇出上限必须是 1–8(写)/ 1–12(只读)之间的整数。',
|
|
124
|
+
debugReasonExploration: '探索',
|
|
125
|
+
debugReasonPlan: '计划',
|
|
94
126
|
debugSection: '调试',
|
|
95
127
|
debugSectionHint: '调试只记录、不改变任何请求:打开后,每次模型请求的档位决策都会实时出现在会话界面的悬浮窗里。',
|
|
96
128
|
debugOverlayRow: '在会话界面显示实时档位切换日志',
|
|
@@ -154,6 +186,8 @@ window.__ModuleLoader__.load({
|
|
|
154
186
|
unsaved: 'Unsaved changes.',
|
|
155
187
|
invalidPattern: 'The model-id pattern must be a valid JavaScript regular expression.',
|
|
156
188
|
invalidEfforts: 'Keep at least one depth.',
|
|
189
|
+
adaptiveThresholdInvalid: 'The trigger threshold must be a non-negative number.',
|
|
190
|
+
adaptiveRoundsInvalid: 'The trigger round must be an integer of at least 1.',
|
|
157
191
|
effortPicker: 'Automatic thinking depth',
|
|
158
192
|
sectionPurpose: 'Depth assignment',
|
|
159
193
|
sectionPurposeHint: 'Each purpose chooses its own depth; an explicit pick is never overridden by the ordinary-step rule.',
|
|
@@ -183,6 +217,36 @@ window.__ModuleLoader__.load({
|
|
|
183
217
|
patternHint: 'For gateway aliases, such as ^deepseek; case insensitive.',
|
|
184
218
|
declareModelsRow: 'Extra declarations',
|
|
185
219
|
declareModelsHint: 'One provider/model per line, or a model-id regular expression, for gateways the rules above miss.',
|
|
220
|
+
sectionAdaptive: 'Automatic difficulty (experimental)',
|
|
221
|
+
adaptiveSectionHint: 'Off by default. Applies only to the selector\'s Auto: an explicit depth always wins, and the policy never guesses from prompt text or tool names.',
|
|
222
|
+
adaptiveEnabledRow: 'Enable automatic difficulty',
|
|
223
|
+
adaptiveEnabledHint: 'When on, the rules below may change the depth; when off, behavior is exactly as before.',
|
|
224
|
+
adaptiveExplorationRow: 'Lower depth during exploration',
|
|
225
|
+
adaptiveExplorationHint: 'Run the first round at the default depth; if that round thought expensively and the turn has not started writing or executing yet, later requests drop to the exploration depth. The first write or local execution restores the default.',
|
|
226
|
+
adaptiveExplorationLevelRow: 'Depth used while exploring',
|
|
227
|
+
adaptiveThresholdRow: 'Trigger threshold (previous round\'s reasoning tokens)',
|
|
228
|
+
adaptiveThresholdHint: '1500 by default; only used when the trigger rule reads reasoning tokens.',
|
|
229
|
+
adaptiveTriggerRow: 'Trigger rule',
|
|
230
|
+
adaptiveTriggerHint: 'auto: use the reasoning threshold when the provider reports reasoning tokens, otherwise count assistant rounds (most gateways report no reasoning tokens); rounds: count rounds only; reasoning: use reasoning tokens only.',
|
|
231
|
+
adaptiveTriggerAuto: 'Auto (reasoning first)',
|
|
232
|
+
adaptiveTriggerRounds: 'By round',
|
|
233
|
+
adaptiveTriggerReasoning: 'By reasoning tokens',
|
|
234
|
+
adaptiveMinRoundsRow: 'Trigger round (assistant messages this turn)',
|
|
235
|
+
adaptiveMinRoundsHint: '1 by default: downgrade after the first round while still exploring.',
|
|
236
|
+
adaptivePlanRow: 'Use a higher depth in plan mode',
|
|
237
|
+
adaptivePlanHint: 'Plan mode raises the depth explicitly so exploration is not downgraded there; turn it off if not wanted.',
|
|
238
|
+
adaptivePlanLevelRow: 'Depth used in plan mode',
|
|
239
|
+
sectionParallel: 'Parallel work (experimental)',
|
|
240
|
+
parallelSectionHint: 'Independent of the depth policy: when on, a short “split first, run independent units in parallel” rule is injected into every session\'s system prompt, so the model uses subagent / workflow where it fits instead of doing everything serially.',
|
|
241
|
+
parallelEnabledRow: 'Enable the parallel-work policy',
|
|
242
|
+
parallelEnabledHint: 'Off by default; the next request picks up the change without a restart. It only changes model behavior; it grants no extra tool permissions.',
|
|
243
|
+
parallelWriteFanoutRow: 'Write-task fan-out cap',
|
|
244
|
+
parallelWriteFanoutHint: '2–4 is a good default; the policy tells the model not to exceed it, limiting same-file and shared-state conflicts.',
|
|
245
|
+
parallelReadFanoutRow: 'Read-only fan-out cap',
|
|
246
|
+
parallelReadFanoutHint: '4–8 is a good default; read-only research and review can run wider than write tasks.',
|
|
247
|
+
parallelFanoutInvalid: 'Fan-out caps must be integers: 1–8 for writes, 1–12 for read-only.',
|
|
248
|
+
debugReasonExploration: 'explore',
|
|
249
|
+
debugReasonPlan: 'plan',
|
|
186
250
|
debugSection: 'Debug',
|
|
187
251
|
debugSectionHint: 'Debugging records but never changes a request: when on, every effort decision appears live in a floating log over the conversation.',
|
|
188
252
|
debugOverlayRow: 'Show the live effort-switch log in the conversation',
|
|
@@ -238,7 +302,12 @@ window.__ModuleLoader__.load({
|
|
|
238
302
|
const FIELDS = [
|
|
239
303
|
'enabled', 'declareCapability', 'deepseekHosts', 'deepseekModelPattern',
|
|
240
304
|
'declareModels', 'efforts', 'defaultEffort', 'autoLevel', 'autoScope',
|
|
241
|
-
'auxDowngrade', 'auxPurposes', 'auxLevel', 'subagentLevel',
|
|
305
|
+
'auxDowngrade', 'auxPurposes', 'auxLevel', 'subagentLevel',
|
|
306
|
+
'adaptiveEnabled', 'adaptiveExploration', 'adaptiveExplorationLevel',
|
|
307
|
+
'adaptiveTrigger', 'adaptiveReasoningThreshold', 'adaptiveMinRounds',
|
|
308
|
+
'adaptivePlanMode', 'adaptivePlanLevel',
|
|
309
|
+
'parallelEnabled', 'parallelWriteFanout', 'parallelReadFanout',
|
|
310
|
+
'debugOverlay', 'trace',
|
|
242
311
|
];
|
|
243
312
|
|
|
244
313
|
function equal(a, b) {
|
|
@@ -352,6 +421,9 @@ window.__ModuleLoader__.load({
|
|
|
352
421
|
.dte-dbg-levels b { color: var(--dsw-alias-brand-primary); font-weight: 600; }
|
|
353
422
|
.dte-dbg-meta { display: flex; gap: 8px; margin-top: 1px; font-size: 10px; color: var(--dsw-alias-label-secondary); white-space: nowrap; overflow: hidden; }
|
|
354
423
|
.dte-dbg-meta span { overflow: hidden; text-overflow: ellipsis; }
|
|
424
|
+
.dte-dbg-reason { flex: none; border-radius: 4px; padding: 0 4px; font-size: 10px; background: color-mix(in srgb, var(--dsw-alias-brand-primary) 14%, transparent); color: var(--dsw-alias-brand-primary); }
|
|
425
|
+
.dte-dbg-reason-plan { background: color-mix(in srgb, var(--dsw-alias-state-success-primary) 16%, transparent); color: var(--dsw-alias-state-success-primary); }
|
|
426
|
+
.dte-input-number { max-width: 180px; }
|
|
355
427
|
.dte-dbg-empty { padding: 14px 12px; font-size: 12px; color: var(--dsw-alias-label-secondary); }
|
|
356
428
|
.dte-dbg-note { padding: 8px 12px; font-size: 11px; color: var(--dsw-alias-state-warn-primary); }
|
|
357
429
|
.dte-dbg-foot { display: flex; align-items: center; gap: 8px; padding: 6px 12px; border-top: 1px solid var(--dsw-alias-border-l1); font-size: 10px; color: var(--dsw-alias-label-secondary); }
|
|
@@ -442,6 +514,14 @@ window.__ModuleLoader__.load({
|
|
|
442
514
|
const validate = () => {
|
|
443
515
|
if (asArray(current.efforts).length === 0) return t('invalidEfforts');
|
|
444
516
|
if (!validPattern(current.deepseekModelPattern)) return t('invalidPattern');
|
|
517
|
+
const threshold = current.adaptiveReasoningThreshold;
|
|
518
|
+
if (typeof threshold !== 'number' || !Number.isFinite(threshold) || threshold < 0) return t('adaptiveThresholdInvalid');
|
|
519
|
+
const rounds = current.adaptiveMinRounds;
|
|
520
|
+
if (typeof rounds !== 'number' || !Number.isFinite(rounds) || rounds < 1) return t('adaptiveRoundsInvalid');
|
|
521
|
+
const writeFanout = current.parallelWriteFanout;
|
|
522
|
+
if (typeof writeFanout !== 'number' || !Number.isInteger(writeFanout) || writeFanout < 1 || writeFanout > 8) return t('parallelFanoutInvalid');
|
|
523
|
+
const readFanout = current.parallelReadFanout;
|
|
524
|
+
if (typeof readFanout !== 'number' || !Number.isInteger(readFanout) || readFanout < 1 || readFanout > 12) return t('parallelFanoutInvalid');
|
|
445
525
|
for (const entry of asArray(current.declareModels)) {
|
|
446
526
|
if (entry.includes('/')) continue;
|
|
447
527
|
if (!validPattern(entry)) return t('invalidPattern');
|
|
@@ -707,6 +787,125 @@ window.__ModuleLoader__.load({
|
|
|
707
787
|
}),
|
|
708
788
|
],
|
|
709
789
|
}),
|
|
790
|
+
Section({
|
|
791
|
+
title: t('sectionAdaptive'),
|
|
792
|
+
hint: t('adaptiveSectionHint'),
|
|
793
|
+
children: [
|
|
794
|
+
Row({
|
|
795
|
+
key: 'adaptiveEnabled',
|
|
796
|
+
label: t('adaptiveEnabledRow'),
|
|
797
|
+
hint: t('adaptiveEnabledHint'),
|
|
798
|
+
children: Switch({ checked: current.adaptiveEnabled === true, disabled: busy, label: current.adaptiveEnabled === true ? t('on') : t('off'), onChange: (next) => patch('adaptiveEnabled', next) }),
|
|
799
|
+
}),
|
|
800
|
+
Row({
|
|
801
|
+
key: 'adaptiveExploration',
|
|
802
|
+
label: t('adaptiveExplorationRow'),
|
|
803
|
+
hint: t('adaptiveExplorationHint'),
|
|
804
|
+
children: Switch({ checked: current.adaptiveExploration !== false, disabled: busy, label: current.adaptiveExploration === false ? t('off') : t('on'), onChange: (next) => patch('adaptiveExploration', next) }),
|
|
805
|
+
}),
|
|
806
|
+
Row({
|
|
807
|
+
key: 'adaptiveExplorationLevel',
|
|
808
|
+
label: t('adaptiveExplorationLevelRow'),
|
|
809
|
+
children: levelSelect('adaptiveExplorationLevel'),
|
|
810
|
+
}),
|
|
811
|
+
Row({
|
|
812
|
+
key: 'adaptiveTrigger',
|
|
813
|
+
label: t('adaptiveTriggerRow'),
|
|
814
|
+
hint: t('adaptiveTriggerHint'),
|
|
815
|
+
children: Select({
|
|
816
|
+
value: current.adaptiveTrigger ?? 'auto',
|
|
817
|
+
options: [
|
|
818
|
+
{ value: 'auto', label: t('adaptiveTriggerAuto') },
|
|
819
|
+
{ value: 'rounds', label: t('adaptiveTriggerRounds') },
|
|
820
|
+
{ value: 'reasoning', label: t('adaptiveTriggerReasoning') },
|
|
821
|
+
],
|
|
822
|
+
disabled: busy,
|
|
823
|
+
onChange: (next) => patch('adaptiveTrigger', next),
|
|
824
|
+
}),
|
|
825
|
+
}),
|
|
826
|
+
Row({
|
|
827
|
+
key: 'adaptiveThreshold',
|
|
828
|
+
label: t('adaptiveThresholdRow'),
|
|
829
|
+
hint: t('adaptiveThresholdHint'),
|
|
830
|
+
children: h('input', {
|
|
831
|
+
className: 'dte-input dte-input-number',
|
|
832
|
+
type: 'number',
|
|
833
|
+
min: 0,
|
|
834
|
+
step: 100,
|
|
835
|
+
value: current.adaptiveReasoningThreshold ?? 1500,
|
|
836
|
+
disabled: busy,
|
|
837
|
+
onChange: (event) => patch('adaptiveReasoningThreshold', event.target.value === '' ? 0 : Number(event.target.value)),
|
|
838
|
+
}),
|
|
839
|
+
}),
|
|
840
|
+
Row({
|
|
841
|
+
key: 'adaptiveRounds',
|
|
842
|
+
label: t('adaptiveMinRoundsRow'),
|
|
843
|
+
hint: t('adaptiveMinRoundsHint'),
|
|
844
|
+
children: h('input', {
|
|
845
|
+
className: 'dte-input dte-input-number',
|
|
846
|
+
type: 'number',
|
|
847
|
+
min: 1,
|
|
848
|
+
step: 1,
|
|
849
|
+
value: current.adaptiveMinRounds ?? 1,
|
|
850
|
+
disabled: busy,
|
|
851
|
+
onChange: (event) => patch('adaptiveMinRounds', event.target.value === '' ? 1 : Number(event.target.value)),
|
|
852
|
+
}),
|
|
853
|
+
}),
|
|
854
|
+
Row({
|
|
855
|
+
key: 'adaptivePlan',
|
|
856
|
+
label: t('adaptivePlanRow'),
|
|
857
|
+
hint: t('adaptivePlanHint'),
|
|
858
|
+
children: Switch({ checked: current.adaptivePlanMode !== false, disabled: busy, label: current.adaptivePlanMode === false ? t('off') : t('on'), onChange: (next) => patch('adaptivePlanMode', next) }),
|
|
859
|
+
}),
|
|
860
|
+
Row({
|
|
861
|
+
key: 'adaptivePlanLevel',
|
|
862
|
+
label: t('adaptivePlanLevelRow'),
|
|
863
|
+
children: levelSelect('adaptivePlanLevel'),
|
|
864
|
+
}),
|
|
865
|
+
],
|
|
866
|
+
}),
|
|
867
|
+
Section({
|
|
868
|
+
title: t('sectionParallel'),
|
|
869
|
+
hint: t('parallelSectionHint'),
|
|
870
|
+
children: [
|
|
871
|
+
Row({
|
|
872
|
+
key: 'parallelEnabled',
|
|
873
|
+
label: t('parallelEnabledRow'),
|
|
874
|
+
hint: t('parallelEnabledHint'),
|
|
875
|
+
children: Switch({ checked: current.parallelEnabled === true, disabled: busy, label: current.parallelEnabled === true ? t('on') : t('off'), onChange: (next) => patch('parallelEnabled', next) }),
|
|
876
|
+
}),
|
|
877
|
+
Row({
|
|
878
|
+
key: 'parallelWriteFanout',
|
|
879
|
+
label: t('parallelWriteFanoutRow'),
|
|
880
|
+
hint: t('parallelWriteFanoutHint'),
|
|
881
|
+
children: h('input', {
|
|
882
|
+
className: 'dte-input dte-input-number',
|
|
883
|
+
type: 'number',
|
|
884
|
+
min: 1,
|
|
885
|
+
max: 8,
|
|
886
|
+
step: 1,
|
|
887
|
+
value: current.parallelWriteFanout ?? 4,
|
|
888
|
+
disabled: busy,
|
|
889
|
+
onChange: (event) => patch('parallelWriteFanout', event.target.value === '' ? 1 : Number(event.target.value)),
|
|
890
|
+
}),
|
|
891
|
+
}),
|
|
892
|
+
Row({
|
|
893
|
+
key: 'parallelReadFanout',
|
|
894
|
+
label: t('parallelReadFanoutRow'),
|
|
895
|
+
hint: t('parallelReadFanoutHint'),
|
|
896
|
+
children: h('input', {
|
|
897
|
+
className: 'dte-input dte-input-number',
|
|
898
|
+
type: 'number',
|
|
899
|
+
min: 1,
|
|
900
|
+
max: 12,
|
|
901
|
+
step: 1,
|
|
902
|
+
value: current.parallelReadFanout ?? 8,
|
|
903
|
+
disabled: busy,
|
|
904
|
+
onChange: (event) => patch('parallelReadFanout', event.target.value === '' ? 1 : Number(event.target.value)),
|
|
905
|
+
}),
|
|
906
|
+
}),
|
|
907
|
+
],
|
|
908
|
+
}),
|
|
710
909
|
Section({
|
|
711
910
|
title: t('debugSection'),
|
|
712
911
|
hint: t('debugSectionHint'),
|
|
@@ -916,6 +1115,11 @@ window.__ModuleLoader__.load({
|
|
|
916
1115
|
h('span', { className: 'dte-dbg-time' }, clockOf(entry?.at)),
|
|
917
1116
|
entry?.subagent === true ? h('span', { className: 'dte-dbg-badge' }, t('debugSubagent')) : null,
|
|
918
1117
|
h('span', { className: 'dte-dbg-purpose' }, purposeLabel(entry?.purpose, t)),
|
|
1118
|
+
entry?.reason === 'exploration'
|
|
1119
|
+
? h('span', { className: 'dte-dbg-reason' }, t('debugReasonExploration'))
|
|
1120
|
+
: entry?.reason === 'plan'
|
|
1121
|
+
? h('span', { className: 'dte-dbg-reason dte-dbg-reason-plan' }, t('debugReasonPlan'))
|
|
1122
|
+
: null,
|
|
919
1123
|
h('span', { className: 'dte-dbg-levels' }, requested, ' → ', h('b', null, applied)),
|
|
920
1124
|
entry?.changed === true
|
|
921
1125
|
? h('span', { className: 'dte-dbg-purpose', title: `${entry.from ?? '—'} → ${applied}` }, '⇄')
|
|
@@ -1027,7 +1231,7 @@ window.__ModuleLoader__.load({
|
|
|
1027
1231
|
const copy = () => {
|
|
1028
1232
|
const text = visible.map((entry) => {
|
|
1029
1233
|
if (entry?.kind === 'request') {
|
|
1030
|
-
return `${clockOf(entry.at)} ${entry.subagent === true ? '[sub]' : '[main]'} ${entry.provider}/${entry.model} ${entry.purpose ?? '-'} ${entry.requested ?? 'default'} -> ${entry.applied ?? 'default'}`;
|
|
1234
|
+
return `${clockOf(entry.at)} ${entry.subagent === true ? '[sub]' : '[main]'} ${entry.provider}/${entry.model} ${entry.purpose ?? '-'} ${entry.requested ?? 'default'} -> ${entry.applied ?? 'default'}${entry.reason ? ` [${entry.reason}]` : ''}`;
|
|
1031
1235
|
}
|
|
1032
1236
|
if (entry?.kind === 'capability') return `${clockOf(entry.at)} [capability] ${(entry.declared ?? []).join(', ')}`;
|
|
1033
1237
|
return `${clockOf(entry.at)} [config] ${configText(entry ?? {}, t)}`;
|
package/cordis.patch.yml
CHANGED
|
@@ -43,6 +43,30 @@
|
|
|
43
43
|
autoScope: all
|
|
44
44
|
# Subagent calls: inherit | auto | low/high/max. Applies immediately.
|
|
45
45
|
subagentLevel: inherit
|
|
46
|
+
# Opt-in automatic difficulty (experimental; off by default). Only an
|
|
47
|
+
# Auto selection is considered; explicit levels and a fixed subagent
|
|
48
|
+
# level always win.
|
|
49
|
+
adaptiveEnabled: false
|
|
50
|
+
# Lower the depth after an expensive round while the turn still explores.
|
|
51
|
+
adaptiveExploration: true
|
|
52
|
+
adaptiveExplorationLevel: low
|
|
53
|
+
# Trigger rule: auto (reasoning tokens when the provider reports them,
|
|
54
|
+
# else assistant rounds) | rounds | reasoning.
|
|
55
|
+
adaptiveTrigger: auto
|
|
56
|
+
# Previous round's reasoning tokens that make exploration expensive.
|
|
57
|
+
adaptiveReasoningThreshold: 1500
|
|
58
|
+
# Assistant rounds in the turn before the exploration downgrade engages.
|
|
59
|
+
adaptiveMinRounds: 1
|
|
60
|
+
# Plan mode is an explicit signal: map it to its own depth.
|
|
61
|
+
adaptivePlanMode: true
|
|
62
|
+
adaptivePlanLevel: high
|
|
63
|
+
# Optional parallel-work policy (experimental; off by default). When on,
|
|
64
|
+
# a short system-prompt section tells the model to split independent
|
|
65
|
+
# work across subagents/workflow instead of running everything serially.
|
|
66
|
+
parallelEnabled: false
|
|
67
|
+
# Fan-out caps advertised by that policy (write 1-8, read-only 1-12).
|
|
68
|
+
parallelWriteFanout: 4
|
|
69
|
+
parallelReadFanout: 8
|
|
46
70
|
# Record every effort decision for the conversation's floating debug
|
|
47
71
|
# log (Settings -> Automatic thinking depth -> Debug). Off by default;
|
|
48
72
|
# turning it on never changes a request.
|
package/docs/DETAIL.en.md
CHANGED
|
@@ -9,6 +9,7 @@ Declarative thinking-depth control for DeepSeek (and other) reasoning models: th
|
|
|
9
9
|
3. **Resolves per request.** At the adapter boundary `auto` becomes the declared default; a request whose `purpose` is a cheap host-owned call becomes `low` when the model declares it — regardless of the session's own choice, because those bounded calls never inherit it; a manually picked depth passes through untouched and is validated by DSH itself.
|
|
10
10
|
4. **Subagent depth.** A subagent effort can be pinned (`inherit` / `auto` / `low`…`max`). `inherit` keeps DSH's native inheritance; a fixed depth overrides the child's own or inherited pick, while a cheap-call downgrade still wins.
|
|
11
11
|
5. **Live debug log.** An optional floating window shows every request's effort decision (requested → sent), subagent sessions included. It records only; it never changes a request.
|
|
12
|
+
6. **Automatic difficulty (experimental, off by default).** An exploration-phase downgrade and a plan-mode elevation that apply only to `Auto`; explicit depths, cheap calls, and fixed subagent depths always win.
|
|
12
13
|
|
|
13
14
|
## Usage
|
|
14
15
|
|
|
@@ -30,6 +31,31 @@ Turn on **Debug → Show the live effort-switch log in the conversation** and a
|
|
|
30
31
|
|
|
31
32
|
Two halves: the Host half appends each decision, at the adapter boundary, to an **in-memory ring buffer** (300 records at most, never written to the session log or disk) and serves it through two `webServer` routes — a cursor-based read and a clear; the browser half polls only while the switch is on, and keeps the window's position and open state in browser storage. With the switch off the routes answer `enabled: false`, the window disappears, and recording stops.
|
|
32
33
|
|
|
34
|
+
## Automatic difficulty (experimental)
|
|
35
|
+
|
|
36
|
+
The opt-in `adaptiveEnabled` switch. When on it applies only to the selector's `Auto`:
|
|
37
|
+
|
|
38
|
+
- **Exploration downgrade** (ported from Reasonix v1.38.1's experimental reasoning governor): a turn starts at the default depth. Once the trigger holds and the turn has not written or executed anything yet (`write`, `edit`, `apply_patch`, `bash`, `terminal_send`, …), later requests drop to `adaptiveExplorationLevel` (default `low`). The first write or local execution ends the phase and restores the default.
|
|
39
|
+
The trigger is `adaptiveTrigger`: `auto` (default) uses `adaptiveReasoningThreshold` (1500) when the provider reports `reasoningTokens`, and otherwise falls back to `adaptiveMinRounds` (1 assistant round); `rounds` and `reasoning` force one rule. Most OpenAI-compatible gateways report no reasoning tokens, which is why the round fallback exists.
|
|
40
|
+
- **Plan mode**: while `planMode` is active, Auto maps to `adaptivePlanLevel` (default `high`); the mapping can be turned off.
|
|
41
|
+
- **Precedence**: cheap calls (title/compaction/auto-review) → fixed `subagentLevel` → adaptive policy → Auto's default resolution. An explicit selector depth always passes through untouched; every adaptive suggestion is clamped to the model's declared vocabulary.
|
|
42
|
+
- **State**: per `sessionId` (parallel subagents never share a phase), reset on `turn/end`, exploration again after a Host restart; never written to the session log or disk.
|
|
43
|
+
- **Observability**: the floating log tags these rows `explore` / `plan`, and the journal records `reason`/`phase`.
|
|
44
|
+
- **Scope**: no failure escalation and no depth/preset maps in this release; it never guesses from prompt text or tool names.
|
|
45
|
+
|
|
46
|
+
## Parallel work (experimental)
|
|
47
|
+
|
|
48
|
+
An independent `parallelEnabled` master switch, off by default. When on, the Host contributes `ctx.systemPrompt.section({ name: 'think-effort:parallel-work', order: 700, text })`. The text is a function over the volatile row config and returns an empty string while off, so a switch takes effect on the **next prompt assembly** without remounting a service.
|
|
49
|
+
|
|
50
|
+
The policy only teaches the model *when* and *how* to split; execution still uses DSH's existing `subagent` / `workflow`:
|
|
51
|
+
|
|
52
|
+
- 1–2 independent units → several `subagent` calls in one step;
|
|
53
|
+
- 3+ → `workflow` with `parallel()` / `pipeline()`;
|
|
54
|
+
- disjoint write paths; one writer per shared file; ordered stages for dependencies;
|
|
55
|
+
- fan-out caps `parallelWriteFanout` (default 4) / `parallelReadFanout` (default 8);
|
|
56
|
+
- the parent integrates and verifies before reporting; long full suites use `run_in_background`;
|
|
57
|
+
- never uses subagent/workflow to run tests.
|
|
58
|
+
|
|
33
59
|
## Where the settings page comes from
|
|
34
60
|
|
|
35
61
|
- The row page registers into the plugin manager's `plugins.row.config`, keyed `dsh-think-effort#think-effort`.
|
|
@@ -60,6 +86,17 @@ Two halves: the Host half appends each decision, at the adapter boundary, to an
|
|
|
60
86
|
| `auxLevel` | `low` | Depth those calls request |
|
|
61
87
|
| `autoScope` | `all` | `all` / `declared` / `off` |
|
|
62
88
|
| `subagentLevel` | `inherit` | Subagent depth: `inherit` / `auto` / a fixed depth; a fixed depth overrides the child's own or inherited pick |
|
|
89
|
+
| `adaptiveEnabled` | `false` | Automatic difficulty master switch (experimental; Auto only) |
|
|
90
|
+
| `adaptiveExploration` | `true` | Downgrade during exploration |
|
|
91
|
+
| `adaptiveExplorationLevel` | `low` | Depth used while exploring |
|
|
92
|
+
| `adaptiveTrigger` | `auto` | `auto` / `rounds` / `reasoning` |
|
|
93
|
+
| `adaptiveReasoningThreshold` | `1500` | Threshold for the reasoning rule |
|
|
94
|
+
| `adaptiveMinRounds` | `1` | Round count for the rounds rule |
|
|
95
|
+
| `parallelEnabled` | `false` | Parallel-work policy switch (experimental; model behavior only) |
|
|
96
|
+
| `parallelWriteFanout` | `4` | Write-task fan-out cap (1–8) |
|
|
97
|
+
| `parallelReadFanout` | `8` | Read-only fan-out cap (1–12) |
|
|
98
|
+
| `adaptivePlanMode` | `true` | Map plan mode to a higher depth |
|
|
99
|
+
| `adaptivePlanLevel` | `high` | Depth used in plan mode |
|
|
63
100
|
| `debugOverlay` | `false` | Live effort-switch log over the conversation (records only, never rewrites; 300 records in Host memory) |
|
|
64
101
|
| `trace` | `false` | Write decisions to stderr for diagnosis |
|
|
65
102
|
|
package/docs/DETAIL.zh.md
CHANGED
|
@@ -9,6 +9,7 @@
|
|
|
9
9
|
3. **逐请求解析**:在适配器边界把 `auto` 换成声明默认档;`purpose` 属于廉价调用时换成 `low`(仅当模型声明了它,且**与会话选了什么都无关**——会话标题/图片摘要本来就不继承会话档位);手动选的档位一律原样透传,由 DSH 自己校验。
|
|
10
10
|
4. **子代理档位**:可给子代理统一指定强度(`inherit` / `auto` / `low`…`max`)。`inherit` 保持 DSH 原生继承;固定档会覆盖子代理自身或从父代理继承的选择,廉价调用的降档仍然优先。
|
|
11
11
|
5. **实时调试日志**:可选的悬浮窗,展示每次请求的档位决策(请求档位 → 实际档位),包括子代理会话;只记录,不改变任何请求。
|
|
12
|
+
6. **自动难度(实验,默认关闭)**:只对 `Auto` 生效的探索阶段降档与计划模式映射;显式档位、廉价调用与固定子代理档位始终优先。
|
|
12
13
|
|
|
13
14
|
## 使用
|
|
14
15
|
|
|
@@ -30,6 +31,31 @@
|
|
|
30
31
|
|
|
31
32
|
实现分两半:Host 半边在适配器边界把每条决策写入一个**内存环形缓冲**(最多 300 条,不写会话日志、不落盘),并通过两条 `webServer` 路由提供增量读取与清空;浏览器半边按开关状态轮询,只在打开时请求,窗口位置与展开状态存在浏览器本地。关掉开关后路由返回 `enabled: false`,窗口消失、记录停止。
|
|
32
33
|
|
|
34
|
+
## 自动难度(实验)
|
|
35
|
+
|
|
36
|
+
默认关闭的 `adaptiveEnabled` 总开关。打开后只对模型选择器里的 `Auto` 生效:
|
|
37
|
+
|
|
38
|
+
- **探索阶段降档**(移植自 Reasonix v1.38.1 的实验性 reasoning governor):一轮开始时按默认档;触发条件成立且本轮还没出现写文件/本地执行(`write`、`edit`、`apply_patch`、`bash`、`terminal_send` 等)时,后续请求降到 `adaptiveExplorationLevel`(默认 `low`);第一次写/执行即退出探索并恢复默认档。
|
|
39
|
+
触发条件由 `adaptiveTrigger` 决定:`auto`(默认)在供应商上报 `reasoningTokens` 时用阈值 `adaptiveReasoningThreshold`(默认 1500),否则退回按轮次 `adaptiveMinRounds`(默认 1,即第一轮之后);`rounds` / `reasoning` 可强制其中一种。多数 OpenAI 兼容网关不返回 reasoning tokens,因此默认需要轮次回退。
|
|
40
|
+
- **计划模式**:`planMode` 激活时 Auto 落到 `adaptivePlanLevel`(默认 `high`),可关闭该映射。
|
|
41
|
+
- **优先级**:廉价调用(标题/压缩/复核)→ 固定 `subagentLevel` → 自动策略 → `Auto` 默认解析。用户显式选择的档位永远原样透传;自动建议一律 clamp 到模型已声明词表,不会发明档位。
|
|
42
|
+
- **状态**:按 `sessionId` 隔离(并行子代理互不影响),`turn/end` 重置,Host 重启后从探索态开始;不写会话日志、不落盘。
|
|
43
|
+
- **可观测**:调试悬浮窗给这类行加「探索 / 计划」标记,journal 记录 `reason`/`phase`。
|
|
44
|
+
- **范围**:本版本不含失败升档、按深度/preset 的多层映射,也不按提示词/工具名猜难度。
|
|
45
|
+
|
|
46
|
+
## 并行工作(实验)
|
|
47
|
+
|
|
48
|
+
独立的 `parallelEnabled` 总开关,默认关闭。打开后由 Host 通过 `ctx.systemPrompt.section({ name: 'think-effort:parallel-work', order: 700, text })` 注入一段策略文本;`text` 是读取 volatile 配置的函数,关闭时返回空串,因此切换在**下一次请求装配**时生效,不重挂任何服务。
|
|
49
|
+
|
|
50
|
+
策略只教模型“何时拆、怎么拆、何时不要拆”,执行仍然走 DSH 已有的 `subagent` / `workflow`:
|
|
51
|
+
|
|
52
|
+
- 1–2 个独立单元 → 同一步多个 `subagent` 调用;
|
|
53
|
+
- 3+ → `workflow` 的 `parallel()` / `pipeline()`;
|
|
54
|
+
- 写路径不重叠;共享文件单写者;有依赖走顺序阶段;
|
|
55
|
+
- 扇出上限 `parallelWriteFanout`(默认 4)/ `parallelReadFanout`(默认 8);
|
|
56
|
+
- 父代理集成、验证后才汇报;长全量测试用 `run_in_background`;
|
|
57
|
+
- 不拿 subagent/workflow 跑测试。
|
|
58
|
+
|
|
33
59
|
## 设置页从哪里来
|
|
34
60
|
|
|
35
61
|
- 插件行页面注册进插件管理器的 `plugins.row.config`,键为 `dsh-think-effort#think-effort`;
|
|
@@ -60,6 +86,17 @@
|
|
|
60
86
|
| `auxLevel` | `low` | 廉价调用用的档位 |
|
|
61
87
|
| `autoScope` | `all` | `all` / `declared` / `off` |
|
|
62
88
|
| `subagentLevel` | `inherit` | 子代理档位:`inherit` / `auto` / 固定档;固定档覆盖子代理自身或继承的选择 |
|
|
89
|
+
| `adaptiveEnabled` | `false` | 自动难度总开关(实验;只对 Auto 生效) |
|
|
90
|
+
| `adaptiveExploration` | `true` | 探索阶段降档 |
|
|
91
|
+
| `adaptiveExplorationLevel` | `low` | 探索阶段档位 |
|
|
92
|
+
| `adaptiveTrigger` | `auto` | `auto` / `rounds` / `reasoning` |
|
|
93
|
+
| `adaptiveReasoningThreshold` | `1500` | reasoning 规则的触发阈值 |
|
|
94
|
+
| `adaptiveMinRounds` | `1` | rounds 规则的触发轮次 |
|
|
95
|
+
| `parallelEnabled` | `false` | 并行工作策略总开关(实验;只改模型行为) |
|
|
96
|
+
| `parallelWriteFanout` | `4` | 写任务扇出上限(1–8) |
|
|
97
|
+
| `parallelReadFanout` | `8` | 只读任务扇出上限(1–12) |
|
|
98
|
+
| `adaptivePlanMode` | `true` | 计划模式映射高档 |
|
|
99
|
+
| `adaptivePlanLevel` | `high` | 计划模式档位 |
|
|
63
100
|
| `debugOverlay` | `false` | 会话界面的实时档位切换日志(只记录,不改请求;Host 内存最多 300 条) |
|
|
64
101
|
| `trace` | `false` | 把决策写到 stderr(排查用) |
|
|
65
102
|
|
|
Binary file
|
|
Binary file
|
package/index.js
CHANGED
|
@@ -43,12 +43,15 @@ import z from '@deepseek-ai/schemastery';
|
|
|
43
43
|
|
|
44
44
|
import {
|
|
45
45
|
DEFAULT_CONFIG,
|
|
46
|
+
isAuxPurpose,
|
|
46
47
|
normalizeConfig,
|
|
47
48
|
planCapabilitySection,
|
|
48
49
|
resolveCallEffort,
|
|
49
50
|
shouldDeclare,
|
|
50
51
|
withAutoEffort,
|
|
51
52
|
} from './src/policy.js';
|
|
53
|
+
import { createAdaptivePolicy } from './src/adaptive.js';
|
|
54
|
+
import { buildParallelPolicy } from './src/parallel.js';
|
|
52
55
|
import { createDebugJournal, registerDebugRoutes } from './src/debug.js';
|
|
53
56
|
|
|
54
57
|
/** The llm-pi-ai settings entry id in a composed profile. */
|
|
@@ -89,6 +92,28 @@ export const Config = z.object({
|
|
|
89
92
|
auxLevel: z.string().default(DEFAULT_CONFIG.auxLevel).volatile(),
|
|
90
93
|
/** Subagent-owned calls: `inherit`, `auto`, or a fixed level. */
|
|
91
94
|
subagentLevel: z.string().default(DEFAULT_CONFIG.subagentLevel).volatile(),
|
|
95
|
+
/** Opt-in automatic difficulty policy; off by default. */
|
|
96
|
+
adaptiveEnabled: z.boolean().default(DEFAULT_CONFIG.adaptiveEnabled).volatile(),
|
|
97
|
+
/** Lower the depth while a turn is still exploring after an expensive round. */
|
|
98
|
+
adaptiveExploration: z.boolean().default(DEFAULT_CONFIG.adaptiveExploration).volatile(),
|
|
99
|
+
/** Depth used during the exploration phase. */
|
|
100
|
+
adaptiveExplorationLevel: z.string().default(DEFAULT_CONFIG.adaptiveExplorationLevel).volatile(),
|
|
101
|
+
/** Previous round's reasoning tokens that make exploration expensive. */
|
|
102
|
+
adaptiveReasoningThreshold: z.number().default(DEFAULT_CONFIG.adaptiveReasoningThreshold).volatile(),
|
|
103
|
+
/** Trigger rule: `auto` (reasoning when reported, else rounds), `rounds`, `reasoning`. */
|
|
104
|
+
adaptiveTrigger: z.union([z.const('auto'), z.const('rounds'), z.const('reasoning')]).default(DEFAULT_CONFIG.adaptiveTrigger).volatile(),
|
|
105
|
+
/** Assistant rounds in the turn before the exploration downgrade engages. */
|
|
106
|
+
adaptiveMinRounds: z.number().default(DEFAULT_CONFIG.adaptiveMinRounds).volatile(),
|
|
107
|
+
/** Explicit plan mode maps to a higher depth. */
|
|
108
|
+
adaptivePlanMode: z.boolean().default(DEFAULT_CONFIG.adaptivePlanMode).volatile(),
|
|
109
|
+
/** Depth used while plan mode is active. */
|
|
110
|
+
adaptivePlanLevel: z.string().default(DEFAULT_CONFIG.adaptivePlanLevel).volatile(),
|
|
111
|
+
/** Inject an optional parallel-work policy into the system prompt. */
|
|
112
|
+
parallelEnabled: z.boolean().default(DEFAULT_CONFIG.parallelEnabled).volatile(),
|
|
113
|
+
/** Fan-out cap for write tasks named by that policy. */
|
|
114
|
+
parallelWriteFanout: z.number().default(DEFAULT_CONFIG.parallelWriteFanout).volatile(),
|
|
115
|
+
/** Fan-out cap for read-only tasks named by that policy. */
|
|
116
|
+
parallelReadFanout: z.number().default(DEFAULT_CONFIG.parallelReadFanout).volatile(),
|
|
92
117
|
/**
|
|
93
118
|
* Record every effort decision in a bounded in-memory journal and serve it to
|
|
94
119
|
* the conversation's floating debug log. Off by default; when off the journal
|
|
@@ -354,8 +379,9 @@ export function apply(ctx, rawConfig) {
|
|
|
354
379
|
* @param {string} input.model model id.
|
|
355
380
|
* @param {object} input.options the request options the adapter receives.
|
|
356
381
|
* @param {string} [input.level] the level the plugin applied, if any.
|
|
382
|
+
* @param {object} [input.adaptive] the automatic-difficulty decision.
|
|
357
383
|
*/
|
|
358
|
-
const debugRequest = ({ provider, model, options, level }) => {
|
|
384
|
+
const debugRequest = ({ provider, model, options, level, adaptive = {} }) => {
|
|
359
385
|
if (debugOn() !== true) return;
|
|
360
386
|
// An ordinary agent step usually carries no purpose; name it explicitly so
|
|
361
387
|
// the browser half can label it instead of showing "unknown".
|
|
@@ -377,9 +403,94 @@ export function apply(ctx, rawConfig) {
|
|
|
377
403
|
switched: level !== undefined && level !== requested,
|
|
378
404
|
from: previous,
|
|
379
405
|
changed: previous !== null && previous !== applied,
|
|
406
|
+
reason: adaptive.reason ?? null,
|
|
407
|
+
phase: adaptive.phase ?? null,
|
|
380
408
|
});
|
|
381
409
|
};
|
|
382
410
|
|
|
411
|
+
// ── adaptive difficulty ──────────────────────────────────────────────────
|
|
412
|
+
// Opt-in policy: the phase state is folded from committed Session events and
|
|
413
|
+
// only consulted for `auto` requests. Every state is per Session, so parallel
|
|
414
|
+
// subagents never inherit each other's phase.
|
|
415
|
+
const adaptive = createAdaptivePolicy();
|
|
416
|
+
ctx.on('session/event', (session, event) => {
|
|
417
|
+
if (config.adaptiveEnabled !== true) return;
|
|
418
|
+
const sessionId = session?.id ?? session?.header?.id;
|
|
419
|
+
if (typeof sessionId !== 'string' || sessionId === '') return;
|
|
420
|
+
try {
|
|
421
|
+
adaptive.observe(sessionId, event);
|
|
422
|
+
} catch {
|
|
423
|
+
/* a malformed event must not affect a turn */
|
|
424
|
+
}
|
|
425
|
+
});
|
|
426
|
+
|
|
427
|
+
/** Whether plan mode is active for one live Session. */
|
|
428
|
+
const planStateOf = (sessionId) => {
|
|
429
|
+
if (typeof sessionId !== 'string' || sessionId === '') return { active: false, why: 'no-session' };
|
|
430
|
+
try {
|
|
431
|
+
const agent = ctx.get('agents')?.get?.(sessionId);
|
|
432
|
+
if (agent === undefined) return { active: false, why: 'no-agent' };
|
|
433
|
+
// Plan mode is composed per agent preset, so its service may live in the
|
|
434
|
+
// agent's own context rather than the profile root; ask the preset
|
|
435
|
+
// registry for the agent-scoped face first and keep a root fallback for
|
|
436
|
+
// compositions that mount it globally.
|
|
437
|
+
const planMode = ctx.get('agentPresets')?.serviceFor?.(agent, 'planMode') ?? ctx.get('planMode');
|
|
438
|
+
if (planMode === undefined) return { active: false, why: 'no-service' };
|
|
439
|
+
const state = planMode.get(agent);
|
|
440
|
+
return { active: state?.active === true, why: `state:${String(state?.active)}:${String(state?.pending)}` };
|
|
441
|
+
} catch (error) {
|
|
442
|
+
return { active: false, why: `error:${error instanceof Error ? error.message : String(error)}` };
|
|
443
|
+
}
|
|
444
|
+
};
|
|
445
|
+
|
|
446
|
+
/**
|
|
447
|
+
* Ask the adaptive policy for one request's suggestion.
|
|
448
|
+
*
|
|
449
|
+
* Cheap calls and a fixed `subagentLevel` keep their precedence: the policy
|
|
450
|
+
* is not consulted for them at all, so a journal reason always describes a
|
|
451
|
+
* decision that could actually apply.
|
|
452
|
+
* @param {object} input request facts.
|
|
453
|
+
* @param {string} [input.requested] the selection's effort.
|
|
454
|
+
* @param {string} [input.purpose] LLM request purpose.
|
|
455
|
+
* @param {boolean} input.isSubagent whether the call belongs to a subagent.
|
|
456
|
+
* @param {string} [input.sessionId] stamped session identity.
|
|
457
|
+
* @returns {object} the policy decision.
|
|
458
|
+
*/
|
|
459
|
+
const adaptiveDecisionFor = ({ requested, purpose, isSubagent, sessionId }) => {
|
|
460
|
+
const none = { level: undefined, reason: null, phase: null };
|
|
461
|
+
if (config.adaptiveEnabled !== true) return none;
|
|
462
|
+
if (requested !== 'auto') return none;
|
|
463
|
+
if (isAuxPurpose(purpose, config)) return none;
|
|
464
|
+
if (isSubagent === true && config.subagentLevel !== 'inherit' && config.subagentLevel !== 'auto') return none;
|
|
465
|
+
const planState = planStateOf(sessionId);
|
|
466
|
+
const decision = adaptive.decide(sessionId, { requested, planActive: planState.active, config });
|
|
467
|
+
if (config.trace === true) {
|
|
468
|
+
trace('adaptive: session=%s plan=%s (%s) level=%s reason=%s', String(sessionId), planState.active, planState.why, String(decision.level), String(decision.reason));
|
|
469
|
+
}
|
|
470
|
+
return decision;
|
|
471
|
+
};
|
|
472
|
+
|
|
473
|
+
// ── optional parallel-work policy ────────────────────────────────────────
|
|
474
|
+
// A system-prompt section, not a tool: the policy changes how the model
|
|
475
|
+
// plans, while the existing workflow/subagent tools stay the execution path.
|
|
476
|
+
// The section text is a function over the live row config, so the switch
|
|
477
|
+
// takes effect on the next assembled step without a remount.
|
|
478
|
+
const systemPrompt = ctx.get('systemPrompt');
|
|
479
|
+
if (systemPrompt?.section !== undefined) {
|
|
480
|
+
ctx.effect(() => systemPrompt.section({
|
|
481
|
+
name: 'think-effort:parallel-work',
|
|
482
|
+
order: 700,
|
|
483
|
+
text: () => {
|
|
484
|
+
const policy = readConfig(config);
|
|
485
|
+
const text = buildParallelPolicy(policy);
|
|
486
|
+
if (policy.trace === true) {
|
|
487
|
+
trace('parallel-policy: enabled=%s chars=%d', String(policy.parallelEnabled), text.length);
|
|
488
|
+
}
|
|
489
|
+
return text;
|
|
490
|
+
},
|
|
491
|
+
}), 'think-effort: parallel work');
|
|
492
|
+
}
|
|
493
|
+
|
|
383
494
|
// ── capability declaration ───────────────────────────────────────────────
|
|
384
495
|
/** Serialize settings writes; a boot burst must not stack whole-section updates. */
|
|
385
496
|
let syncTail = Promise.resolve();
|
|
@@ -437,14 +548,22 @@ export function apply(ctx, rawConfig) {
|
|
|
437
548
|
if (config.enabled === false) return options;
|
|
438
549
|
if (options === null || typeof options !== 'object') return options;
|
|
439
550
|
const reasoning = info !== null && typeof info === 'object' ? info.reasoning : undefined;
|
|
551
|
+
const subagent = isSubagentSession(options.sessionId);
|
|
552
|
+
const adaptiveDecision = adaptiveDecisionFor({
|
|
553
|
+
requested: options.reasoningEffort,
|
|
554
|
+
purpose: options.purpose,
|
|
555
|
+
isSubagent: subagent,
|
|
556
|
+
sessionId: options.sessionId,
|
|
557
|
+
});
|
|
440
558
|
const level = resolveCallEffort({
|
|
441
559
|
requested: options.reasoningEffort,
|
|
442
560
|
purpose: options.purpose,
|
|
443
|
-
isSubagent:
|
|
561
|
+
isSubagent: subagent,
|
|
444
562
|
efforts: reasoning !== null && typeof reasoning === 'object' ? reasoning.efforts : undefined,
|
|
445
563
|
defaultEffort: reasoning !== null && typeof reasoning === 'object' ? reasoning.defaultEffort : undefined,
|
|
564
|
+
adaptiveLevel: adaptiveDecision.level,
|
|
446
565
|
}, config);
|
|
447
|
-
debugRequest({ provider, model, options, level });
|
|
566
|
+
debugRequest({ provider, model, options, level, adaptive: adaptiveDecision });
|
|
448
567
|
if (level === undefined || level === options.reasoningEffort) return options;
|
|
449
568
|
const key = `${provider}/${model}/${String(options.purpose ?? '-')}/${level}`;
|
|
450
569
|
trace('translate: %s/%s purpose=%s requested=%s -> %s', provider, model, String(options.purpose ?? '-'), String(options.reasoningEffort), level);
|
|
@@ -534,6 +653,8 @@ export function apply(ctx, rawConfig) {
|
|
|
534
653
|
trace('volatile update: enabled=%s subagentLevel=%s', config.enabled, config.subagentLevel);
|
|
535
654
|
debugRecord('config', {
|
|
536
655
|
enabled: config.enabled,
|
|
656
|
+
adaptiveEnabled: config.adaptiveEnabled,
|
|
657
|
+
parallelEnabled: config.parallelEnabled,
|
|
537
658
|
debugOverlay: config.debugOverlay,
|
|
538
659
|
autoLevel: config.autoLevel,
|
|
539
660
|
defaultEffort: config.defaultEffort,
|
package/locale/en.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"meta": {
|
|
3
3
|
"title": "Automatic thinking depth",
|
|
4
|
-
"description": "Adds Auto to the model selector for reasoning models and resolves it per request: the declared default for normal steps (high on DeepSeek), Low for cheap host-owned calls, and an optional depth just for subagents — all editable on a live visual settings page. A debug switch shows every request's effort decision (subagents included) in a floating log over the conversation.",
|
|
4
|
+
"description": "Adds Auto to the model selector for reasoning models and resolves it per request: the declared default for normal steps (high on DeepSeek), Low for cheap host-owned calls, and an optional depth just for subagents — all editable on a live visual settings page. A debug switch shows every request's effort decision (subagents included) in a floating log over the conversation, and an experimental opt-in automatic difficulty lowers depth during exploration and raises it in plan mode (Auto only).",
|
|
5
5
|
"detail": "docs/DETAIL.en.md"
|
|
6
6
|
}
|
|
7
7
|
}
|
package/locale/zh.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"meta": {
|
|
3
3
|
"title": "自动思考档位",
|
|
4
|
-
"description": "为推理模型在模型选择器里加上 Auto,并逐请求解析:普通步骤用声明的默认档(DeepSeek 为 high),廉价调用用 low
|
|
4
|
+
"description": "为推理模型在模型选择器里加上 Auto,并逐请求解析:普通步骤用声明的默认档(DeepSeek 为 high),廉价调用用 low,子代理可单独指定强度;全部规则都能在可视化设置页即时调整。打开调试开关后,每次请求的档位决策(含子代理)会实时显示在会话界面的悬浮窗里。另有一个默认关闭的实验性自动难度:探索阶段降档、计划模式用高档,只对 Auto 生效。",
|
|
5
5
|
"detail": "docs/DETAIL.zh.md"
|
|
6
6
|
}
|
|
7
7
|
}
|
package/package.json
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-think-effort",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.7.0",
|
|
4
4
|
"type": "module",
|
|
5
|
-
"description": "Automatic thinking depth for DeepSeek routes in DeepSeek Harness: declare the model's effort vocabulary, add Auto to the model selector, resolve it to the declared default, give subagents their own depth, drop cheap host-owned calls to Low, edit every rule on a live visual settings page,
|
|
5
|
+
"description": "Automatic thinking depth for DeepSeek routes in DeepSeek Harness: declare the model's effort vocabulary, add Auto to the model selector, resolve it to the declared default, give subagents their own depth, drop cheap host-owned calls to Low, edit every rule on a live visual settings page, watch each request's effort decision in a floating debug log, optionally lower depth during exploration with the experimental adaptive policy, and optionally inject a parallel-work policy that tells the model to split independent work across subagents/workflow.",
|
|
6
6
|
"icon": "./icon.svg",
|
|
7
7
|
"license": "MIT",
|
|
8
8
|
"author": "mhlywxl",
|
|
@@ -16,7 +16,11 @@
|
|
|
16
16
|
"subagent",
|
|
17
17
|
"settings-page",
|
|
18
18
|
"debug-overlay",
|
|
19
|
-
"live-log"
|
|
19
|
+
"live-log",
|
|
20
|
+
"adaptive-effort",
|
|
21
|
+
"exploration",
|
|
22
|
+
"parallel-work",
|
|
23
|
+
"task-orchestration"
|
|
20
24
|
],
|
|
21
25
|
"exports": {
|
|
22
26
|
".": "./index.js",
|
package/src/adaptive.js
ADDED
|
@@ -0,0 +1,205 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Opt-in automatic difficulty policy: the exploration-phase downgrade ported
|
|
3
|
+
* from Reasonix's retired reasoning governor, adapted to DSH's session events.
|
|
4
|
+
*
|
|
5
|
+
* <h2>What it does</h2>
|
|
6
|
+
*
|
|
7
|
+
* With `adaptiveEnabled` on and the selector on `Auto`, a turn starts at the
|
|
8
|
+
* normal default depth. Once the turn is still exploring — no mutating or local
|
|
9
|
+
* execution tool has run — and the trigger condition holds, later requests in
|
|
10
|
+
* that turn drop to `adaptiveExplorationLevel`. The first write or local
|
|
11
|
+
* execution ends the exploration phase and the default depth returns. Plan mode
|
|
12
|
+
* is an explicit user signal and maps to `adaptivePlanLevel` instead.
|
|
13
|
+
*
|
|
14
|
+
* The trigger is deliberately configurable because not every gateway reports
|
|
15
|
+
* reasoning tokens. `adaptiveTrigger: 'auto'` uses the reasoning-token threshold
|
|
16
|
+
* when the provider reports `usage.reasoningTokens`, and otherwise falls back to
|
|
17
|
+
* the number of assistant rounds (`adaptiveMinRounds`, default 1). `'rounds'`
|
|
18
|
+
* and `'reasoning'` force one rule.
|
|
19
|
+
*
|
|
20
|
+
* <h2>What it deliberately does NOT do</h2>
|
|
21
|
+
*
|
|
22
|
+
* It never inspects prompt text, tool names for difficulty, or argument sizes.
|
|
23
|
+
* It never overrides an explicit selector choice, a fixed `subagentLevel`, or a
|
|
24
|
+
* cheap-call downgrade; those decisions happen in `src/policy.js` before this
|
|
25
|
+
* policy is consulted. It is off by default and resets every turn.
|
|
26
|
+
*
|
|
27
|
+
* The reference implementation is Reasonix v1.38.1 `internal/agent/governor.go`
|
|
28
|
+
* (`govReasoningThreshold = 1500`, exploration cell, env-gated enforcement);
|
|
29
|
+
* that experiment was retired in Reasonix v1.39.11, which is why this is an
|
|
30
|
+
* opt-in experiment rather than default behavior.
|
|
31
|
+
*
|
|
32
|
+
* @module dsh-think-effort/adaptive
|
|
33
|
+
*/
|
|
34
|
+
|
|
35
|
+
/** Journal reason for an exploration-phase downgrade. */
|
|
36
|
+
export const REASON_EXPLORATION = 'exploration';
|
|
37
|
+
/** Journal reason for a plan-mode elevation. */
|
|
38
|
+
export const REASON_PLAN = 'plan';
|
|
39
|
+
|
|
40
|
+
/** Tool names whose call means local execution has started. */
|
|
41
|
+
export const LOCAL_EXEC_TOOLS = new Set([
|
|
42
|
+
'bash',
|
|
43
|
+
'pwsh',
|
|
44
|
+
'run_code',
|
|
45
|
+
'cordis_run',
|
|
46
|
+
'terminal_send',
|
|
47
|
+
'terminal_signal',
|
|
48
|
+
]);
|
|
49
|
+
|
|
50
|
+
/** Tool names whose call mutates the workspace. */
|
|
51
|
+
export const MUTATING_TOOLS = new Set([
|
|
52
|
+
'write',
|
|
53
|
+
'edit',
|
|
54
|
+
'apply_patch',
|
|
55
|
+
'multi_edit',
|
|
56
|
+
'str_replace_editor',
|
|
57
|
+
'notebook_edit',
|
|
58
|
+
]);
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* Classify one tool name for the exploration phase.
|
|
62
|
+
* @param {unknown} name tool name.
|
|
63
|
+
* @returns {'exec'|'mutate'|'other'} the classification.
|
|
64
|
+
*/
|
|
65
|
+
export function classifyTool(name) {
|
|
66
|
+
if (typeof name !== 'string' || name === '') return 'other';
|
|
67
|
+
if (LOCAL_EXEC_TOOLS.has(name)) return 'exec';
|
|
68
|
+
if (MUTATING_TOOLS.has(name)) return 'mutate';
|
|
69
|
+
return 'other';
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* Create the per-session adaptive policy.
|
|
74
|
+
*
|
|
75
|
+
* One instance is owned by `apply()`; states are keyed by Session id, so
|
|
76
|
+
* parallel main sessions and subagents never share a phase. Nothing is
|
|
77
|
+
* persisted: a Host restart simply starts every session in exploration again.
|
|
78
|
+
*
|
|
79
|
+
* @returns {object} the policy.
|
|
80
|
+
*/
|
|
81
|
+
export function createAdaptivePolicy() {
|
|
82
|
+
/** @type {Map<string, {exploring: boolean, lastReasoning: number, rounds: number, reasoningReported: boolean}>} */
|
|
83
|
+
const states = new Map();
|
|
84
|
+
|
|
85
|
+
const fresh = () => ({ exploring: true, lastReasoning: 0, rounds: 0, reasoningReported: false });
|
|
86
|
+
const stateOf = (sessionId) => {
|
|
87
|
+
const existing = states.get(sessionId);
|
|
88
|
+
if (existing !== undefined) return existing;
|
|
89
|
+
const state = fresh();
|
|
90
|
+
states.set(sessionId, state);
|
|
91
|
+
return state;
|
|
92
|
+
};
|
|
93
|
+
|
|
94
|
+
return {
|
|
95
|
+
/** Number of tracked sessions (tests and diagnostics). */
|
|
96
|
+
get size() {
|
|
97
|
+
return states.size;
|
|
98
|
+
},
|
|
99
|
+
|
|
100
|
+
/**
|
|
101
|
+
* Fold one committed Session event into the phase state.
|
|
102
|
+
* @param {string} sessionId Session identity.
|
|
103
|
+
* @param {object} event committed `SessionEvent`.
|
|
104
|
+
*/
|
|
105
|
+
observe(sessionId, event) {
|
|
106
|
+
if (typeof sessionId !== 'string' || sessionId === '') return;
|
|
107
|
+
if (event === null || typeof event !== 'object') return;
|
|
108
|
+
switch (event.type) {
|
|
109
|
+
case 'turn/start':
|
|
110
|
+
states.set(sessionId, fresh());
|
|
111
|
+
return;
|
|
112
|
+
case 'turn/end':
|
|
113
|
+
states.delete(sessionId);
|
|
114
|
+
return;
|
|
115
|
+
case 'assistant/message': {
|
|
116
|
+
const state = stateOf(sessionId);
|
|
117
|
+
state.rounds += 1;
|
|
118
|
+
const tokens = event.data?.usage?.reasoningTokens;
|
|
119
|
+
if (typeof tokens === 'number' && Number.isFinite(tokens)) {
|
|
120
|
+
state.lastReasoning = tokens;
|
|
121
|
+
state.reasoningReported = true;
|
|
122
|
+
}
|
|
123
|
+
return;
|
|
124
|
+
}
|
|
125
|
+
case 'tool/call':
|
|
126
|
+
if (classifyTool(event.data?.name) !== 'other') {
|
|
127
|
+
stateOf(sessionId).exploring = false;
|
|
128
|
+
}
|
|
129
|
+
return;
|
|
130
|
+
default:
|
|
131
|
+
return;
|
|
132
|
+
}
|
|
133
|
+
},
|
|
134
|
+
|
|
135
|
+
/**
|
|
136
|
+
* Decide the adaptive depth for one request.
|
|
137
|
+
*
|
|
138
|
+
* Only an `auto` request is considered; explicit selections belong to the
|
|
139
|
+
* caller. The returned level is a *suggestion*: the policy resolver clamps
|
|
140
|
+
* it to the model's declared vocabulary and applies the precedence rules.
|
|
141
|
+
*
|
|
142
|
+
* @param {string} sessionId Session identity.
|
|
143
|
+
* @param {object} input decision inputs.
|
|
144
|
+
* @param {string} [input.requested] the selection's effort.
|
|
145
|
+
* @param {boolean} [input.planActive] whether plan mode is active.
|
|
146
|
+
* @param {object} input.config normalized plugin config.
|
|
147
|
+
* @returns {{level: string|undefined, reason: string|null, phase: string|null, lastReasoning: number}} the decision.
|
|
148
|
+
*/
|
|
149
|
+
decide(sessionId, { requested, planActive, config }) {
|
|
150
|
+
const none = { level: undefined, reason: null, phase: null, lastReasoning: 0, rounds: 0 };
|
|
151
|
+
if (config?.adaptiveEnabled !== true) return none;
|
|
152
|
+
if (requested !== 'auto') return none;
|
|
153
|
+
if (planActive === true && config.adaptivePlanMode !== false) {
|
|
154
|
+
const planState = stateOf(sessionId);
|
|
155
|
+
return {
|
|
156
|
+
level: config.adaptivePlanLevel,
|
|
157
|
+
reason: REASON_PLAN,
|
|
158
|
+
phase: 'plan',
|
|
159
|
+
lastReasoning: planState.lastReasoning,
|
|
160
|
+
rounds: planState.rounds,
|
|
161
|
+
};
|
|
162
|
+
}
|
|
163
|
+
if (config.adaptiveExploration === false) return none;
|
|
164
|
+
const state = stateOf(sessionId);
|
|
165
|
+
if (state.exploring !== true) {
|
|
166
|
+
return { level: undefined, reason: null, phase: 'executing', lastReasoning: state.lastReasoning, rounds: state.rounds };
|
|
167
|
+
}
|
|
168
|
+
const threshold = Number.isFinite(config.adaptiveReasoningThreshold)
|
|
169
|
+
? Number(config.adaptiveReasoningThreshold)
|
|
170
|
+
: 1500;
|
|
171
|
+
const minRounds = Number.isFinite(config.adaptiveMinRounds) ? Number(config.adaptiveMinRounds) : 1;
|
|
172
|
+
const trigger = config.adaptiveTrigger;
|
|
173
|
+
const reasoningRule = trigger === 'reasoning' || (trigger !== 'rounds' && state.reasoningReported);
|
|
174
|
+
const engaged = reasoningRule
|
|
175
|
+
? state.reasoningReported && state.lastReasoning >= threshold
|
|
176
|
+
: state.rounds >= minRounds;
|
|
177
|
+
if (engaged) {
|
|
178
|
+
return {
|
|
179
|
+
level: config.adaptiveExplorationLevel,
|
|
180
|
+
reason: REASON_EXPLORATION,
|
|
181
|
+
phase: 'exploring',
|
|
182
|
+
lastReasoning: state.lastReasoning,
|
|
183
|
+
rounds: state.rounds,
|
|
184
|
+
};
|
|
185
|
+
}
|
|
186
|
+
return {
|
|
187
|
+
level: undefined,
|
|
188
|
+
reason: null,
|
|
189
|
+
phase: 'exploring',
|
|
190
|
+
lastReasoning: state.lastReasoning,
|
|
191
|
+
rounds: state.rounds,
|
|
192
|
+
};
|
|
193
|
+
},
|
|
194
|
+
|
|
195
|
+
/** Forget one session (tests and disposal). */
|
|
196
|
+
reset(sessionId) {
|
|
197
|
+
states.delete(sessionId);
|
|
198
|
+
},
|
|
199
|
+
|
|
200
|
+
/** Forget every session; a Host teardown needs no replay. */
|
|
201
|
+
clear() {
|
|
202
|
+
states.clear();
|
|
203
|
+
},
|
|
204
|
+
};
|
|
205
|
+
}
|
package/src/parallel.js
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The optional parallel-work policy injected into the system prompt.
|
|
3
|
+
*
|
|
4
|
+
* This module owns only the instruction text: it has no Host access and no
|
|
5
|
+
* tool permissions. The switch lives in the row config, so turning it off
|
|
6
|
+
* removes the text from the next assembled prompt without remounting anything.
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Clamp one fan-out limit to the range the policy advertises.
|
|
11
|
+
* @param {unknown} value raw config value.
|
|
12
|
+
* @param {number} fallback default when the value is not a finite number.
|
|
13
|
+
* @param {number} max largest allowed fan-out.
|
|
14
|
+
* @returns {number} a positive integer.
|
|
15
|
+
*/
|
|
16
|
+
function fanout(value, fallback, max) {
|
|
17
|
+
if (typeof value !== 'number' || !Number.isFinite(value)) return fallback;
|
|
18
|
+
return Math.min(max, Math.max(1, Math.round(value)));
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Build the parallel-work section text.
|
|
23
|
+
*
|
|
24
|
+
* The text is deliberately short: it is re-sent on every model request while
|
|
25
|
+
* the switch is on, and long policy prose costs more than it saves.
|
|
26
|
+
* @param {object} [config] normalized plugin config.
|
|
27
|
+
* @returns {string} the system-prompt section, or an empty string when off.
|
|
28
|
+
*/
|
|
29
|
+
export function buildParallelPolicy(config) {
|
|
30
|
+
if (config?.parallelEnabled !== true) return '';
|
|
31
|
+
const write = fanout(config.parallelWriteFanout, 4, 8);
|
|
32
|
+
const read = fanout(config.parallelReadFanout, 8, 12);
|
|
33
|
+
return [
|
|
34
|
+
'## 并行工作(可选策略)',
|
|
35
|
+
'开始多步骤编码/实现任务前,先判断能否拆成互不阻塞的单元;能并行就不要串行。',
|
|
36
|
+
'',
|
|
37
|
+
'**何时并行**:独立文件/模块/包(写路径不重叠);互不相关的失败测试或诊断方向;只读调研不同区域;不同验证层(typecheck/lint/unit/e2e)。',
|
|
38
|
+
'',
|
|
39
|
+
'**怎么拆**:',
|
|
40
|
+
'1. 先列单元、允许写的路径、依赖关系;共享文件(lockfile、snapshot、生成文件、迁移)只能有一个写者。',
|
|
41
|
+
'2. 1–2 个独立单元:在同一步里发多个 `subagent` 调用(会并发执行),不要串行发。',
|
|
42
|
+
'3. 3 个以上:用 `workflow` 的 `parallel()` / `pipeline()`;每个 child 的 prompt 写清目标、允许修改的文件、验证命令,并返回 JSON(改了哪些文件/测试结果/风险)。',
|
|
43
|
+
'4. 有依赖的用顺序阶段;不要让 B 等 A 的结果却并行启动。',
|
|
44
|
+
`5. 扇出上限:写任务 ${write} 个,只读任务 ${read} 个;每个 child 都有 token 与上下文成本。`,
|
|
45
|
+
'6. 父代理负责集成:等所有 child 结束,检查 diff 与冲突,跑合并后的验证(优先 affected 测试),确认后才汇报完成。长全量测试用 `run_in_background`,最后 `job_output`。',
|
|
46
|
+
'7. 如果你是被委派的子代理:只完成分配给你的单元,不再拆分子任务、不再并行委派。',
|
|
47
|
+
'',
|
|
48
|
+
'**何时不要**:改动集中在一两个文件或同文件耦合;共享状态(数据库、迁移、锁、快照、端口、缓存)没有隔离;设计还没定;小任务(拆分开销大于收益)。',
|
|
49
|
+
'',
|
|
50
|
+
'**不要**:用 `subagent`/`workflow` 来跑测试(测试用一条 affected/`--changed` 命令);未检查子代理结果、未跑验证就宣称完成。',
|
|
51
|
+
].join('\n');
|
|
52
|
+
}
|
package/src/policy.js
CHANGED
|
@@ -92,6 +92,28 @@ export const DEFAULT_CONFIG = {
|
|
|
92
92
|
* id forces that depth (clamped to the model's declared vocabulary).
|
|
93
93
|
*/
|
|
94
94
|
subagentLevel: 'inherit',
|
|
95
|
+
/** Opt-in automatic difficulty policy (off by default). */
|
|
96
|
+
adaptiveEnabled: false,
|
|
97
|
+
/** Lower the depth while a turn is still exploring after an expensive round. */
|
|
98
|
+
adaptiveExploration: true,
|
|
99
|
+
/** Depth used during the exploration phase. */
|
|
100
|
+
adaptiveExplorationLevel: 'low',
|
|
101
|
+
/** Previous round's reasoning tokens that make exploration expensive. */
|
|
102
|
+
adaptiveReasoningThreshold: 1500,
|
|
103
|
+
/** Trigger rule: `auto` (reasoning when reported, else rounds), `rounds`, `reasoning`. */
|
|
104
|
+
adaptiveTrigger: 'auto',
|
|
105
|
+
/** Assistant rounds in the turn before the exploration downgrade engages. */
|
|
106
|
+
adaptiveMinRounds: 1,
|
|
107
|
+
/** Explicit plan mode maps to a higher depth. */
|
|
108
|
+
adaptivePlanMode: true,
|
|
109
|
+
/** Depth used while plan mode is active. */
|
|
110
|
+
adaptivePlanLevel: 'high',
|
|
111
|
+
/** Inject the optional parallel-work policy into the system prompt. */
|
|
112
|
+
parallelEnabled: false,
|
|
113
|
+
/** Fan-out cap for write tasks named by the policy. */
|
|
114
|
+
parallelWriteFanout: 4,
|
|
115
|
+
/** Fan-out cap for read-only tasks named by the policy. */
|
|
116
|
+
parallelReadFanout: 8,
|
|
95
117
|
/** Record every effort decision for the conversation's floating debug log. */
|
|
96
118
|
debugOverlay: false,
|
|
97
119
|
/** Diagnostic stderr trace of each decision. */
|
|
@@ -105,6 +127,29 @@ export function normalizeConfig(raw) {
|
|
|
105
127
|
if (!Array.isArray(config.auxPurposes)) config.auxPurposes = [...DEFAULT_CONFIG.auxPurposes];
|
|
106
128
|
if (!Array.isArray(config.deepseekHosts)) config.deepseekHosts = [...DEFAULT_CONFIG.deepseekHosts];
|
|
107
129
|
if (!Array.isArray(config.declareModels)) config.declareModels = [];
|
|
130
|
+
// A threshold is a non-negative token count; a broken value must not make the
|
|
131
|
+
// policy behave as "always zero".
|
|
132
|
+
if (typeof config.adaptiveReasoningThreshold !== 'number'
|
|
133
|
+
|| !Number.isFinite(config.adaptiveReasoningThreshold)
|
|
134
|
+
|| config.adaptiveReasoningThreshold < 0) {
|
|
135
|
+
config.adaptiveReasoningThreshold = DEFAULT_CONFIG.adaptiveReasoningThreshold;
|
|
136
|
+
}
|
|
137
|
+
if (config.adaptiveTrigger !== 'rounds' && config.adaptiveTrigger !== 'reasoning') {
|
|
138
|
+
config.adaptiveTrigger = 'auto';
|
|
139
|
+
}
|
|
140
|
+
if (typeof config.adaptiveMinRounds !== 'number'
|
|
141
|
+
|| !Number.isFinite(config.adaptiveMinRounds)
|
|
142
|
+
|| config.adaptiveMinRounds < 1) {
|
|
143
|
+
config.adaptiveMinRounds = DEFAULT_CONFIG.adaptiveMinRounds;
|
|
144
|
+
}
|
|
145
|
+
// The fan-out caps are advertised in the prompt text, so keep them in the
|
|
146
|
+
// range the policy can honestly claim rather than passing a wild number on.
|
|
147
|
+
for (const [key, max] of [['parallelWriteFanout', 8], ['parallelReadFanout', 12]]) {
|
|
148
|
+
const value = config[key];
|
|
149
|
+
config[key] = typeof value === 'number' && Number.isFinite(value)
|
|
150
|
+
? Math.min(max, Math.max(1, Math.round(value)))
|
|
151
|
+
: DEFAULT_CONFIG[key];
|
|
152
|
+
}
|
|
108
153
|
return config;
|
|
109
154
|
}
|
|
110
155
|
|
|
@@ -411,15 +456,17 @@ function autoTarget(cfg, efforts, defaultEffort) {
|
|
|
411
456
|
* unconditionally, because a session's own depth never applies to a bounded
|
|
412
457
|
* summary request.
|
|
413
458
|
* 2. A subagent-owned call with `subagentLevel` set → that level, or the
|
|
414
|
-
* plugin's `auto` resolution for `auto`.
|
|
459
|
+
* plugin's `auto` resolution for `auto`. A fixed pin outranks the adaptive
|
|
460
|
+
* suggestion; `auto` lets it through. The child's own selection and
|
|
415
461
|
* inherited parent selection are overridden only when the user opted in.
|
|
416
462
|
* 3. An explicit level → `undefined`: a user pick is passed through untouched
|
|
417
463
|
* (DSH validates it against the same vocabulary, so an undeclared pick never
|
|
418
464
|
* reaches the wire).
|
|
419
465
|
* 4. No explicit selection on an ordinary call → `undefined`: the adapter's own
|
|
420
466
|
* default stands (with the declaration above, that is `high`).
|
|
421
|
-
* 5. `auto` → the
|
|
422
|
-
*
|
|
467
|
+
* 5. `auto` → the adaptive suggestion when the opt-in policy produced one,
|
|
468
|
+
* otherwise the declared route default (DeepSeek: `high`), or the highest
|
|
469
|
+
* declared depth when the route names none.
|
|
423
470
|
*
|
|
424
471
|
* @param {object} input decision inputs.
|
|
425
472
|
* @param {string} [input.requested] the selection's effort.
|
|
@@ -427,10 +474,12 @@ function autoTarget(cfg, efforts, defaultEffort) {
|
|
|
427
474
|
* @param {boolean} [input.isSubagent] whether the call belongs to a subagent session.
|
|
428
475
|
* @param {readonly object[]} [input.efforts] declared vocabulary.
|
|
429
476
|
* @param {string} [input.defaultEffort] route/model default depth.
|
|
477
|
+
* @param {string} [input.adaptiveLevel] the automatic-difficulty suggestion for
|
|
478
|
+
* an `auto` request, already limited to the request's session and phase.
|
|
430
479
|
* @param {object} rawCfg plugin config.
|
|
431
480
|
* @returns {string | undefined} the level to send, or undefined to leave the request alone.
|
|
432
481
|
*/
|
|
433
|
-
export function resolveCallEffort({ requested, purpose, isSubagent, efforts, defaultEffort }, rawCfg) {
|
|
482
|
+
export function resolveCallEffort({ requested, purpose, isSubagent, efforts, defaultEffort, adaptiveLevel }, rawCfg) {
|
|
434
483
|
const cfg = normalizeConfig(rawCfg);
|
|
435
484
|
const depths = depthLevels(efforts);
|
|
436
485
|
if (depths.length === 0) return undefined;
|
|
@@ -441,12 +490,16 @@ export function resolveCallEffort({ requested, purpose, isSubagent, efforts, def
|
|
|
441
490
|
// still win, because a summary request has no task difficulty to describe.
|
|
442
491
|
if (isSubagent === true && cfg.subagentLevel !== undefined && cfg.subagentLevel !== 'inherit') {
|
|
443
492
|
if (aux !== undefined) return aux;
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
493
|
+
if (cfg.subagentLevel !== AUTO_EFFORT) return clampEffort(cfg.subagentLevel, efforts);
|
|
494
|
+
// `auto` for subagents is the same Auto the selector offers, so the
|
|
495
|
+
// adaptive policy may suggest a depth for it as well.
|
|
496
|
+
return adaptiveLevel !== undefined
|
|
497
|
+
? clampEffort(adaptiveLevel, efforts)
|
|
498
|
+
: autoTarget(cfg, efforts, defaultEffort);
|
|
447
499
|
}
|
|
448
500
|
if (requested !== undefined && requested !== AUTO_EFFORT) return undefined;
|
|
449
501
|
if (aux !== undefined) return aux;
|
|
450
502
|
if (requested === undefined) return undefined;
|
|
503
|
+
if (adaptiveLevel !== undefined) return clampEffort(adaptiveLevel, efforts);
|
|
451
504
|
return autoTarget(cfg, efforts, defaultEffort);
|
|
452
505
|
}
|