dsh-parallel-tools-prompt 0.2.2 → 0.2.5
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 +25 -19
- package/icon.svg +9 -0
- package/lib/index.d.ts +2 -0
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +76 -10
- package/lib/index.js.map +1 -1
- package/lib/prompt.d.ts +13 -5
- package/lib/prompt.d.ts.map +1 -1
- package/lib/prompt.js +12 -4
- package/lib/prompt.js.map +1 -1
- package/package.json +16 -3
- package/skills/batch-tool-calls/SKILL.md +34 -8
package/README.md
CHANGED
|
@@ -6,25 +6,28 @@
|
|
|
6
6
|
|
|
7
7
|
## 行为
|
|
8
8
|
|
|
9
|
-
- 插件启用后,默认通过 `contextReminder` 向所有 Agent
|
|
9
|
+
- 插件启用后,默认通过 `contextReminder` 向所有 Agent(包括子智能体)提供提醒,覆盖除 `contextExcludePresetIds`(默认 `[ptc]`)以外的所有 preset 以及没有 preset 的会话;`presetIds` 与根 Agent 筛选不限制此通道。PTC 只暴露 `run_code`,根级调用是独占的,合批应发生在单个程序内部,所以默认跳过;排除判断每一步都做,会话中途切换 preset 后会按新 preset 补发或跳过。插件重载前已存活的子智能体也会在下一步骤获得提醒。
|
|
10
10
|
- `systemPromptSection` 是默认关闭的可选通道;只有此通道按符合条件的根 Agent 与 `presetIds` 筛选,默认目标为 `standard` 根 Agent,跳过子智能体及不在列表中的 preset。
|
|
11
|
-
- 使用公开 Agent 生命周期、session projection 与 `systemPrompt.section()`,不替换 preset。系统提示词 section 固定名称 `parallel-tools:guidance`、order
|
|
11
|
+
- 使用公开 Agent 生命周期、session projection 与 `systemPrompt.section()`,不替换 preset。系统提示词 section 固定名称 `parallel-tools:guidance`、order 3200(排在所有单工具 section 1000–3000 与 MCP_SERVERS 3100 之后,不拆散工具说明、不先于它引用的 jobs/subagent 说明;在 TOOLS_SDK 5000 与输出/人设 section 之前)、禁止插值;不注入时间戳、工具列表或每轮变化的数据。
|
|
12
12
|
- 同一 Agent 幂等注册;插件卸载与 Agent 释放都清理 section。插件重载时为仍存活的目标根 Agent 补挂已启用的 section,并覆盖仍存活 Agent 的提醒通道;源码更新建议重启宿主加载新模块。
|
|
13
|
-
- 两个独立开关选择注入通道(默认只走 CONTEXT 提醒):`contextReminder`(默认 `true`)与 `systemPromptSection`(默认 `false`,设为 `true` 输出 `systemPrompt.section()` 的指引内容)。提醒通过 `agent/pre-step` 在下一步骤追加一条带独立 `source.kind: parallel-tools-scheduling` 的 CONTEXT 消息,写入会话历史并渲染为 CONTEXT 块,与宿主 `time-context`
|
|
13
|
+
- 两个独立开关选择注入通道(默认只走 CONTEXT 提醒):`contextReminder`(默认 `true`)与 `systemPromptSection`(默认 `false`,设为 `true` 输出 `systemPrompt.section()` 的指引内容)。提醒通过 `agent/pre-step` 在下一步骤追加一条带独立 `source.kind: parallel-tools-scheduling` 的 CONTEXT 消息,写入会话历史并渲染为 CONTEXT 块,与宿主 `time-context` 同一机制;去重以模型当前可见的历史(session surface)为准,而不是全量事件日志:可见历史里已有(含继承来的)提醒就不再注入;上下文压缩或裁剪把提醒替换掉之后(surface `replaceGeneration` 变化),下一步骤补发一次,压缩保留了提醒则不补发。CONTEXT 文本带前缀 `Tool-call scheduling (applies to every remaining step of this session):`,说明它对整个会话持续有效。两者可同时开启;同时关闭则插件不注入任何内容。提醒进入历史,卸载不会删除。这不是每轮重复提醒,也不保证长期遵循。
|
|
14
14
|
- 插件详情页(Plugins → 本插件)在描述与组件列表之间提供这两个开关的设置表单,开关即时写入当前 profile 的 patch。两个字段声明为 `.volatile()`,修改不重启插件:`contextReminder` 在下一步骤生效;系统提示词开关对修改之后重新组装提示词的会话生效(已建立的会话沿用旧提示词)。浏览器端由 `src/client` 经 `scripts/build-client.mjs` 构建为 `lib/client.js`,按宿主客户端模块格式封装;表单要求 profile 里条目 id 为 `parallel-tools-prompt`。
|
|
15
|
-
-
|
|
16
|
-
-
|
|
15
|
+
- 两个注入通道共用同一条规则:每次带工具调用的响应前,在心里列出参数已知的调用,逐条问“尚未返回的结果会不会改变我是否调用它、或传什么参数”;不会就本轮一起发出。只有其他后续调用都依赖这一个结果时,单调用才正确。
|
|
16
|
+
- 同一响应里的调用可能并发、顺序不定,所以结果决定下一步、需要审批、或触及同一状态(先读后改、改后运行、同一文件两次编辑)时保持顺序。不凑批:不把无关命令串进一条 shell 调用、不为短调用开子智能体、不做投机调用;不打印计划或添加调度专用轮次,正常的计划、todo 和审批流程照常遵守。
|
|
17
17
|
- 同轮多个工具调用不代表真正同时执行;执行并发仍由DSH调度器决定。
|
|
18
18
|
|
|
19
19
|
## 提示词设计逻辑
|
|
20
20
|
|
|
21
|
-
###
|
|
21
|
+
### 当前规则:逐条就绪检验,单调用要有理由
|
|
22
22
|
|
|
23
|
-
|
|
23
|
+
两个注入通道共用 [prompt.ts](<src/prompt.ts>) 中的 `BATCH_RULE`(约 1000 字符),分发的 skill 描述与其完全一致。设计要点:
|
|
24
24
|
|
|
25
|
-
-
|
|
26
|
-
-
|
|
27
|
-
-
|
|
25
|
+
- **一个能逐条回答的判据**:对每个参数已知的调用问“尚未返回的结果会不会改变我是否调用它、或传什么参数”。比抽象的“依赖 DAG”更容易在每一步执行,也不要求输出任何图或计划。
|
|
26
|
+
- **单调用要有理由**:只有其他后续调用都依赖这一个结果时,单调用才正确。把默认从“能合批就合批”变成“不合批要说得出原因”,但 `test → read failure → fix → retest` 这样的真实依赖链仍然合法。
|
|
27
|
+
- **点名常被漏掉的合批**:任务开头的读取与搜索;一个结果同时指向的多个文件或符号(例如栈追踪里的每一帧);内容已确定后对不同文件的编辑;typecheck、lint、test 等只读检查。
|
|
28
|
+
- **用执行语义解释等待**:“同一响应里的调用可能并发、顺序不定”,所以结果决定下一步、需要审批、或触及同一状态(先读后改、改后运行、同一文件两次编辑)时要分开。
|
|
29
|
+
- **防凑批只禁真正的作弊**:不把无关命令串进一条 shell 调用、不为短调用开子智能体、不做投机调用;`build && test` 这类本身有依赖的串联不受影响。
|
|
30
|
+
- **删掉不改变行为的免责说明**:并发与收益的边界写在本文档里,不占提示词篇幅。
|
|
28
31
|
- **合批与执行并发分开**:同一响应携带多个调用,目标是减少本可避免的模型往返;工具是否真正同时运行仍取决于 runtime/宿主调度、安全限制与资源情况。合批不保证延迟、tokens 或费用下降。
|
|
29
32
|
- **后台重叠与同轮合批也分开**:后台任务运行期间,不依赖其结果、不会干扰其共享状态的独立工作可以继续。即使前后每轮都只有一个工具调用,实际工作仍可能重叠;应遵守宿主的任务跟踪、结果收集与禁止重复执行规则,而不是重复启动正在运行的工作。
|
|
30
33
|
|
|
@@ -40,18 +43,20 @@
|
|
|
40
43
|
|
|
41
44
|
### 本次改进(当前源码已启用,效果未证实)
|
|
42
45
|
|
|
43
|
-
|
|
46
|
+
当前源码(`0.2.5`,尚未发布)的改动,不表示已更新运行中的宿主或已证实有效:
|
|
44
47
|
|
|
45
|
-
-
|
|
46
|
-
-
|
|
47
|
-
-
|
|
48
|
-
-
|
|
48
|
+
- **规则重写**:用上文的逐条就绪检验替换原来的“先发现动作,再查依赖 DAG”措辞;两个通道和 skill 描述同步更新,skill 正文改为“合批 / 等待 / 不凑批 / 后台”四节,并给出正反例。
|
|
49
|
+
- **CONTEXT 前缀**:系统提示词通道仍用 `Tool-call scheduling:`;CONTEXT 通道改为 `Tool-call scheduling (applies to every remaining step of this session):`,因为它只交付一次,需要说明对后续所有步骤有效。
|
|
50
|
+
- **压缩后补发**:去重改看模型当前可见的 surface,而不是全量事件日志。原先压缩删掉提醒后不会补发,模型从此看不到规则;现在会在下一步骤补发一次。
|
|
51
|
+
- **默认跳过 PTC**:新增 `contextExcludePresetIds`(默认 `[ptc]`)。
|
|
52
|
+
- **section 排序**:order 从 1050 改为 3200,挪到全部工具说明之后。
|
|
53
|
+
- **未改动**:注入频率、默认开关、宿主调度行为。收益仍需受控对比验证,实际并发由 runtime 决定。
|
|
49
54
|
|
|
50
55
|
## 版本、依赖与发布
|
|
51
56
|
|
|
52
|
-
插件版本 `0.2.
|
|
57
|
+
插件版本 `0.2.5` 独立编号,不等于宿主版本。最低宿主要求 `>=0.2.3-alpha.2`,Node.js `>=24.9.0`。插件测试运行在 `0.2.3-alpha.2` 宿主依赖上。
|
|
53
58
|
|
|
54
|
-
宿主库以 peerDependencies 声明,同时列入 devDependencies 供构建测试:Cordis `4.0.
|
|
59
|
+
宿主库以 peerDependencies 声明,同时列入 devDependencies 供构建测试:Cordis `4.2.0-alpha.1`、Schemastery `3.20.0-alpha.1`、DSH agent/llm/agent-preset-registry/session-projection/system-prompt 均为 `0.2.3-alpha.2`。不将宿主服务打包为普通运行依赖,避免重复服务身份。peer 依赖是精确版本,宿主升级后需要同步调整。
|
|
55
60
|
|
|
56
61
|
建议使用 `npm ci` 配合 npm lock,避免交替更新两种锁文件。包发布白名单包含构建产物、bundle patch、README、许可证与分析脚本,不包含测试、原始会话或调试捕获。`prepack` 自动构建;预发布默认 `next` tag。确认版本未占用后由维护者执行 `npm publish`;已发布版本不能覆盖。
|
|
57
62
|
|
|
@@ -80,13 +85,14 @@ npm pack --dry-run
|
|
|
80
85
|
```yaml
|
|
81
86
|
enabled: true
|
|
82
87
|
systemPromptSection: false # 默认;设为 true 选择启用系统提示词通道
|
|
83
|
-
contextReminder: true # 默认;所有 Agent
|
|
88
|
+
contextReminder: true # 默认;所有 Agent(含子智能体),排除下一项列出的 preset
|
|
89
|
+
contextExcludePresetIds: [ptc] # 默认;不接收 CONTEXT 提醒的精确 preset ID,最多 32 项
|
|
84
90
|
presetIds: [standard] # 默认;只筛选系统提示词通道的目标根 Agent
|
|
85
91
|
```
|
|
86
92
|
|
|
87
93
|
**注意:profile 的 `cordis.patch.yml` 覆盖本插件时,`config` 是整体替换、不与 bundle 默认值深合并。** 覆盖项必须写全需要的字段,尤其是 `enabled: true`;否则 `enabled` 回落为默认 `false`,插件静默不注入。省略的通道字段使用上述 schema 默认值;自定义系统提示词目标时也要保留所需 `presetIds`。已有 profile 中显式设置的值不会自动迁移:例如原来的 `contextReminder: false` 或 `systemPromptSection: true` 仍保留,需通过设置 UI 或手动修改 profile 才会改变。验收方式:系统提示词通道看新会话 `system/message` 中是否出现 `Tool-call scheduling:`;CONTEXT 通道看会话里是否出现 `source.kind` 为 `parallel-tools-scheduling` 的消息。
|
|
88
94
|
|
|
89
|
-
`presetIds` 是精确 ID 列表,不是正则,且只控制选择启用后的系统提示词通道,不影响 CONTEXT 提醒。系统提示词的自定义目标仅适用于原生工具调用 preset;不要把 PTC
|
|
95
|
+
`presetIds` 是精确 ID 列表,不是正则,且只控制选择启用后的系统提示词通道,不影响 CONTEXT 提醒。系统提示词的自定义目标仅适用于原生工具调用 preset;不要把 PTC 加入该列表,以免对专用执行模式施加额外系统指导。CONTEXT 提醒由 `contextExcludePresetIds` 单独控制:默认跳过 PTC,覆盖 minimal、creator 等其他 preset、无 preset 会话及子智能体;同样是精确 ID 列表,设为 `[]` 则 PTC 也会收到提醒。根会话 fork 可以保留历史 parentSession,不会仅因此被当作子智能体;若继承了已有提醒,则不会再注入。
|
|
90
96
|
|
|
91
97
|
卸载会释放注册;已有模型历史中的旧指令不会被改写或删除。若宿主需要重新投影系统提示,生效边界由宿主管理;稳妥方式是重启后继续原会话。首次安装可能改变system前缀并影响一次缓存复用;不能保证零缓存影响。
|
|
92
98
|
|
package/icon.svg
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" width="36" height="36" viewBox="0 0 36 36" fill="none">
|
|
2
|
+
<circle cx="9.3" cy="18" r="2.3" fill="#175E96"/>
|
|
3
|
+
<path d="M11.5 17 C16.5 15.5 18 10.5 23.5 10.5 H25.4" stroke="#7FB7E3" stroke-width="2.2" stroke-linecap="round"/>
|
|
4
|
+
<path d="M24.2 8.3 26.8 10.5 24.2 12.7" stroke="#7FB7E3" stroke-width="2.2" stroke-linecap="round" stroke-linejoin="round"/>
|
|
5
|
+
<path d="M12 18 H25.4" stroke="#247bbf" stroke-width="2.2" stroke-linecap="round"/>
|
|
6
|
+
<path d="M24.2 15.8 26.8 18 24.2 20.2" stroke="#247bbf" stroke-width="2.2" stroke-linecap="round" stroke-linejoin="round"/>
|
|
7
|
+
<path d="M11.5 19 C16.5 20.5 18 25.5 23.5 25.5 H25.4" stroke="#7FB7E3" stroke-width="2.2" stroke-linecap="round"/>
|
|
8
|
+
<path d="M24.2 23.3 26.8 25.5 24.2 27.7" stroke="#7FB7E3" stroke-width="2.2" stroke-linecap="round" stroke-linejoin="round"/>
|
|
9
|
+
</svg>
|
package/lib/index.d.ts
CHANGED
|
@@ -22,6 +22,7 @@ export declare const Config: z<Schemastery.ObjectS<NoInfer<{
|
|
|
22
22
|
enabled: z<boolean, boolean, "defined">;
|
|
23
23
|
systemPromptSection: z<boolean, boolean, "volatile-defined">;
|
|
24
24
|
contextReminder: z<boolean, boolean, "volatile-defined">;
|
|
25
|
+
contextExcludePresetIds: z<string[], string[], "defined">;
|
|
25
26
|
presetIds: z<string[], string[], "defined">;
|
|
26
27
|
}>>, Schemastery.ObjectT<NoInfer<{
|
|
27
28
|
debugEnabled: z<boolean, boolean, "defined">;
|
|
@@ -31,6 +32,7 @@ export declare const Config: z<Schemastery.ObjectS<NoInfer<{
|
|
|
31
32
|
enabled: z<boolean, boolean, "defined">;
|
|
32
33
|
systemPromptSection: z<boolean, boolean, "volatile-defined">;
|
|
33
34
|
contextReminder: z<boolean, boolean, "volatile-defined">;
|
|
35
|
+
contextExcludePresetIds: z<string[], string[], "defined">;
|
|
34
36
|
presetIds: z<string[], string[], "defined">;
|
|
35
37
|
}>>, "plain">;
|
|
36
38
|
export type Config = ReturnType<typeof Config>;
|
package/lib/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AAKnD,OAAO,CAAC,MAAM,0BAA0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AgB,KAAK,CAAC,GAAG,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,GAAG,IAAI,CAsExD"}
|
package/lib/index.js
CHANGED
|
@@ -7,10 +7,33 @@ export const name = 'parallel-tools-prompt';
|
|
|
7
7
|
export const inject = ['agents', 'systemPrompt', 'agentPresets'];
|
|
8
8
|
/** Source kind of the reminder message; the host renders unknown context kinds as CONTEXT blocks. */
|
|
9
9
|
export const CONTEXT_SOURCE_KIND = 'parallel-tools-scheduling';
|
|
10
|
-
|
|
10
|
+
function isReminderEvent(event) {
|
|
11
|
+
return event?.type === 'user/message'
|
|
12
|
+
&& event.data?.source?.kind === CONTEXT_SOURCE_KIND;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* True when the reminder is still model-visible. Reads the session surface
|
|
16
|
+
* (the projected history after compaction/pruning replacements), like the
|
|
17
|
+
* host's own agent-instructions plugin; the raw event log would still contain
|
|
18
|
+
* a reminder that compaction has already replaced with a summary. Hosts
|
|
19
|
+
* without a surface fall back to the full log.
|
|
20
|
+
*/
|
|
11
21
|
function hasReminder(agent) {
|
|
12
|
-
|
|
13
|
-
|
|
22
|
+
const session = agent.session;
|
|
23
|
+
const { surface, eventAt } = session;
|
|
24
|
+
if (surface !== undefined && typeof eventAt === 'function') {
|
|
25
|
+
const nodes = surface.nodes;
|
|
26
|
+
for (let i = nodes.length - 1; i >= 0; i--) {
|
|
27
|
+
if (isReminderEvent(eventAt.call(session, nodes[i])))
|
|
28
|
+
return true;
|
|
29
|
+
}
|
|
30
|
+
return false;
|
|
31
|
+
}
|
|
32
|
+
return session.snapshotEvents().some(isReminderEvent);
|
|
33
|
+
}
|
|
34
|
+
/** Surface replacement counter; changes only on compaction/prune replacements. */
|
|
35
|
+
function surfaceGeneration(agent) {
|
|
36
|
+
return agent.session.surface?.replaceGeneration ?? 0;
|
|
14
37
|
}
|
|
15
38
|
export const Config = z.object({
|
|
16
39
|
debugEnabled: z.boolean().default(false).description('Capture normalized LLM system prompts locally, only with an explicit session and enable sentinel. Sensitive: disable after diagnosis.'),
|
|
@@ -20,6 +43,8 @@ export const Config = z.object({
|
|
|
20
43
|
enabled: z.boolean().default(false).description('Enable static tool-call scheduling guidance. The bundle explicitly opts in; direct plugin use is disabled by default.'),
|
|
21
44
|
systemPromptSection: z.boolean().default(false).volatile().description('Inject static scheduling guidance as a system-prompt section for eligible roots (default false). May be combined with contextReminder; with both off the plugin injects nothing.'),
|
|
22
45
|
contextReminder: z.boolean().default(true).volatile().description('Inject a one-time scheduling reminder as a CONTEXT message for all agents, including subagents and all presets, at the next step boundary (default true). Persists in the session transcript; never duplicated across reloads. Independent of systemPromptSection and presetIds.'),
|
|
46
|
+
contextExcludePresetIds: z.array(z.string().pattern(/^[A-Za-z0-9][A-Za-z0-9._-]{0,127}$/))
|
|
47
|
+
.max(32).default(['ptc']).description('Exact preset IDs that never receive the CONTEXT reminder (default [ptc]: PTC exposes only run_code, whose root calls are exclusive; batching there belongs inside one program). Agents without a preset are always reminded.'),
|
|
23
48
|
presetIds: z.array(z.string().pattern(/^[A-Za-z0-9][A-Za-z0-9._-]{0,127}$/))
|
|
24
49
|
.max(32).default(['standard']).description('Exact preset IDs for the system-prompt channel only. Root agents only; use native-tool presets, not PTC. An empty list disables system-prompt targets, not context reminders.'),
|
|
25
50
|
});
|
|
@@ -27,6 +52,31 @@ export const Config = z.object({
|
|
|
27
52
|
function flag(value) {
|
|
28
53
|
return typeof value === 'boolean' ? value : value.get();
|
|
29
54
|
}
|
|
55
|
+
/**
|
|
56
|
+
* Read the live agent registry across host generations. The registry API moved
|
|
57
|
+
* from `roots()` (dsh-agent <= 0.2.3-alpha.1) to `list()` (since
|
|
58
|
+
* 0.2.3-alpha.2); calling a removed method crashes the plugin with
|
|
59
|
+
* "ctx.agents.roots is not a function or its return value is not iterable".
|
|
60
|
+
* Probe both names and fail soft with an empty roster, so any future rename
|
|
61
|
+
* degrades to "no guidance attached" instead of a hard plugin error.
|
|
62
|
+
*/
|
|
63
|
+
function liveAgents(ctx) {
|
|
64
|
+
const registry = ctx.agents;
|
|
65
|
+
if (typeof registry.list === 'function')
|
|
66
|
+
return registry.list();
|
|
67
|
+
if (typeof registry.roots === 'function')
|
|
68
|
+
return registry.roots();
|
|
69
|
+
return [];
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Defensive projected-preset lookup: `presetForSession` shipped alongside the
|
|
73
|
+
* registry rename in 0.2.3-alpha.2. On hosts where the service exists without
|
|
74
|
+
* the method, fall back to the durable session header instead of throwing.
|
|
75
|
+
*/
|
|
76
|
+
function projectedPreset(ctx, session) {
|
|
77
|
+
const presets = ctx.agentPresets;
|
|
78
|
+
return typeof presets.presetForSession === 'function' ? presets.presetForSession(session) : null;
|
|
79
|
+
}
|
|
30
80
|
/**
|
|
31
81
|
* Attach or re-attach the guidance section to one already-eligible live agent.
|
|
32
82
|
* Idempotent via the registration guard; shared by `agent/created` and
|
|
@@ -42,10 +92,10 @@ function attach(ctx, agent, config, presetIds, registrations, active) {
|
|
|
42
92
|
// is fork lineage, NOT a parent Agent.
|
|
43
93
|
if (header.origin === 'subagent' || (header.delegationDepth ?? 0) > 0)
|
|
44
94
|
return;
|
|
45
|
-
// Live check only:
|
|
46
|
-
if (!ctx
|
|
95
|
+
// Live check only: the registry lookup still drops agents whose registration detached.
|
|
96
|
+
if (!liveAgents(ctx).includes(agent))
|
|
47
97
|
return;
|
|
48
|
-
const preset = ctx
|
|
98
|
+
const preset = projectedPreset(ctx, agent.session)
|
|
49
99
|
?? header.agentPreset;
|
|
50
100
|
if (preset == null || !presetIds.has(preset))
|
|
51
101
|
return;
|
|
@@ -96,15 +146,31 @@ export function apply(ctx, config) {
|
|
|
96
146
|
// downstream listeners accept the step, append one sourced message to the
|
|
97
147
|
// step's messages; the host persists it and renders it as a CONTEXT block.
|
|
98
148
|
{
|
|
99
|
-
|
|
149
|
+
// Per agent: the surface replacement generation at which the reminder was
|
|
150
|
+
// last confirmed visible (or delivered). Unchanged generation means no
|
|
151
|
+
// compaction since, so the reminder is still visible and nothing is
|
|
152
|
+
// re-scanned. After a compaction the surface is checked once more and the
|
|
153
|
+
// reminder is re-delivered only if the replacement removed it.
|
|
154
|
+
const checked = new WeakMap();
|
|
155
|
+
const excluded = new Set(config.contextExcludePresetIds);
|
|
100
156
|
ctx.on('agent/pre-step', async ({ agent, signal }, next) => {
|
|
101
157
|
const decision = await next();
|
|
102
158
|
if (decision.kind === 'reject' || signal.aborted)
|
|
103
159
|
return decision;
|
|
104
|
-
if (!flag(config.contextReminder)
|
|
160
|
+
if (!flag(config.contextReminder))
|
|
161
|
+
return decision;
|
|
162
|
+
// Checked every step (cheap), before the generation cache, so a session
|
|
163
|
+
// that later switches away from an excluded preset still gets reminded.
|
|
164
|
+
if (excluded.size > 0) {
|
|
165
|
+
const preset = projectedPreset(ctx, agent.session) ?? agent.session.header.agentPreset;
|
|
166
|
+
if (preset != null && excluded.has(preset))
|
|
167
|
+
return decision;
|
|
168
|
+
}
|
|
169
|
+
const generation = surfaceGeneration(agent);
|
|
170
|
+
if (checked.get(agent) === generation)
|
|
105
171
|
return decision;
|
|
172
|
+
checked.set(agent, generation);
|
|
106
173
|
const present = hasReminder(agent) || decision.messages.some(m => m.source.kind === CONTEXT_SOURCE_KIND);
|
|
107
|
-
delivered.add(agent);
|
|
108
174
|
if (present)
|
|
109
175
|
return decision;
|
|
110
176
|
return {
|
|
@@ -127,7 +193,7 @@ export function apply(ctx, config) {
|
|
|
127
193
|
// Runs once at apply/reload time: re-attach to agents that survived the
|
|
128
194
|
// previous instance's disposal. The no-op disposer satisfies the effect
|
|
129
195
|
// contract; per-agent cleanup is owned by each registration instead.
|
|
130
|
-
for (const agent of ctx
|
|
196
|
+
for (const agent of liveAgents(ctx))
|
|
131
197
|
attach(ctx, agent, config, presetIds, registrations, active);
|
|
132
198
|
return () => { };
|
|
133
199
|
});
|
package/lib/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sour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EAAE,SAAS,EAAE,aAAa,EAAE,MAAM,CAAC,CAAC;QAClG,OAAO,GAAG,EAAE,GAAE,CAAC,CAAC;IAClB,CAAC,CAAC,CAAC;AACL,CAAC"}
|
package/lib/prompt.d.ts
CHANGED
|
@@ -1,10 +1,18 @@
|
|
|
1
1
|
/** Stable prompt bytes: no runtime interpolation, tool inventory, or per-turn state. */
|
|
2
2
|
export declare const SECTION_NAME = "parallel-tools:guidance";
|
|
3
|
-
|
|
3
|
+
/**
|
|
4
|
+
* After every per-tool section (TOOL_* 1000–3000, MCP_SERVERS 3100) so the
|
|
5
|
+
* guidance neither splits the tool descriptions nor precedes the jobs/subagent
|
|
6
|
+
* sections it refers to; before TOOLS_SDK (5000) and output/persona sections.
|
|
7
|
+
*/
|
|
8
|
+
export declare const SECTION_ORDER = 3200;
|
|
4
9
|
/** Shared by both injection channels and the distributed skill description. */
|
|
5
|
-
export declare const BATCH_RULE = "Before
|
|
10
|
+
export declare const BATCH_RULE = "Before each tool-using response, silently list every call whose arguments you already know and send them all together. Per call, ask: could a pending result change whether I make it or what I pass? If not, include it now. A lone call is right only when every other next call depends on its result. Typical batches: a task's opening reads and searches; every file or symbol one result points to (e.g. each frame of a stack trace); edits to different files once their content is known; read-only checks like typecheck, lint and tests. Calls in one response may run concurrently and in any order, so wait when a result decides the next call, approval is needed, or calls touch the same state (read before edit, edit before run, two edits to one file). Don't fake batches: no unrelated commands chained into one shell call, no subagents for quick calls, no speculative calls. While background work runs, do unrelated work; never poll or repeat running or finished calls. Never skip required plan, todo or approval steps.";
|
|
6
11
|
/** The "Tool-call scheduling:" prefix is the verification marker searched for in system/message. */
|
|
7
|
-
export declare const PARALLEL_TOOLS_PROMPT = "Tool-call scheduling: Before
|
|
8
|
-
/**
|
|
9
|
-
|
|
12
|
+
export declare const PARALLEL_TOOLS_PROMPT = "Tool-call scheduling: Before each tool-using response, silently list every call whose arguments you already know and send them all together. Per call, ask: could a pending result change whether I make it or what I pass? If not, include it now. A lone call is right only when every other next call depends on its result. Typical batches: a task's opening reads and searches; every file or symbol one result points to (e.g. each frame of a stack trace); edits to different files once their content is known; read-only checks like typecheck, lint and tests. Calls in one response may run concurrently and in any order, so wait when a result decides the next call, approval is needed, or calls touch the same state (read before edit, edit before run, two edits to one file). Don't fake batches: no unrelated commands chained into one shell call, no subagents for quick calls, no speculative calls. While background work runs, do unrelated work; never poll or repeat running or finished calls. Never skip required plan, todo or approval steps.";
|
|
13
|
+
/**
|
|
14
|
+
* Same rule in the history-backed context channel. Delivered once per visible
|
|
15
|
+
* history, so the prefix states it persists rather than describing one step.
|
|
16
|
+
*/
|
|
17
|
+
export declare const CONTEXT_REMINDER = "Tool-call scheduling (applies to every remaining step of this session): Before each tool-using response, silently list every call whose arguments you already know and send them all together. Per call, ask: could a pending result change whether I make it or what I pass? If not, include it now. A lone call is right only when every other next call depends on its result. Typical batches: a task's opening reads and searches; every file or symbol one result points to (e.g. each frame of a stack trace); edits to different files once their content is known; read-only checks like typecheck, lint and tests. Calls in one response may run concurrently and in any order, so wait when a result decides the next call, approval is needed, or calls touch the same state (read before edit, edit before run, two edits to one file). Don't fake batches: no unrelated commands chained into one shell call, no subagents for quick calls, no speculative calls. While background work runs, do unrelated work; never poll or repeat running or finished calls. Never skip required plan, todo or approval steps.";
|
|
10
18
|
//# sourceMappingURL=prompt.d.ts.map
|
package/lib/prompt.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"prompt.d.ts","sourceRoot":"","sources":["../src/prompt.ts"],"names":[],"mappings":"AAAA,wFAAwF;AACxF,eAAO,MAAM,YAAY,4BAA4B,CAAC;AACtD,eAAO,MAAM,aAAa,OAAO,CAAC;AAElC,+EAA+E;AAC/E,eAAO,MAAM,UAAU,
|
|
1
|
+
{"version":3,"file":"prompt.d.ts","sourceRoot":"","sources":["../src/prompt.ts"],"names":[],"mappings":"AAAA,wFAAwF;AACxF,eAAO,MAAM,YAAY,4BAA4B,CAAC;AACtD;;;;GAIG;AACH,eAAO,MAAM,aAAa,OAAO,CAAC;AAElC,+EAA+E;AAC/E,eAAO,MAAM,UAAU,6/BAA6/B,CAAC;AAErhC,oGAAoG;AACpG,eAAO,MAAM,qBAAqB,mhCAAwC,CAAC;AAE3E;;;GAGG;AACH,eAAO,MAAM,gBAAgB,qkCAA0F,CAAC"}
|
package/lib/prompt.js
CHANGED
|
@@ -1,10 +1,18 @@
|
|
|
1
1
|
/** Stable prompt bytes: no runtime interpolation, tool inventory, or per-turn state. */
|
|
2
2
|
export const SECTION_NAME = 'parallel-tools:guidance';
|
|
3
|
-
|
|
3
|
+
/**
|
|
4
|
+
* After every per-tool section (TOOL_* 1000–3000, MCP_SERVERS 3100) so the
|
|
5
|
+
* guidance neither splits the tool descriptions nor precedes the jobs/subagent
|
|
6
|
+
* sections it refers to; before TOOLS_SDK (5000) and output/persona sections.
|
|
7
|
+
*/
|
|
8
|
+
export const SECTION_ORDER = 3200;
|
|
4
9
|
/** Shared by both injection channels and the distributed skill description. */
|
|
5
|
-
export const BATCH_RULE = `Before
|
|
10
|
+
export const BATCH_RULE = `Before each tool-using response, silently list every call whose arguments you already know and send them all together. Per call, ask: could a pending result change whether I make it or what I pass? If not, include it now. A lone call is right only when every other next call depends on its result. Typical batches: a task's opening reads and searches; every file or symbol one result points to (e.g. each frame of a stack trace); edits to different files once their content is known; read-only checks like typecheck, lint and tests. Calls in one response may run concurrently and in any order, so wait when a result decides the next call, approval is needed, or calls touch the same state (read before edit, edit before run, two edits to one file). Don't fake batches: no unrelated commands chained into one shell call, no subagents for quick calls, no speculative calls. While background work runs, do unrelated work; never poll or repeat running or finished calls. Never skip required plan, todo or approval steps.`;
|
|
6
11
|
/** The "Tool-call scheduling:" prefix is the verification marker searched for in system/message. */
|
|
7
12
|
export const PARALLEL_TOOLS_PROMPT = `Tool-call scheduling: ${BATCH_RULE}`;
|
|
8
|
-
/**
|
|
9
|
-
|
|
13
|
+
/**
|
|
14
|
+
* Same rule in the history-backed context channel. Delivered once per visible
|
|
15
|
+
* history, so the prefix states it persists rather than describing one step.
|
|
16
|
+
*/
|
|
17
|
+
export const CONTEXT_REMINDER = `Tool-call scheduling (applies to every remaining step of this session): ${BATCH_RULE}`;
|
|
10
18
|
//# sourceMappingURL=prompt.js.map
|
package/lib/prompt.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"prompt.js","sourceRoot":"","sources":["../src/prompt.ts"],"names":[],"mappings":"AAAA,wFAAwF;AACxF,MAAM,CAAC,MAAM,YAAY,GAAG,yBAAyB,CAAC;AACtD,MAAM,CAAC,MAAM,aAAa,GAAG,IAAI,CAAC;AAElC,+EAA+E;AAC/E,MAAM,CAAC,MAAM,UAAU,GAAG,
|
|
1
|
+
{"version":3,"file":"prompt.js","sourceRoot":"","sources":["../src/prompt.ts"],"names":[],"mappings":"AAAA,wFAAwF;AACxF,MAAM,CAAC,MAAM,YAAY,GAAG,yBAAyB,CAAC;AACtD;;;;GAIG;AACH,MAAM,CAAC,MAAM,aAAa,GAAG,IAAI,CAAC;AAElC,+EAA+E;AAC/E,MAAM,CAAC,MAAM,UAAU,GAAG,0/BAA0/B,CAAC;AAErhC,oGAAoG;AACpG,MAAM,CAAC,MAAM,qBAAqB,GAAG,yBAAyB,UAAU,EAAE,CAAC;AAE3E;;;GAGG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG,2EAA2E,UAAU,EAAE,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-parallel-tools-prompt",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.5",
|
|
4
4
|
"description": "Plan ready tool-call batches to reduce model round trips in DeepSeek Harness",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -10,7 +10,10 @@
|
|
|
10
10
|
"bugs": {
|
|
11
11
|
"url": "https://github.com/lloydzhou/dsh-parallel-tools-prompt/issues"
|
|
12
12
|
},
|
|
13
|
-
"publishConfig": {
|
|
13
|
+
"publishConfig": {
|
|
14
|
+
"access": "public",
|
|
15
|
+
"tag": "next"
|
|
16
|
+
},
|
|
14
17
|
"type": "module",
|
|
15
18
|
"license": "MIT",
|
|
16
19
|
"main": "./lib/index.js",
|
|
@@ -22,9 +25,19 @@
|
|
|
22
25
|
},
|
|
23
26
|
"./client": "./lib/client.js",
|
|
24
27
|
"./locale/*.json": "./locale/*.json",
|
|
28
|
+
"./icon": "./icon.svg",
|
|
25
29
|
"./package.json": "./package.json"
|
|
26
30
|
},
|
|
27
|
-
"files": [
|
|
31
|
+
"files": [
|
|
32
|
+
"lib",
|
|
33
|
+
"locale",
|
|
34
|
+
"icon.svg",
|
|
35
|
+
"cordis.patch.yml",
|
|
36
|
+
"README.md",
|
|
37
|
+
"LICENSE",
|
|
38
|
+
"skills",
|
|
39
|
+
"scripts/analyze-session.mjs"
|
|
40
|
+
],
|
|
28
41
|
"engines": {
|
|
29
42
|
"node": ">=24.9.0",
|
|
30
43
|
"dsh": ">=0.2.3-alpha.2"
|
|
@@ -1,17 +1,43 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: batch-tool-calls
|
|
3
|
-
description: "Before
|
|
3
|
+
description: "Before each tool-using response, silently list every call whose arguments you already know and send them all together. Per call, ask: could a pending result change whether I make it or what I pass? If not, include it now. A lone call is right only when every other next call depends on its result. Typical batches: a task's opening reads and searches; every file or symbol one result points to (e.g. each frame of a stack trace); edits to different files once their content is known; read-only checks like typecheck, lint and tests. Calls in one response may run concurrently and in any order, so wait when a result decides the next call, approval is needed, or calls touch the same state (read before edit, edit before run, two edits to one file). Don't fake batches: no unrelated commands chained into one shell call, no subagents for quick calls, no speculative calls. While background work runs, do unrelated work; never poll or repeat running or finished calls. Never skip required plan, todo or approval steps."
|
|
4
4
|
---
|
|
5
5
|
|
|
6
6
|
# Batch ready tool calls
|
|
7
7
|
|
|
8
|
-
|
|
8
|
+
## The test
|
|
9
9
|
|
|
10
|
-
|
|
11
|
-
2. Wait when a result determines whether or how to act, approval is pending, or shared-state ordering requires it (including read-before-edit). Real dependency chains and single calls are valid; never invent work to fill a batch.
|
|
12
|
-
3. While background work runs, continue useful work that neither needs its results nor interferes with its state. Follow the host's job tracking and result collection rules; do not busy-poll or duplicate running/completed calls or delegations. After results arrive, reassess what is ready.
|
|
13
|
-
4. Use tools as intended, not shell wrappers or delegation solely to simulate batching. Do not print a DAG or add scheduling-only turns; required plan, todo, and approval workflows still apply.
|
|
10
|
+
Before each tool-using response, silently list every call whose arguments you already know. For each one ask: **could a pending result change whether I make this call, or what I pass to it?** If not, it is ready: send it in this response. Do not print the list or spend a turn on scheduling.
|
|
14
11
|
|
|
15
|
-
|
|
12
|
+
A response with a single call is right only when every other call you would make next depends on that call's result.
|
|
16
13
|
|
|
17
|
-
|
|
14
|
+
If you think in dependency graphs: this test picks out the current ready layer, the calls with no unmet dependency. Send that whole layer at once; you never need to plan the full graph.
|
|
15
|
+
|
|
16
|
+
## Batch these
|
|
17
|
+
|
|
18
|
+
- **Opening reads and searches.** Starting a task that names `src/a.ts`, `src/b.ts` and a config file: read all three and run the search for the symbol in one response.
|
|
19
|
+
- **One result, several follow-ups.** A stack trace names three files, or a search returns four matches you need to inspect: read all of them together, not one per turn.
|
|
20
|
+
- **Independent edits.** Once you know the change for each file, edit different files in the same response.
|
|
21
|
+
- **Read-only checks.** After edits are done, typecheck, lint and tests that do not write shared state go together.
|
|
22
|
+
|
|
23
|
+
## Wait for these
|
|
24
|
+
|
|
25
|
+
Calls in one response may run concurrently and in any order. Keep calls in separate responses when:
|
|
26
|
+
|
|
27
|
+
- a result decides whether to make the next call or what it takes (a search must find a path before you read it; don't guess the path);
|
|
28
|
+
- approval is required first;
|
|
29
|
+
- they touch the same state: read before edit, edit before run, two edits to one file, write then read back.
|
|
30
|
+
|
|
31
|
+
`test → read failure → fix → retest` is a valid serial chain, and so is a single call when nothing else is ready.
|
|
32
|
+
|
|
33
|
+
## Don't fake batches
|
|
34
|
+
|
|
35
|
+
- Don't chain unrelated commands into one shell call (`cat a; cat b; ls c`) to look parallel; use separate tool calls. A command whose steps really depend on each other (`build && test`) is fine.
|
|
36
|
+
- Don't launch subagents just to parallelize quick calls.
|
|
37
|
+
- Don't add speculative calls you would not otherwise make.
|
|
38
|
+
|
|
39
|
+
## Background work
|
|
40
|
+
|
|
41
|
+
While a background job or subagent runs, do work that neither needs its result nor touches its state (e.g. read unrelated docs while tests run; don't edit files the tests depend on). Don't busy-poll, and never repeat a call or delegation that is running or finished.
|
|
42
|
+
|
|
43
|
+
Required plan, todo and approval workflows still apply. Actual concurrency is up to the host scheduler; the goal is fewer avoidable model round trips.
|