dsh-workplan 1.8.4 → 1.9.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +686 -0
- package/README.en.md +1 -1
- package/README.md +1 -1
- package/client.js +18 -2
- package/docs/postmortem-1.8.4-20261030.md +51 -0
- package/docs/postmortem-1.8.7-20261031.md +498 -0
- package/docs/release-notes-1.9.1.md +67 -0
- package/docs/release-record-1.8.4-20261030.md +70 -0
- package/lib/host.js +345 -31
- package/lib/plan.js +494 -17
- package/lib/runtime.js +1819 -124
- package/lib/supersede-digest.js +115 -0
- package/lib/supersede.js +378 -0
- package/package.json +2 -2
- package/src/client.ts +19 -2
- package/src/host.ts +370 -33
- package/src/plan.ts +537 -17
- package/src/runtime.ts +1813 -114
- package/src/supersede-digest.ts +116 -0
- package/src/supersede.ts +429 -0
package/lib/plan.js
CHANGED
|
@@ -7,7 +7,55 @@
|
|
|
7
7
|
* runtime and by unit tests.
|
|
8
8
|
*/
|
|
9
9
|
import { randomUUID } from 'node:crypto';
|
|
10
|
+
import { isMappingDigest, verifyMappingDigest } from './supersede-digest.js';
|
|
10
11
|
export const PLAN_VERSION = 1;
|
|
12
|
+
/**
|
|
13
|
+
* [1.9.0] 处置终态:cancelled(用户撤销)与 superseded(责任已转移)。
|
|
14
|
+
*
|
|
15
|
+
* 两者都是终态:记录与计数原样保留,永不算完成,也永不被自动选为
|
|
16
|
+
* `present` 的判定对象;只有「本回合结构化点名」时才判定(cancelled 仍硬拦)。
|
|
17
|
+
* 规则依据:_rerun_20261101/GATE_rule_design.md §3.1。
|
|
18
|
+
*/
|
|
19
|
+
export const TERMINAL_PHASES = new Set(['cancelled', 'superseded']);
|
|
20
|
+
export function isTerminalPhase(phase) {
|
|
21
|
+
return typeof phase === 'string' && TERMINAL_PHASES.has(phase);
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* [1.9.2] `present` 拒绝码(P1 统一)。
|
|
25
|
+
*
|
|
26
|
+
* 规则出处:`_rerun_20261101/GATE_rule_design.md` §4.3(P1/P2 与
|
|
27
|
+
* `judgeEffective`)及 §4.4 真值表;最小修法出处:
|
|
28
|
+
* `_rerun_20261101/GATE_case_matrix.md` §3.2(T9 的唯一不一致格
|
|
29
|
+
* `C05.denyCode`)。
|
|
30
|
+
*
|
|
31
|
+
* T8 原文的 P1 把「全部 done 但证据缺口」和「还有子任务没做完」合并成
|
|
32
|
+
* 一个码值 `ACTIVE_NOT_READY`,于是 R2/G02 的 `EVIDENCE_GAP` 在未点名时
|
|
33
|
+
* 永远走不到。修法只拆一个维度:`remaining` 为空且 `blockers` 非空
|
|
34
|
+
* ⇒ `EVIDENCE_GAP`,其余仍是 `ACTIVE_NOT_READY`。这本来就是 1.8.19 的
|
|
35
|
+
* 既有语义(`remaining.length === 0` 有独立文案),不是新增语义。
|
|
36
|
+
*
|
|
37
|
+
* 码值是对外契约:测试、日志与后续 UI 按字面值断言。所有拒绝点只能引用
|
|
38
|
+
* 这里的常量或 `activeDenyCode()`,不得再手写字符串。
|
|
39
|
+
*/
|
|
40
|
+
export const PRESENT_DENY_CODES = {
|
|
41
|
+
ACTIVE_NOT_READY: 'ACTIVE_NOT_READY',
|
|
42
|
+
EVIDENCE_GAP: 'EVIDENCE_GAP',
|
|
43
|
+
CANCELLED_NAMED: 'CANCELLED_NAMED',
|
|
44
|
+
SUPERSEDED_STALE: 'SUPERSEDED_STALE',
|
|
45
|
+
};
|
|
46
|
+
/**
|
|
47
|
+
* P1 的单一映射:active 计划未就绪时,只由交付就绪结果决定拒绝码。
|
|
48
|
+
*
|
|
49
|
+
* 调用点(`present` 的未完成分支、点名 active 计划的判定)必须走这个函数,
|
|
50
|
+
* 不要在分支里各写一份判断——T9 的 C05 不一致正是「规则一个码、实现另一个
|
|
51
|
+
* 码」造成的。终态计划不走这里:cancelled 是 `CANCELLED_NAMED`,superseded
|
|
52
|
+
* 按覆盖链给 `SUPERSEDED_STALE` / `ACTIVE_NOT_READY`。
|
|
53
|
+
*/
|
|
54
|
+
export function activeDenyCode(readiness) {
|
|
55
|
+
return readiness.remaining.length === 0 && readiness.blockers.length > 0
|
|
56
|
+
? PRESENT_DENY_CODES.EVIDENCE_GAP
|
|
57
|
+
: PRESENT_DENY_CODES.ACTIVE_NOT_READY;
|
|
58
|
+
}
|
|
11
59
|
export const MAX_STAGES = 6;
|
|
12
60
|
export const MAX_SUBTASKS = 15;
|
|
13
61
|
export const MAX_CONCURRENT = 5;
|
|
@@ -82,6 +130,43 @@ export function messageText(message) {
|
|
|
82
130
|
.map((block) => block.text)
|
|
83
131
|
.join('\n');
|
|
84
132
|
}
|
|
133
|
+
/*
|
|
134
|
+
* [1.8.12] 不能让正文里的「包名:行号」变成跨会话引用。
|
|
135
|
+
*
|
|
136
|
+
* Harness 的 session-reference 在 `agent/pre-step` 阶段扫描每条
|
|
137
|
+
* `source.kind === 'user'` 消息的文本块,正则会把裸的
|
|
138
|
+
* `dsh-session:<payload>` 当成引用候选;候选无法按 base64url+JSON 解码时抛
|
|
139
|
+
* SessionReferenceError,整个 turn 在第一次模型调用之前就结束。部门子 Agent
|
|
140
|
+
* 的首条消息正是 user 消息,所以父会话历史里只要有人写过
|
|
141
|
+
* `dsh-session:1980`(“dsh-session 包第 1980 行”),子任务就会表现为
|
|
142
|
+
* “处理失败 / 无响应”,且没有任何模型步可以解释。
|
|
143
|
+
*
|
|
144
|
+
* 插件侧的防线:拼装子任务提示词时,把无法规范化的裸 token 转义成
|
|
145
|
+
* `dsh-session\:<payload>`,肉眼仍是同一段文字,但不再命中引用正则。
|
|
146
|
+
* 规范 URI(真正的跨会话引用)保持原样。
|
|
147
|
+
*/
|
|
148
|
+
const SESSION_URI_PREFIX = 'dsh-session:';
|
|
149
|
+
const BARE_SESSION_URI = /dsh-session:([A-Za-z0-9_-]+)/gu;
|
|
150
|
+
export function isCanonicalSessionUri(uri) {
|
|
151
|
+
if (typeof uri !== 'string' || !uri.startsWith(SESSION_URI_PREFIX))
|
|
152
|
+
return false;
|
|
153
|
+
const payload = uri.slice(SESSION_URI_PREFIX.length);
|
|
154
|
+
if (!/^[A-Za-z0-9_-]+$/.test(payload))
|
|
155
|
+
return false;
|
|
156
|
+
try {
|
|
157
|
+
const decoded = JSON.parse(Buffer.from(payload, 'base64url').toString('utf8'));
|
|
158
|
+
return typeof decoded === 'string'
|
|
159
|
+
&& Buffer.from(JSON.stringify(decoded), 'utf8').toString('base64url') === payload;
|
|
160
|
+
}
|
|
161
|
+
catch {
|
|
162
|
+
return false;
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
export function defuseSessionReferenceText(text) {
|
|
166
|
+
if (typeof text !== 'string' || !text.includes(SESSION_URI_PREFIX))
|
|
167
|
+
return text;
|
|
168
|
+
return text.replace(BARE_SESSION_URI, (match, payload) => (isCanonicalSessionUri(`${SESSION_URI_PREFIX}${payload}`) ? match : `dsh-session\\:${payload}`));
|
|
169
|
+
}
|
|
85
170
|
/*
|
|
86
171
|
* Lightweight conversational inputs must not start the planning pipeline.
|
|
87
172
|
*
|
|
@@ -889,10 +974,60 @@ export function buildDegradedMessage(options) {
|
|
|
889
974
|
}
|
|
890
975
|
export function buildResultSummary(result) {
|
|
891
976
|
const stats = result.stats ?? { done: 0, total: 0, blocked: 0 };
|
|
892
|
-
|
|
977
|
+
const done = Number(stats.done ?? 0);
|
|
978
|
+
const total = Number(stats.total ?? 0);
|
|
979
|
+
const remaining = Math.max(0, total - done);
|
|
980
|
+
/*
|
|
981
|
+
* [1.8.7] 「请主 Agent 核对并整合」在未完成时也是一条误导:它把这一轮当成
|
|
982
|
+
* 已经可以交付,只差整合。剩余项必须出现在摘要第一句,模型只读摘要也能看到。
|
|
983
|
+
*/
|
|
984
|
+
/*
|
|
985
|
+
* [1.8.15] Cancel is a terminal state, not a pause.
|
|
986
|
+
*
|
|
987
|
+
* 1.8.13 already refused `present` for a cancelled plan, but the round's
|
|
988
|
+
* result message still said "请继续派发", and `dsh_workplan_dispatch`
|
|
989
|
+
* complied by really starting another round (T4e F1/C16: `activationCalled:
|
|
990
|
+
* true`, `ok: true`). A summary that tells the model to dispatch a cancelled
|
|
991
|
+
* plan is the root of that contradiction; this text now has one meaning:
|
|
992
|
+
* cancelled ≠ complete, and there is nothing left to resume.
|
|
993
|
+
*/
|
|
994
|
+
if (result.phase === 'cancelled') {
|
|
995
|
+
return truncate(remaining > 0
|
|
996
|
+
? `【部门执行结果】已取消:只完成 ${done}/${total},剩余 ${remaining} 项未完成;取消只停止执行,不得交付,也不要再次派发`
|
|
997
|
+
: `【部门执行结果】已取消:完成 ${done}/${total};取消只停止执行,不得交付`, 300);
|
|
998
|
+
}
|
|
999
|
+
if (remaining > 0) {
|
|
1000
|
+
return truncate(`【部门执行结果】未完成:完成 ${done}/${total},剩余 ${remaining} 项,受阻 ${Number(stats.blocked ?? 0)};请主 Agent 核对后继续派发,完成前不得交付`, 300);
|
|
1001
|
+
}
|
|
1002
|
+
/*
|
|
1003
|
+
* [1.8.13] All rows done is not the same as deliverable. The summary used to
|
|
1004
|
+
* say "请核对并整合" even when every done row had legacy/empty evidence, so a
|
|
1005
|
+
* model that only read the summary could close the turn as finished.
|
|
1006
|
+
*/
|
|
1007
|
+
const statuses = Array.isArray(result.statuses) ? result.statuses : [];
|
|
1008
|
+
if (statuses.length > 0) {
|
|
1009
|
+
const readiness = deliveryReadiness(derivePlanSnapshot(statuses), { phase: result.phase });
|
|
1010
|
+
if (!readiness.ready) {
|
|
1011
|
+
const shown = readiness.blockers.slice(0, 2).join(';');
|
|
1012
|
+
return truncate(`【部门执行结果】未完成:完成 ${done}/${total} 但证据未通过${shown ? `(${shown}${readiness.blockers.length > 2 ? '…' : ''})` : ''};证据补齐前不得交付`, 300);
|
|
1013
|
+
}
|
|
1014
|
+
}
|
|
1015
|
+
return truncate(`【部门执行结果】完成 ${done}/${total},受阻 ${Number(stats.blocked ?? 0)},请主 Agent 核对并整合`, 300);
|
|
893
1016
|
}
|
|
894
1017
|
export function buildResultMessage(result) {
|
|
895
1018
|
const summary = buildResultSummary(result);
|
|
1019
|
+
/*
|
|
1020
|
+
* [1.8.13] Compute delivery readiness once, from the same statuses that ship
|
|
1021
|
+
* in the payload. The result message used to tell the model "给出最终答复"
|
|
1022
|
+
* whenever done === total, even when present would immediately refuse the
|
|
1023
|
+
* delivery for legacy/empty evidence. One predicate now feeds the summary,
|
|
1024
|
+
* the instruction block and the durable payload.
|
|
1025
|
+
*/
|
|
1026
|
+
const statuses = Array.isArray(result.statuses) ? result.statuses : [];
|
|
1027
|
+
const readiness = statuses.length > 0
|
|
1028
|
+
? deliveryReadiness(derivePlanSnapshot(statuses), { phase: result.phase })
|
|
1029
|
+
: null;
|
|
1030
|
+
const deliveryBlockers = readiness?.blockers ?? [];
|
|
896
1031
|
const payload = {
|
|
897
1032
|
kind: 'workplan-result',
|
|
898
1033
|
version: PLAN_VERSION,
|
|
@@ -913,6 +1048,10 @@ export function buildResultMessage(result) {
|
|
|
913
1048
|
// "never resumed", instead of promising a retry that will be refused.
|
|
914
1049
|
resumeCount: Number(result.resumeCount ?? 0),
|
|
915
1050
|
resumeAvailable: result.resumeAvailable === true,
|
|
1051
|
+
// [1.8.13] The delivery verdict travels with the round so a reload cannot
|
|
1052
|
+
// re-derive a more optimistic "done" from the statuses alone.
|
|
1053
|
+
deliveryReady: readiness ? readiness.ready : undefined,
|
|
1054
|
+
deliveryBlockers: deliveryBlockers.slice(0, 12),
|
|
916
1055
|
};
|
|
917
1056
|
const blocked = Number(result.stats?.blocked ?? 0);
|
|
918
1057
|
const paused = Number(result.stats?.pending ?? 0) > 0 && result.phase === 'paused';
|
|
@@ -924,7 +1063,6 @@ export function buildResultMessage(result) {
|
|
|
924
1063
|
* are missing, and what a sibling department asked for. Keeping this out of
|
|
925
1064
|
* the payload (it is derived) keeps the durable message small.
|
|
926
1065
|
*/
|
|
927
|
-
const statuses = Array.isArray(result.statuses) ? result.statuses : [];
|
|
928
1066
|
const unverified = statuses.filter((item) => item?.verification === 'unverified');
|
|
929
1067
|
const failed = statuses.filter((item) => item?.verification === 'failed');
|
|
930
1068
|
const legacy = statuses.filter((item) => item?.status === 'done' && item?.verification === 'legacy');
|
|
@@ -944,27 +1082,67 @@ export function buildResultMessage(result) {
|
|
|
944
1082
|
if (missingArtifacts.length > 0) {
|
|
945
1083
|
review.push(`- 声明产物缺失:${missingArtifacts.slice(0, 10).join(';')}`);
|
|
946
1084
|
}
|
|
1085
|
+
/*
|
|
1086
|
+
* [1.8.7] 未完成时不能再命令「给出最终答复」。
|
|
1087
|
+
*
|
|
1088
|
+
* 事故(session-99984ebd…,2026-10-31 12:02):预算到点返回 10/13,本条消息
|
|
1089
|
+
* 第 3 条却写着「给出最终答复」,第 4 条又要求「再次派发续跑」。两条命令
|
|
1090
|
+
* 互相抵触,模型照前者收尾,于是用户在计划只完成 10/13 时拿到了「成品」。
|
|
1091
|
+
* 现在:未完成时第 3 条改为「禁止交付」,恢复动作固定为第 4 条;只有全部
|
|
1092
|
+
* 子任务 done 才允许收尾。
|
|
1093
|
+
*/
|
|
1094
|
+
const doneCount = Number(result.stats?.done ?? 0);
|
|
1095
|
+
const totalCount = Number(result.stats?.total ?? 0);
|
|
1096
|
+
const remaining = Math.max(0, totalCount - doneCount);
|
|
1097
|
+
const incomplete = totalCount > 0 && remaining > 0;
|
|
1098
|
+
/*
|
|
1099
|
+
* [1.8.13] All rows done but evidence not passing is a distinct blocked
|
|
1100
|
+
* state. It must not fall into the "完成 ⇒ 给出最终答复" branch: present
|
|
1101
|
+
* would reject the very delivery the message just ordered.
|
|
1102
|
+
*/
|
|
1103
|
+
const evidenceBlocked = !incomplete && Boolean(readiness && !readiness.ready);
|
|
1104
|
+
/*
|
|
1105
|
+
* [1.8.15] A cancelled round has no legal next dispatch.
|
|
1106
|
+
*
|
|
1107
|
+
* T4e F1/C16 proved the old text ("再次调用 dsh_workplan_dispatch 即可继续跑")
|
|
1108
|
+
* started a real round on a cancelled plan. Cancel is terminal here: no
|
|
1109
|
+
* present, no "已完成", no dispatch — only an honest 未完成 reply.
|
|
1110
|
+
*/
|
|
1111
|
+
const cancelled = result.phase === 'cancelled';
|
|
1112
|
+
const shownBlockers = deliveryBlockers.slice(0, 8).join(';');
|
|
1113
|
+
const recovery = blocked > 0
|
|
1114
|
+
? (result.resumeAvailable === false
|
|
1115
|
+
? `本计划已用尽自动续跑额度(${Number(result.resumeCount ?? 0)}/${MAX_PLAN_RESUMES}),受阻项不会再自动重跑:请主 Agent 直接接手完成剩余 ${remaining} 项,完成前同样不得交付。`
|
|
1116
|
+
: `受阻项可再次调用 dsh_workplan_dispatch 从受阻处续跑(已完成的不会重跑,本计划剩余续跑额度 ${MAX_PLAN_RESUMES - Number(result.resumeCount ?? 0)} 次)。`)
|
|
1117
|
+
: paused
|
|
1118
|
+
? `本轮执行预算用尽,剩余 ${Number(result.stats?.pending ?? 0)} 项未完成(不是失败、未计入续跑额度):再次调用 dsh_workplan_dispatch 即可从剩下的步骤继续,已完成的不重跑。`
|
|
1119
|
+
: `剩余 ${remaining} 项子任务还没有完成:再次调用 dsh_workplan_dispatch 即可继续跑,已完成的不重跑。`;
|
|
947
1120
|
const lines = [
|
|
948
1121
|
summary,
|
|
949
1122
|
'',
|
|
950
1123
|
'各部门子任务结果如下,请主 Agent:',
|
|
951
1124
|
'1. 核对每个完成项的证据与验收标准;',
|
|
952
1125
|
'2. 处理受阻项,必要时向用户确认;',
|
|
953
|
-
|
|
1126
|
+
...(cancelled
|
|
1127
|
+
? [
|
|
1128
|
+
`3. 【已取消但未完成,禁止交付】计划只完成 ${doneCount}/${totalCount},剩余 ${remaining} 项(取消只停止执行,不等于完成):不要调用 present,不要写“已完成/最终版/已交付”,不要给出收尾性最终答复,不要声称未验证的完成。`,
|
|
1129
|
+
'4. 不要再调用 dsh_workplan_dispatch(计划已取消,不会启动任何部门 Agent)。如需继续这项工作,请向用户确认后重新生成计划。答复开头必须写「未完成:剩余 N 项与原因」。',
|
|
1130
|
+
]
|
|
1131
|
+
: incomplete
|
|
1132
|
+
? [
|
|
1133
|
+
`3. 【未完成,禁止交付】计划只完成 ${doneCount}/${totalCount},还有 ${remaining} 项没做完:不要调用 present 交付当前产物,不要写“已完成/最终版/已交付”,也不要给出收尾性最终答复,不要声称未验证的完成。`,
|
|
1134
|
+
`4. ${recovery}`,
|
|
1135
|
+
]
|
|
1136
|
+
: evidenceBlocked
|
|
1137
|
+
? [
|
|
1138
|
+
`3. 【证据未通过,禁止交付】计划 ${doneCount}/${totalCount} 虽已全部 done,但以下证据缺口未通过:${shownBlockers}${deliveryBlockers.length > 8 ? '…' : ''}。不要调用 present,不要写“已完成/最终版/已交付”,不要给出收尾性最终答复,不要声称未验证的完成。`,
|
|
1139
|
+
'4. 先用 dsh_workplan_update 为这些子任务补齐 verification=\'structured\' 与 acceptance(每项 result=\'pass\',并附证据),或把对应子任务改回 blocked 并写明原因;缺口补齐、deliveryReady 变为 true 之后 present 才会放行。',
|
|
1140
|
+
]
|
|
1141
|
+
: ['3. 给出最终答复,不要声称未验证的完成。']),
|
|
954
1142
|
...(review.length > 0 ? ['', '验收核对:', ...review] : []),
|
|
955
1143
|
...(needs.length > 0
|
|
956
1144
|
? ['', '跨部门待转达(子 Agent 提出的需求,请逐条处理):', ...needs.slice(0, 10).map((line) => `- ${line}`)]
|
|
957
1145
|
: []),
|
|
958
|
-
// A blocked plan used to look identical to a finished one. State the exact
|
|
959
|
-
// recovery move so the model retries the failed work instead of rebuilding
|
|
960
|
-
// the whole plan or stopping to ask the user for a repeated request.
|
|
961
|
-
...(blocked > 0
|
|
962
|
-
? [result.resumeAvailable === false
|
|
963
|
-
? `4. 本计划已用尽自动续跑额度(${Number(result.resumeCount ?? 0)}/${MAX_PLAN_RESUMES}),受阻项不会再自动重跑:请主 Agent 直接接手完成,不要重复派发。`
|
|
964
|
-
: `4. 受阻项可再次调用 dsh_workplan_dispatch 从受阻处续跑(已完成的不会重跑,本计划剩余续跑额度 ${MAX_PLAN_RESUMES - Number(result.resumeCount ?? 0)} 次)。`]
|
|
965
|
-
: paused
|
|
966
|
-
? [`4. 本轮执行预算用尽,剩余 ${Number(result.stats?.pending ?? 0)} 项未完成(不是失败、未计入续跑额度):再次调用 dsh_workplan_dispatch 即可从剩下的步骤继续,已完成的不重跑。`]
|
|
967
|
-
: []),
|
|
968
1146
|
'',
|
|
969
1147
|
RESULT_MARKER_BEGIN,
|
|
970
1148
|
JSON.stringify(payload),
|
|
@@ -976,6 +1154,94 @@ export function buildResultMessage(result) {
|
|
|
976
1154
|
summary,
|
|
977
1155
|
});
|
|
978
1156
|
}
|
|
1157
|
+
/**
|
|
1158
|
+
* [1.8.7] 回合收尾前注入的「计划没做完」指令。
|
|
1159
|
+
*
|
|
1160
|
+
* 事故(session-99984ebd…)里,计划停在 10/13,主 Agent 却已经 present 了报告
|
|
1161
|
+
* 并给出收尾答复。软约束(系统提示词)挡不住这种收尾,所以由 runtime 在
|
|
1162
|
+
* `agent/turn-stopping` 里 `agent.steer()` 这条消息,强制再跑一步去续跑。
|
|
1163
|
+
*
|
|
1164
|
+
* 措辞必须同时做到三件事:说清剩余量、禁止交付措辞、给出唯一恢复动作;不含
|
|
1165
|
+
* 任何「已完成」的暗示,也不假装这是用户说的话(source.kind 单独标记)。
|
|
1166
|
+
*/
|
|
1167
|
+
export function buildStopSteerText(input) {
|
|
1168
|
+
const stats = input?.stats ?? {};
|
|
1169
|
+
const total = Number(stats.total ?? 0);
|
|
1170
|
+
const done = Number(stats.done ?? 0);
|
|
1171
|
+
const remaining = Math.max(0, total - done);
|
|
1172
|
+
const statuses = Array.isArray(input?.statuses) ? input.statuses : [];
|
|
1173
|
+
const snapshot = statuses.length > 0 ? derivePlanSnapshot(statuses) : null;
|
|
1174
|
+
const readiness = snapshot ? deliveryReadiness(snapshot, { phase: input?.phase }) : null;
|
|
1175
|
+
const blockers = readiness?.blockers ?? [];
|
|
1176
|
+
const ids = statuses
|
|
1177
|
+
.filter((item) => item?.status !== 'done')
|
|
1178
|
+
.map((item) => String(item?.subtaskId ?? ''))
|
|
1179
|
+
.filter((id) => id !== '')
|
|
1180
|
+
.slice(0, 10);
|
|
1181
|
+
const runnable = statuses.filter((item) => item?.status === 'pending' || item?.status === 'in_progress').length;
|
|
1182
|
+
const attempt = Number(input?.attempt ?? 1);
|
|
1183
|
+
const planLabel = `计划 ${String(input?.planId ?? '')}`;
|
|
1184
|
+
const footer = `(这是 dsh-workplan 在回合收尾前自动发出的第 ${attempt} 次提醒:计划未通过交付就绪检查,这个回合暂不关闭。)`;
|
|
1185
|
+
/*
|
|
1186
|
+
* [1.8.13] One gate, four truthful messages.
|
|
1187
|
+
*
|
|
1188
|
+
* 1.8.8 only steered while `pending/in_progress` existed, so an all-done plan
|
|
1189
|
+
* with legacy/empty evidence closed the turn normally (T5-B/D), and a
|
|
1190
|
+
* cancelled plan was released outright (T5-C). Each branch below keeps the
|
|
1191
|
+
* same contract — no present, no completion wording, start with 未完成 —
|
|
1192
|
+
* but only the first asks for another dispatch, because only it has runnable
|
|
1193
|
+
* work. The others would otherwise spin forever on an empty dispatch.
|
|
1194
|
+
*/
|
|
1195
|
+
if (readiness?.cancelled && !readiness.ready) {
|
|
1196
|
+
const scope = remaining > 0
|
|
1197
|
+
? `已取消,只完成 ${done}/${total},还有 ${remaining} 项没做完${ids.length > 0 ? `(${ids.join('、')})` : ''}`
|
|
1198
|
+
: `已取消,完成 ${done}/${total},但证据未通过:${blockers.slice(0, 4).join(';')}`;
|
|
1199
|
+
return [
|
|
1200
|
+
`【计划已取消但未完成 · 禁止收尾】${planLabel} ${scope}。`,
|
|
1201
|
+
'',
|
|
1202
|
+
'取消只停止执行,不等于完成;当前内容不能当作最终结果交付。',
|
|
1203
|
+
'1. 不要再调用 dsh_workplan_dispatch(计划已取消,不会继续执行)。',
|
|
1204
|
+
'2. 不要调用 present;不要写“已完成/最终版/已交付”;不要输出收尾性最终结论。',
|
|
1205
|
+
`3. 答复开头必须写「未完成:剩余 ${Math.max(remaining, blockers.length)} 项(列出 ID)与原因」,说明取消原因与未完成范围。`,
|
|
1206
|
+
'',
|
|
1207
|
+
footer,
|
|
1208
|
+
].join('\n');
|
|
1209
|
+
}
|
|
1210
|
+
if (readiness && !readiness.ready && remaining === 0) {
|
|
1211
|
+
return [
|
|
1212
|
+
`【证据未通过 · 禁止交付】${planLabel} 的 ${done}/${total} 个子任务虽都已 done,但证据未通过:${blockers.slice(0, 8).join(';')}${blockers.length > 8 ? '…' : ''}。`,
|
|
1213
|
+
'',
|
|
1214
|
+
'当前内容不能作为成品交付。请立即处理证据缺口:',
|
|
1215
|
+
"1. 不要调用 present;不要写“已完成/最终版/已交付”;不要输出收尾性最终结论。",
|
|
1216
|
+
"2. 用 dsh_workplan_update 为这些子任务补齐 verification='structured' 与 acceptance(每项 result='pass',并附证据),或把对应子任务改回 blocked 并写明原因。",
|
|
1217
|
+
'3. 在证据补齐、deliveryReady 变为 true 之前,不得声称完成;确实无法补齐时,答复开头写「未完成:剩余 N 项与原因」。',
|
|
1218
|
+
'',
|
|
1219
|
+
footer,
|
|
1220
|
+
].join('\n');
|
|
1221
|
+
}
|
|
1222
|
+
if (remaining > 0 && runnable === 0) {
|
|
1223
|
+
return [
|
|
1224
|
+
`【剩余项全部受阻 · 禁止收尾】${planLabel} 只完成 ${done}/${total},还有 ${remaining} 项没完成${ids.length > 0 ? `(${ids.join('、')})` : ''},当前没有可自动续跑的项。`,
|
|
1225
|
+
'',
|
|
1226
|
+
'现在不能把当前内容当作最终结果交付。',
|
|
1227
|
+
'1. 不要调用 present;不要写“已完成/最终版/已交付”;不要声称完成。',
|
|
1228
|
+
'2. 向用户说明受阻项与原因,答复开头必须写「未完成:剩余 N 项(列出 ID)与原因」。',
|
|
1229
|
+
'3. 如用户确认终止,可调用 dsh_workplan_cancel;取消只停止执行,不改变“未完成”的结论。',
|
|
1230
|
+
'',
|
|
1231
|
+
footer,
|
|
1232
|
+
].join('\n');
|
|
1233
|
+
}
|
|
1234
|
+
return [
|
|
1235
|
+
`【计划未完成 · 禁止收尾】${planLabel} 只完成 ${done}/${total},还有 ${remaining} 项没做完${ids.length > 0 ? `(${ids.join('、')})` : ''}。`,
|
|
1236
|
+
'',
|
|
1237
|
+
'现在不能把当前内容当作最终结果交付。请立即继续:',
|
|
1238
|
+
'1. 调用 dsh_workplan_dispatch(默认 wait)续跑剩余子任务;已完成的不重跑。',
|
|
1239
|
+
'2. 在计划通过交付就绪检查之前:不要调用 present;不要写“已完成/最终版/已交付”;不要输出收尾性最终结论。',
|
|
1240
|
+
'3. 若续跑被拒绝或持续失败,答复开头必须写「未完成:剩余 N 项(列出 ID)与原因」,不得把它包装成成品。',
|
|
1241
|
+
'',
|
|
1242
|
+
footer,
|
|
1243
|
+
].join('\n');
|
|
1244
|
+
}
|
|
979
1245
|
function extractBetween(text, begin, end) {
|
|
980
1246
|
if (typeof text !== 'string')
|
|
981
1247
|
return null;
|
|
@@ -1015,7 +1281,27 @@ export function parseResultMessage(message) {
|
|
|
1015
1281
|
return null;
|
|
1016
1282
|
}
|
|
1017
1283
|
}
|
|
1018
|
-
|
|
1284
|
+
/*
|
|
1285
|
+
* [1.9.2] `workplan-cancel` 信封是 cancelled / superseded 的**唯一写入出口**。
|
|
1286
|
+
*
|
|
1287
|
+
* 规则出处:`_rerun_20261101/GATE_rule_design.md` §6.1(字段 schema)、§7.2
|
|
1288
|
+
* 第 7 条(写入 durable 记录后 replay 仍为 superseded)。写侧任何地方都不得
|
|
1289
|
+
* 自己拼这段 JSON:一旦有第二条拼装路径,`disposition`/`supersededBy` 的字段
|
|
1290
|
+
* 形状就会分叉,replay 与 present 的读侧判定随之失效(正是本子任务要杜绝的
|
|
1291
|
+
* 「绕过」)。
|
|
1292
|
+
*
|
|
1293
|
+
* 语义边界:本函数只负责把**运行时已经核验过**的处置结果写成信封;V1–V8
|
|
1294
|
+
* 核验与 digest 复算在 `src/supersede.ts`(唯一写入者)。因此这里对 superseded
|
|
1295
|
+
* 再做一次防线:`supersededBy.mapping` 与 `digest` 必须能逐字复算,否则抛错、
|
|
1296
|
+
* 不写日志、不改状态(fail-closed)。
|
|
1297
|
+
*/
|
|
1298
|
+
export function buildCancelMessage(planId, reason = '用户取消', terminal = null) {
|
|
1299
|
+
const disposition = terminal?.disposition ?? 'cancelled';
|
|
1300
|
+
if (disposition === 'superseded')
|
|
1301
|
+
return buildSupersededMessage(planId, reason, terminal);
|
|
1302
|
+
if (disposition !== 'cancelled') {
|
|
1303
|
+
throw new Error(`buildCancelMessage: 非法处置 disposition=${String(disposition)}`);
|
|
1304
|
+
}
|
|
1019
1305
|
const summary = `【任务已取消】${truncate(String(reason || '用户取消'), 120)}`;
|
|
1020
1306
|
const payload = {
|
|
1021
1307
|
kind: 'workplan-cancel',
|
|
@@ -1028,6 +1314,68 @@ export function buildCancelMessage(planId, reason = '用户取消') {
|
|
|
1028
1314
|
summary,
|
|
1029
1315
|
'',
|
|
1030
1316
|
'这次任务分解已取消。取消只停止后续执行,不会把未完成项标成完成;已完成项保留原记录。',
|
|
1317
|
+
/*
|
|
1318
|
+
* [1.8.13] Cancel is not a delivery permit. The old text stopped at "不会
|
|
1319
|
+
* 标成完成" and never told the model what that means for the reply, so the
|
|
1320
|
+
* T5-C snapshot could cancel 1/3 and then present. The same readiness
|
|
1321
|
+
* predicate now rejects that present, and this message states the output
|
|
1322
|
+
* contract so the model does not try.
|
|
1323
|
+
*/
|
|
1324
|
+
'取消不等于完成:如仍有未完成项或证据缺口,不要调用 present,不要写“已完成/最终版/已交付”;',
|
|
1325
|
+
'答复开头必须写「未完成:剩余 N 项(列出 ID)与原因」。',
|
|
1326
|
+
'',
|
|
1327
|
+
CANCEL_MARKER_BEGIN,
|
|
1328
|
+
JSON.stringify(payload),
|
|
1329
|
+
CANCEL_MARKER_END,
|
|
1330
|
+
];
|
|
1331
|
+
return makeUserMessage(lines.join('\n'), {
|
|
1332
|
+
kind: 'workplan-cancel',
|
|
1333
|
+
form: 'notice',
|
|
1334
|
+
summary,
|
|
1335
|
+
});
|
|
1336
|
+
}
|
|
1337
|
+
/**
|
|
1338
|
+
* [1.9.2] `disposition:'superseded'` 的信封正文(由 `buildCancelMessage` 独占调用)。
|
|
1339
|
+
*
|
|
1340
|
+
* 与 cancelled 共用同一个 `kind:'workplan-cancel'`:旧版本解析器只校验 `kind`
|
|
1341
|
+
* (`parseCancelMessage`),新增字段被忽略后按 cancelled 读——不可派发、不可
|
|
1342
|
+
* 交付,属安全降级(规则文档 §10.3)。这也是「不得新增第二种信封 kind」的原因:
|
|
1343
|
+
* 换 kind 会让旧回放彻底读不到这条处置记录。
|
|
1344
|
+
*/
|
|
1345
|
+
function buildSupersededMessage(planId, reason, terminal) {
|
|
1346
|
+
const by = terminal?.supersededBy;
|
|
1347
|
+
const verifiable = isRecord(by)
|
|
1348
|
+
&& typeof by.planId === 'string'
|
|
1349
|
+
&& by.planId !== ''
|
|
1350
|
+
&& Array.isArray(by.mapping)
|
|
1351
|
+
&& by.mapping.length > 0
|
|
1352
|
+
&& isMappingDigest(by.digest)
|
|
1353
|
+
&& verifyMappingDigest(by.mapping, by.digest);
|
|
1354
|
+
if (!verifiable) {
|
|
1355
|
+
throw new Error('buildCancelMessage: superseded 信封必须带可复算的 supersededBy.planId/mapping/digest');
|
|
1356
|
+
}
|
|
1357
|
+
const text = String(reason || '责任已转移');
|
|
1358
|
+
const supersededAt = Number.isFinite(Number(terminal?.supersededAt)) ? Number(terminal.supersededAt) : Date.now();
|
|
1359
|
+
const requiredCount = Number(by.requiredCount ?? 0);
|
|
1360
|
+
const coveredCount = Number(by.coveredCount ?? 0);
|
|
1361
|
+
const summary = `【计划已被取代】${truncate(text, 120)}|承接:${by.planId}`
|
|
1362
|
+
+ `(映射 ${coveredCount}/${requiredCount})`;
|
|
1363
|
+
const payload = {
|
|
1364
|
+
kind: 'workplan-cancel',
|
|
1365
|
+
version: PLAN_VERSION,
|
|
1366
|
+
planId,
|
|
1367
|
+
reason: text,
|
|
1368
|
+
cancelledAt: supersededAt,
|
|
1369
|
+
disposition: 'superseded',
|
|
1370
|
+
supersededAt,
|
|
1371
|
+
supersededBy: by,
|
|
1372
|
+
};
|
|
1373
|
+
const lines = [
|
|
1374
|
+
summary,
|
|
1375
|
+
'',
|
|
1376
|
+
'这次任务分解的责任已转移给一个可验证的承接计划。被取代不等于完成:',
|
|
1377
|
+
'原计划的记录与计数原样保留,未完成项永远不会因为这次转移而变成完成。',
|
|
1378
|
+
'交付时只能使用承接计划通过交付就绪检查的产物;原计划不作为完成证据。',
|
|
1031
1379
|
'',
|
|
1032
1380
|
CANCEL_MARKER_BEGIN,
|
|
1033
1381
|
JSON.stringify(payload),
|
|
@@ -1198,7 +1546,19 @@ export function adjudicateResult({ output, strict = true }) {
|
|
|
1198
1546
|
error: `自检未通过:${failed.map((item) => item.criterion).join(';')}`,
|
|
1199
1547
|
};
|
|
1200
1548
|
}
|
|
1201
|
-
|
|
1549
|
+
/*
|
|
1550
|
+
* [1.8.13] No acceptance rows is not "structured and passing".
|
|
1551
|
+
*
|
|
1552
|
+
* `acceptance: []` used to fall through to `structured` because only the
|
|
1553
|
+
* literal `unverified` result was checked. A child that omitted the whole
|
|
1554
|
+
* acceptance list therefore looked better than one that honestly marked a
|
|
1555
|
+
* row unverified. Treat the absence of a check as unverified evidence; the
|
|
1556
|
+
* main Agent can still supply a real check through `dsh_workplan_update`
|
|
1557
|
+
* (now carrying verification/acceptance), and delivery readiness will then
|
|
1558
|
+
* re-evaluate it.
|
|
1559
|
+
*/
|
|
1560
|
+
const hasUnverified = acceptance.length === 0
|
|
1561
|
+
|| acceptance.some((item) => item.result === 'unverified');
|
|
1202
1562
|
return {
|
|
1203
1563
|
status: 'done',
|
|
1204
1564
|
verification: hasUnverified ? 'unverified' : 'structured',
|
|
@@ -1218,6 +1578,19 @@ export function buildUpdateMessage(update) {
|
|
|
1218
1578
|
...(update.progress === undefined ? {} : { progress: update.progress }),
|
|
1219
1579
|
...(update.note === undefined ? {} : { note: update.note }),
|
|
1220
1580
|
...(update.evidence === undefined ? {} : { evidence: update.evidence }),
|
|
1581
|
+
/*
|
|
1582
|
+
* [1.8.13] A manual verdict is now allowed to carry real evidence.
|
|
1583
|
+
*
|
|
1584
|
+
* `dsh_workplan_update` could set `status:'done'` but had no field for
|
|
1585
|
+
* verification/acceptance, and this durable message only carried a free
|
|
1586
|
+
* text note. After a refresh the evidence was gone, so the row came back
|
|
1587
|
+
* as done-without-proof and present had no way to recover. Persisting the
|
|
1588
|
+
* structured fields makes the repair itself replayable.
|
|
1589
|
+
*/
|
|
1590
|
+
...(update.verification === undefined ? {} : { verification: update.verification }),
|
|
1591
|
+
...(update.acceptance === undefined ? {} : { acceptance: update.acceptance }),
|
|
1592
|
+
...(update.artifacts === undefined ? {} : { artifacts: update.artifacts }),
|
|
1593
|
+
...(update.missingArtifacts === undefined ? {} : { missingArtifacts: update.missingArtifacts }),
|
|
1221
1594
|
...(update.revision === undefined ? {} : { revision: update.revision }),
|
|
1222
1595
|
at: update.at ?? Date.now(),
|
|
1223
1596
|
};
|
|
@@ -1800,6 +2173,12 @@ export function planPhase(statuses, _resultSeen = false) {
|
|
|
1800
2173
|
* 它们携带状态列表里没有的信息(预算暂停、用户取消)。
|
|
1801
2174
|
*/
|
|
1802
2175
|
export function reconcilePhase(phase, statuses) {
|
|
2176
|
+
/*
|
|
2177
|
+
* [1.9.0] 终态优先:superseded 的记录即使状态全部 done,也不得被对账成
|
|
2178
|
+
* done(T8 §5.5 C6)。cancelled 保持 1.8.19 的既有对账语义不变。
|
|
2179
|
+
*/
|
|
2180
|
+
if (phase === 'superseded')
|
|
2181
|
+
return phase;
|
|
1803
2182
|
const derived = planPhase(statuses);
|
|
1804
2183
|
if (derived === 'done')
|
|
1805
2184
|
return 'done';
|
|
@@ -1810,6 +2189,74 @@ export function reconcilePhase(phase, statuses) {
|
|
|
1810
2189
|
}
|
|
1811
2190
|
return phase ?? derived;
|
|
1812
2191
|
}
|
|
2192
|
+
function verificationGap(item) {
|
|
2193
|
+
const verification = typeof item?.verification === 'string' ? item.verification : '';
|
|
2194
|
+
if (verification === 'structured')
|
|
2195
|
+
return '';
|
|
2196
|
+
if (verification === '')
|
|
2197
|
+
return '未提供自检结果(verification)';
|
|
2198
|
+
if (verification === 'legacy')
|
|
2199
|
+
return '旧格式回传,没有结构化自检';
|
|
2200
|
+
if (verification === 'unverified')
|
|
2201
|
+
return '自检标记为未验证';
|
|
2202
|
+
if (verification === 'failed')
|
|
2203
|
+
return '自检失败';
|
|
2204
|
+
if (verification === 'unparsable')
|
|
2205
|
+
return '自检块无法解析';
|
|
2206
|
+
return `自检状态非法:${verification}`;
|
|
2207
|
+
}
|
|
2208
|
+
export function deliveryReadiness(snapshot, options = {}) {
|
|
2209
|
+
const phase = typeof options.phase === 'string' ? options.phase : '';
|
|
2210
|
+
const statuses = Array.isArray(snapshot?.statuses) ? snapshot.statuses : [];
|
|
2211
|
+
const remaining = [];
|
|
2212
|
+
const blockers = [];
|
|
2213
|
+
for (const item of statuses) {
|
|
2214
|
+
const id = String(item?.subtaskId ?? '');
|
|
2215
|
+
if (item?.status !== 'done') {
|
|
2216
|
+
if (id)
|
|
2217
|
+
remaining.push(id);
|
|
2218
|
+
continue;
|
|
2219
|
+
}
|
|
2220
|
+
const gap = verificationGap(item);
|
|
2221
|
+
if (gap)
|
|
2222
|
+
blockers.push(`${id} ${gap}`);
|
|
2223
|
+
const acceptance = Array.isArray(item?.acceptance) ? item.acceptance : [];
|
|
2224
|
+
/*
|
|
2225
|
+
* An empty acceptance list is not "everything passed"; it is the absence
|
|
2226
|
+
* of a check. `adjudicateResult` used to call that `structured`, which is
|
|
2227
|
+
* exactly how the T5-D snapshot still looked deliverable.
|
|
2228
|
+
*/
|
|
2229
|
+
if (acceptance.length === 0)
|
|
2230
|
+
blockers.push(`${id} 未提供验收项(acceptance 为空)`);
|
|
2231
|
+
for (const entry of acceptance) {
|
|
2232
|
+
if (entry?.result !== 'pass') {
|
|
2233
|
+
blockers.push(`${id} 验收未通过:${truncate(String(entry?.criterion ?? '未命名验收项'), 80)}`);
|
|
2234
|
+
}
|
|
2235
|
+
}
|
|
2236
|
+
const missing = Array.isArray(item?.missingArtifacts) ? item.missingArtifacts : [];
|
|
2237
|
+
if (missing.length > 0)
|
|
2238
|
+
blockers.push(`${id} 缺少声明产物:${missing.slice(0, 5).join('、')}`);
|
|
2239
|
+
const artifacts = Array.isArray(item?.artifacts) ? item.artifacts : [];
|
|
2240
|
+
for (const artifact of artifacts) {
|
|
2241
|
+
if (artifact?.exists === false) {
|
|
2242
|
+
blockers.push(`${id} 声明产物不存在:${truncate(String(artifact?.ref ?? '未命名产物'), 120)}`);
|
|
2243
|
+
}
|
|
2244
|
+
}
|
|
2245
|
+
}
|
|
2246
|
+
const done = Number(snapshot?.stats?.done ?? 0);
|
|
2247
|
+
const total = Number(snapshot?.stats?.total ?? 0);
|
|
2248
|
+
if (phase === 'cancelled' && (remaining.length > 0 || blockers.length > 0)) {
|
|
2249
|
+
blockers.unshift(`计划已取消但只完成 ${done}/${total}:取消只停止执行,不等于完成`);
|
|
2250
|
+
}
|
|
2251
|
+
return {
|
|
2252
|
+
ready: total > 0 && remaining.length === 0 && blockers.length === 0,
|
|
2253
|
+
total,
|
|
2254
|
+
done,
|
|
2255
|
+
remaining,
|
|
2256
|
+
blockers,
|
|
2257
|
+
cancelled: phase === 'cancelled',
|
|
2258
|
+
};
|
|
2259
|
+
}
|
|
1813
2260
|
export function nextReadyInStage(plan, statuses, stageId) {
|
|
1814
2261
|
const byId = new Map(statuses.map((item) => [item.subtaskId, item]));
|
|
1815
2262
|
const stage = plan.stages.find((item) => item.id === stageId);
|
|
@@ -2025,7 +2472,36 @@ export function buildChildPrompt({ plan, subtask, stage, dependencyResults, cwd,
|
|
|
2025
2472
|
'请针对上面这个原因调整做法,不要重复相同的失败路径;如果仍然无法完成,第一行输出 `BLOCKED: 原因` 并说明缺少什么。',
|
|
2026
2473
|
].join('\n')
|
|
2027
2474
|
: '';
|
|
2028
|
-
|
|
2475
|
+
/*
|
|
2476
|
+
* [1.8.19] A retried subtask must not pretend the prior attempt never existed.
|
|
2477
|
+
*
|
|
2478
|
+
* The timeout/budget paths record the declared outputs that already landed on
|
|
2479
|
+
* disk (`artifacts[].exists === true`). Feeding them back into the next
|
|
2480
|
+
* attempt turns a 15-minute restart into "check what is there and finish",
|
|
2481
|
+
* which is the difference between a recoverable ceiling and silent rework.
|
|
2482
|
+
*/
|
|
2483
|
+
const previousStatus = Array.isArray(statuses)
|
|
2484
|
+
? statuses.find((item) => item && item.subtaskId === subtask?.id)
|
|
2485
|
+
: null;
|
|
2486
|
+
const landedArtifacts = (Array.isArray(previousStatus?.artifacts) ? previousStatus.artifacts : [])
|
|
2487
|
+
.filter((item) => item && item.exists === true && typeof item.ref === 'string')
|
|
2488
|
+
.map((item) => String(item.ref));
|
|
2489
|
+
const resumeHint = landedArtifacts.length > 0
|
|
2490
|
+
? [
|
|
2491
|
+
'',
|
|
2492
|
+
'上一次这一子任务被中止,但以下声明产物已经在盘上(先用 read/grep 核对,不要重写):',
|
|
2493
|
+
...landedArtifacts.slice(0, 8).map((ref) => `- ${ref}`),
|
|
2494
|
+
'已经覆盖验收标准的部分保持原样,只补缺失部分;结尾按契约给出证据块。',
|
|
2495
|
+
].join('\n')
|
|
2496
|
+
: '';
|
|
2497
|
+
/*
|
|
2498
|
+
* [1.8.12] 提示词整体过一遍 session-reference 消毒。
|
|
2499
|
+
*
|
|
2500
|
+
* 背景、依赖结果、兄弟部门摘要都可能是父会话原文的摘录,任何一处出现
|
|
2501
|
+
* 裸的 `dsh-session:<payload>` 都会让子 Agent 的首轮在 harness 里直接失败。
|
|
2502
|
+
* 在唯一的出口统一消毒,避免逐个字段漏掉。
|
|
2503
|
+
*/
|
|
2504
|
+
return defuseSessionReferenceText([
|
|
2029
2505
|
`你是「${departmentLabel(subtask.department)}」部门的执行 Agent,只负责下面这一个子任务。`,
|
|
2030
2506
|
'',
|
|
2031
2507
|
`全局任务:${understanding.originalRequest ?? '(未记录)'}`,
|
|
@@ -2050,6 +2526,7 @@ export function buildChildPrompt({ plan, subtask, stage, dependencyResults, cwd,
|
|
|
2050
2526
|
dependencies,
|
|
2051
2527
|
...(team ? ['', '兄弟部门进展(同一计划内的其他子任务;不要直接联系它们,需要协作请写进 needs 由主 Agent 转达):', team] : []),
|
|
2052
2528
|
...(failure ? [failure] : []),
|
|
2529
|
+
...(resumeHint ? [resumeHint] : []),
|
|
2053
2530
|
'',
|
|
2054
2531
|
'执行要求:',
|
|
2055
2532
|
'- 只完成本子任务,不擅自扩大范围;不要派生新的 Agent。',
|
|
@@ -2070,5 +2547,5 @@ export function buildChildPrompt({ plan, subtask, stage, dependencyResults, cwd,
|
|
|
2070
2547
|
'- artifacts 写你实际产出或修改的文件(kind=file,ref 用相对路径)、链接(kind=url)或说明(kind=note)。',
|
|
2071
2548
|
'- 需要其他部门配合时写进 needs(每条一句话),主 Agent 会转达;不要直连其他子 Agent。',
|
|
2072
2549
|
'- 整块不超过 8000 字符;不要把这段模板本身抄进结果块。',
|
|
2073
|
-
].join('\n');
|
|
2550
|
+
].join('\n'));
|
|
2074
2551
|
}
|