@delta-infra/cli 1.0.96 → 1.0.97
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 +471 -471
- package/checksums.txt +5 -5
- package/package.json +1 -1
- package/scripts/install-wizard.js +701 -701
- package/scripts/install.js +442 -442
- package/scripts/run.js +65 -65
- package/skills/delta-sandbox/SKILL.md +356 -345
- package/skills/delta-sandbox/agents/openai.yaml +4 -4
- package/skills/delta-sandbox/references/commands.md +56 -58
- package/skills/delta-sandbox/references/lifecycle.md +92 -98
- package/skills/delta-sandbox/references/recipes.md +133 -138
- package/skills/delta-science/AGENTS.md +49 -49
- package/skills/delta-science/SKILL.md +141 -129
- package/skills/delta-science/agents/openai.yaml +4 -4
- package/skills/delta-science/references/antbo.md +100 -100
- package/skills/delta-science/references/cli-contract.md +53 -53
- package/skills/delta-science/references/delta-bo.md +89 -89
- package/skills/delta-science/references/generated-catalog.md +48 -0
- package/skills/delta-science/references/gsasii.md +116 -116
- package/skills/delta-science/references/lammps.md +66 -66
- package/skills/delta-science/references/ldm-bo.md +129 -129
- package/skills/delta-science/references/ldm.md +73 -73
- package/skills/delta-science/references/materials-design.md +109 -0
- package/skills/delta-science/references/molecule-enrich.md +59 -0
- package/skills/delta-science/references/operation-contracts.md +137 -0
- package/skills/delta-science/references/pubchem.md +126 -126
- package/skills/delta-science/references/pymatgen.md +68 -68
- package/skills/delta-science/references/qe-dft.md +123 -0
- package/skills/delta-science/references/rdkit.md +138 -138
- package/skills/delta-science/references/routing-index.md +35 -26
- package/skills/delta-science/references/services.md +112 -0
- package/skills/delta-science/references/strbo.md +87 -87
- package/skills/delta-science/references/synbo.md +198 -198
- package/skills/delta-science/references/workflows.md +86 -49
- package/skills/delta-science/scripts/catalog.py +92 -0
- package/skills/delta-science/scripts/generated_catalog.py +69 -0
- package/skills/delta-science/scripts/invoke.py +346 -0
- package/skills/delta-shared/SKILL.md +95 -97
- package/skills/delta-shared/agents/openai.yaml +4 -4
- package/skills/manifest.json +19 -19
|
@@ -1,345 +1,356 @@
|
|
|
1
|
-
---
|
|
2
|
-
name: delta-sandbox
|
|
3
|
-
description: "在 Delta Sandbox Linux 容器中运行任意命令或脚本。适用于训练、推理、编译、数据处理等任意需要 sandbox 的计算任务,支持 Python / Node.js / Go / Java / Rust 等语言。所有任务通用同一套输出约定:命令在 stdout 末尾输出结构化 JSON
|
|
4
|
-
metadata:
|
|
5
|
-
requires:
|
|
6
|
-
bins: ["delta-cli"]
|
|
7
|
-
cliHelp: "delta-cli sandbox --help"
|
|
8
|
-
---
|
|
9
|
-
|
|
10
|
-
**CRITICAL — 开始前 MUST 先用 Read 工具读取 [`../delta-shared/SKILL.md`](../delta-shared/SKILL.md),其中包含认证、配置和通用错误处理**
|
|
11
|
-
|
|
12
|
-
# delta-sandbox
|
|
13
|
-
|
|
14
|
-
## 何时使用
|
|
15
|
-
|
|
16
|
-
- 用户提到 sandbox、容器、GPU、CUDA、训练、推理、计算任务。
|
|
17
|
-
- 用户需要创建/管理 sandbox 实例、在 sandbox 中运行命令、读写文件。
|
|
18
|
-
- **不要**用于:认证、配置初始化、权限恢复、更新检查 → 转 `delta-shared`。
|
|
19
|
-
|
|
20
|
-
## 使用边界
|
|
21
|
-
|
|
22
|
-
- 所有 sandbox 操作使用 `delta-cli sandbox <subcommand>`。
|
|
23
|
-
- delta-cli 不内嵌默认凭证,运行前必须按 `delta-shared` 完成认证配置。
|
|
24
|
-
- sandbox_id 必须来自真实返回,不要凭用户口述猜测。
|
|
25
|
-
|
|
26
|
-
##
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
-
|
|
76
|
-
-
|
|
77
|
-
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
|
139
|
-
|
|
140
|
-
|
|
|
141
|
-
|
|
|
142
|
-
|
|
|
143
|
-
|
|
|
144
|
-
|
|
|
145
|
-
|
|
|
146
|
-
|
|
|
147
|
-
|
|
|
148
|
-
|
|
|
149
|
-
|
|
|
150
|
-
|
|
|
151
|
-
|
|
|
152
|
-
|
|
|
153
|
-
|
|
|
154
|
-
|
|
|
155
|
-
|
|
|
156
|
-
|
|
|
157
|
-
|
|
|
158
|
-
|
|
|
159
|
-
|
|
|
160
|
-
|
|
|
161
|
-
|
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
-
|
|
179
|
-
|
|
180
|
-
-
|
|
181
|
-
- `
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
#
|
|
243
|
-
|
|
244
|
-
for
|
|
245
|
-
|
|
246
|
-
if
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
{
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
-
|
|
331
|
-
-
|
|
332
|
-
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
1
|
+
---
|
|
2
|
+
name: delta-sandbox
|
|
3
|
+
description: "在 Delta Sandbox Linux 容器中运行任意命令或脚本。适用于训练、推理、编译、数据处理等任意需要 sandbox 的计算任务,支持 Python / Node.js / Go / Java / Rust 等语言。所有任务通用同一套输出约定:命令在 stdout 末尾输出结构化 JSON,CLI 反向扫描 stdout 末尾 JSON 自动提取为 `data.result_summary` 字段。Planner 调用本 skill 时,请在 plan step 的 required_outputs 中声明 [{kind: 'file', extensions: ['.json']}]。请求中用中性动词(运行/执行)描述命令,只有真的会落盘文件时,才使用创建/写入/保存等动词并带上扩展名。认证/配置/权限错误转 delta-shared。"
|
|
4
|
+
metadata:
|
|
5
|
+
requires:
|
|
6
|
+
bins: ["delta-cli"]
|
|
7
|
+
cliHelp: "delta-cli sandbox --help"
|
|
8
|
+
---
|
|
9
|
+
|
|
10
|
+
**CRITICAL — 开始前 MUST 先用 Read 工具读取 [`../delta-shared/SKILL.md`](../delta-shared/SKILL.md),其中包含认证、配置和通用错误处理**
|
|
11
|
+
|
|
12
|
+
# delta-sandbox
|
|
13
|
+
|
|
14
|
+
## 何时使用
|
|
15
|
+
|
|
16
|
+
- 用户提到 sandbox、容器、GPU、CUDA、训练、推理、计算任务。
|
|
17
|
+
- 用户需要创建/管理 sandbox 实例、在 sandbox 中运行命令、读写文件。
|
|
18
|
+
- **不要**用于:认证、配置初始化、权限恢复、更新检查 → 转 `delta-shared`。
|
|
19
|
+
|
|
20
|
+
## 使用边界
|
|
21
|
+
|
|
22
|
+
- 所有 sandbox 操作使用 `delta-cli sandbox <subcommand>`。
|
|
23
|
+
- delta-cli 不内嵌默认凭证,运行前必须按 `delta-shared` 完成认证配置。
|
|
24
|
+
- sandbox_id 必须来自真实返回,不要凭用户口述猜测。
|
|
25
|
+
|
|
26
|
+
## 强制规则(违规则任务视为失败)
|
|
27
|
+
|
|
28
|
+
1. **必须使用 delta-cli**:所有 sandbox 操作必须通过 `delta-cli sandbox <subcommand>` 执行。**禁止**用 Python(urllib/httpx/requests)或任何 SDK 直接调用 HTTP API。delta-cli 提供类型化错误输出(`error.type`),是 AI agent 正确解析错误的唯一途径。
|
|
29
|
+
2. **必须销毁**:每次 `sandbox create` 成功后,在当前任务的最终 `step_finish` 之前 **必须** 执行 `sandbox kill <id>` 或 `sandbox finish <id>` 销毁 sandbox。未销毁等价于任务失败。
|
|
30
|
+
3. **异常时也必须销毁**:即使 sandbox 内命令失败、超时或报错,仍然 **必须** 执行 `sandbox kill <id>`。异常不是跳过销毁的理由。
|
|
31
|
+
4. **不得依赖外部清理**:server 端 **没有** sandbox 的自动过期或 TTL 机制。不 kill → sandbox 永久占用 GPU 资源。
|
|
32
|
+
5. **同步任务一条命令内完成,后台任务可跨轮次**:
|
|
33
|
+
- 同步模式(`sandbox run`):从 `create` 到 `kill` 的完整生命周期必须在同一次执行中完成。不允许跨任务保留。
|
|
34
|
+
- 后台模式(`sandbox run-bg`):允许在当前执行中将 `sandbox_id` 和 `execution_id` 报告给用户,后续轮次通过 `sandbox status` + `sandbox logs` 获取结果。任务完成后仍需 `sandbox kill`。
|
|
35
|
+
6. **禁止重复创建**:同一次任务中只允许存在一个活跃 sandbox。若命令失败需要重试,优先复用已创建的 `sandbox_id`;若确实需要重新创建,必须先 `sandbox kill <旧_sandbox_id>`,确认旧实例销毁后再执行新的 `sandbox create`。可用 `delta-cli sandbox list` 查询当前用户的活跃 sandbox 来**清理残留**(上轮任务异常中断遗留的 sandbox),但 **禁止** 用 list 来绕过“同一次任务只保留一个 sandbox”的规则。
|
|
36
|
+
|
|
37
|
+
7. **长任务必须后台执行**:预计执行时间超过 60 秒的任务(例如下载模型、训练、微调、长推理、大规模数据处理),**必须**使用 `delta-cli sandbox run-bg <id> --command "..." --timeout <秒>` 提交为后台任务,禁止使用同步的 `sandbox run`。
|
|
38
|
+
|
|
39
|
+
**推荐方式(1 次 tool call 等完成)**:
|
|
40
|
+
```bash
|
|
41
|
+
delta-cli sandbox run-bg <id> --command "<命令>" --timeout <秒> --wait
|
|
42
|
+
```
|
|
43
|
+
CLI 在内部每 5 秒轮询一次 `logs`,直到 `finished=true` 或超时(`--timeout` 同时充当服务端命令超时和客户端轮询 deadline,默认 300s),然后一次性返回 `CommandResult` 信封:`{execution_id, sandbox_id, finished, exit_code, stderr_tail, stderr_size, log_file, result_summary, hints, error}`。**stdout 不直接暴露**——命令的 stdout 在 `finished=true` 时被写入沙箱内的 `log_file`,需要读全文时用 `sandbox read <id> --path <log_file>`;默认开启的 `--summary` 会自动 reverse-scan stdout 末尾 JSON 并填入 `data.result_summary`,常用场景无需手动读 `log_file`。返回的 `execution_id` 可在后续用于 `sandbox logs` / `cancel`。适合只关心最终结果、不需要查看中间进度的场景。
|
|
44
|
+
|
|
45
|
+
**手动轮询(需要查看中间进度时)**:
|
|
46
|
+
如果不加 `--wait` 或需要查看实时输出,用 `sandbox logs <id> --execution-id <exec_id>` 手动轮询:
|
|
47
|
+
- `finished=true` + `exit_code=0` → 完成
|
|
48
|
+
- `finished=true` + `exit_code!=0` → 失败
|
|
49
|
+
- `running=true` → 仍运行
|
|
50
|
+
|
|
51
|
+
**故障诊断**:连续 3 次 `running=true` 且 `stderr_tail`/`stdout_tail`/`cursor` 无变化且距离提交超过 60 秒 → 用 `sandbox status <id>` 检查 sandbox 是否存活。注意:`cursor` 字段无 `omitempty`,永远会出现在响应中(即使为 0);`stderr_tail` 默认只保留 **最后 200 字节** stderr 片段,`stdout_tail` 默认保留 **最后 800 字节** stdout 片段(CLI 硬编码 `tailString(s, n)`,按字节截取;ASCII 文本等同于 n 字符,多字节 UTF-8 可能被截断),`cursor=0` 通常意味着服务端从 provider 还没读到任何 stderr 行。
|
|
52
|
+
|
|
53
|
+
- 后台任务成功后仍需按规则 2/3 销毁 sandbox。
|
|
54
|
+
|
|
55
|
+
8. **写入文件禁止使用路径或 Shell 变量,仅允许文件名**:
|
|
56
|
+
- ❌ **禁止**:`--source "$WORKSPACE_ROOT/train.py"`、`--source "$(pwd)/train.py"`(Shell 展开路径 → 空文件或失败)
|
|
57
|
+
- ❌ **禁止**:`--data "大量代码..."`(Shell 转义问题)
|
|
58
|
+
- ✅ **正确**:`delta-cli sandbox write <id> --path /workspace/train.py --source train.py`(仅文件名)
|
|
59
|
+
- 少量配置(< 20 行)可用 `--data "..."`。`--mode 755` 可设置文件权限。
|
|
60
|
+
|
|
61
|
+
9. **每个 `run-bg` 生成独立 `execution_id`**:每次调用 `sandbox run-bg` 都会返回一个唯一的 `execution_id`,多个后台任务之间通过它区分。务必保存每次返回的 `execution_id` 并与任务对应,后续通过 `sandbox logs <id> --execution-id <exec_id>` 分别查询各任务的结果。同步 `sandbox run` 无需 `execution_id`,结果直接返回。
|
|
62
|
+
|
|
63
|
+
10. **执行 delta-cli 命令必须使用 `bash` 工具,禁止用 `python_repl` 包装 `subprocess`**
|
|
64
|
+
- `delta-cli` 返回的是结构化 JSON,用 `bash` 直接执行最清晰,也便于 `log_file` 提取。
|
|
65
|
+
- ❌ **禁止**:在 `python_repl` 里写 `subprocess.run(['delta-cli', ...])`。这会把输出混在 Python 代码块中,既难读又多走一步解析。
|
|
66
|
+
- ✅ **正确**:`bash` 工具直接执行 `delta-cli sandbox ...`。
|
|
67
|
+
- 只有在**解析 JSON**(例如从 `sandbox read` 的信封中提取 `summary` 并写入 `result.json`)时,才使用 `python3`/`python_repl`。
|
|
68
|
+
|
|
69
|
+
11. **代码/数据必须经由 `delta-cli sandbox write` 进入 sandbox**
|
|
70
|
+
- 所有要送进 sandbox 执行的脚本、配置、数据文件,**必须**通过 `delta-cli sandbox write <id> --path /workspace/<文件名> --source <本地文件名>` 写入。
|
|
71
|
+
- 不要把脚本先写到宿主 workspace 再依赖同步;宿主 workspace 的文件对 sandbox 内部不可见。
|
|
72
|
+
- 本规则关注的是“入口统一为 `sandbox write`”,不针对任何特定宿主工具。无论宿主提供何种文件操作接口,最终都要把内容送到 sandbox 内部。
|
|
73
|
+
|
|
74
|
+
12. **任务完成标准是执行结果,而不是脚本文件存在**
|
|
75
|
+
- 本 skill 的交付物是**命令在 sandbox 中执行后的结果摘要**(本地 `result.json` 及其 `result_summary`),而不是 `.py`、`.sh` 等脚本文件本身。
|
|
76
|
+
- 仅把脚本写入 disk 不代表任务完成;必须完成 `write → run → read log_file → create result.json → kill sandbox` 整个生命周期,才能调用 `step_finish`。
|
|
77
|
+
- 因此,`skill_request` 中不要用“写出/保存/创建某某文件并执行”这类把文件落盘当成里程碑的措辞,而是直接要求“运行某某命令并返回结果摘要”。
|
|
78
|
+
|
|
79
|
+
13. **`result.json` 是完成前的必要条件**
|
|
80
|
+
- 在调用 `step_finish` 之前,必须确认:
|
|
81
|
+
1. `delta-cli sandbox run` / `run-bg --wait` 已返回且 `finished=true`;
|
|
82
|
+
2. (默认)直接复用 `sandbox run` / `run-bg --wait` 返回的 `summary` 字段写入 `result.json`;或(fallback)从 `log_file` 用 `sandbox read` + Python 解析
|
|
83
|
+
3. 已执行 `sandbox kill <id>` 销毁 sandbox;
|
|
84
|
+
4. `final_response` 只有一行 `RESULT: <result_summary>`。
|
|
85
|
+
|
|
86
|
+
14. **避免冗余检查与验证**
|
|
87
|
+
- 如果 `skill_request` 或用户请求已经明确指定了镜像与资源,**不要**在 `sandbox create` 前先调用 `sandbox providers` 或 `sandbox images`。
|
|
88
|
+
- 文件写入 sandbox 后,只需要 `sandbox stat`(可选)确认 size 正常即可。**禁止**用 `sandbox ls` + `sandbox read` 把刚写入的文件读回宿主再验证内容;这会产生一次无意义的往返。
|
|
89
|
+
- 不要在 `sandbox create` 成功后反复调用 `sandbox status` 轮询;create 返回时 sandbox 已就绪。
|
|
90
|
+
|
|
91
|
+
## 请求措辞约定
|
|
92
|
+
|
|
93
|
+
为降低被 host 的 Phase-10B 文件扩展名校验误判的概率,构造 `skill_request` 时遵守:
|
|
94
|
+
|
|
95
|
+
1. **运行/执行命令时,用中性动词**
|
|
96
|
+
优先使用 `运行`、`执行`、`调用`。
|
|
97
|
+
- 正确:`在 GPU sandbox 中运行 PyTorch CUDA 自检脚本`
|
|
98
|
+
- 不推荐在请求里直接写代码并带“输出”动词,例如
|
|
99
|
+
`脚本需输出:1) torch.cuda.is_available();...`
|
|
100
|
+
其中的 `torch.cuda` 会被正则误判为承诺输出 `.cuda` 文件。
|
|
101
|
+
|
|
102
|
+
2. **只有真正会创建文件时,才用承诺动词 + 扩展名**
|
|
103
|
+
`创建`、`写入`、`保存`、`输出`、`生成` 这类词只在你确实会让 skill 落盘文件时使用,并显式写出扩展名。
|
|
104
|
+
- 正确:`创建 check_cuda.py 并运行`
|
|
105
|
+
- 正确:`训练完成后将指标写入 result.json`
|
|
106
|
+
|
|
107
|
+
3. **不要把完整代码块写进 `skill_request`**
|
|
108
|
+
用自然语言描述任务目标,具体代码由 skill 内部写入 sandbox。
|
|
109
|
+
- 正确:`运行标准 PyTorch CUDA 可用性检查`
|
|
110
|
+
- 不推荐:在 `skill_request` 里粘贴 `import torch; print(torch.cuda.is_available())`。
|
|
111
|
+
|
|
112
|
+
### required_outputs 声明
|
|
113
|
+
|
|
114
|
+
构造调用本 skill 的 plan step 时,**必须**在 `required_outputs` 中声明会落盘一个 `.json` 文件:
|
|
115
|
+
|
|
116
|
+
```yaml
|
|
117
|
+
required_outputs:
|
|
118
|
+
- kind: file
|
|
119
|
+
extensions: [".json"]
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
原因:本 skill 运行命令后会从 sandbox 读取 `log_file` 并写入本地 `result.json`。host 的 Phase-10B deliverable 校验是“或”语义(任意一个 required 扩展名被真实文件满足即可);显式声明 `.json` 可以避免 `torch.cuda` 等代码 token 被误判为 `.cuda` 文件承诺,从而防止 `VERIFICATION_FAILED` 导致的重复执行。
|
|
123
|
+
|
|
124
|
+
## 快速路由
|
|
125
|
+
|
|
126
|
+
> ⚠️ **`list` 与 `ls` 区分**:`sandbox list` 列出用户的 **沙箱实例**(与 `docker ps` 类似),`sandbox ls <id>` 列出 **沙箱内目录**(与 `ls` 命令类似)。Tab 补全时注意区分。
|
|
127
|
+
|
|
128
|
+
| 用户目标 | 命令 |
|
|
129
|
+
|---------|------|
|
|
130
|
+
| **发现** | |
|
|
131
|
+
| 查看可用镜像 | `sandbox images` |
|
|
132
|
+
| 查看可用 provider | `sandbox providers` |
|
|
133
|
+
| 获取资源推荐 | `sandbox recommend --cpu N --memory XGi [--gpu N] [--gpu-mem N]` |
|
|
134
|
+
| 列出当前用户的 sandbox | `sandbox list` |
|
|
135
|
+
| **生命周期** | |
|
|
136
|
+
| 创建 sandbox | `sandbox create --image <image> [--cpu N --memory XGi --gpu N --gpu-mem N --max-life M]` |
|
|
137
|
+
| 连接 sandbox | `sandbox connect <id>` |
|
|
138
|
+
| 查看状态 | `sandbox status <id>` |
|
|
139
|
+
| 完成 sandbox | `sandbox finish <id> [--results '{...}']` |
|
|
140
|
+
| 销毁 sandbox | `sandbox kill <id>` |
|
|
141
|
+
| **命令执行** | |
|
|
142
|
+
| 同步运行命令(≤60s) | `sandbox run <id> --command "..." [--timeout <秒>] [--summary/--no-summary] [--artifacts]` |
|
|
143
|
+
| 后台运行命令(>60s) | `sandbox run-bg <id> --command "..." [--timeout <秒>] [--wait] [--summary/--no-summary] [--artifacts]` |
|
|
144
|
+
| 查看后台日志 | `sandbox logs <id> --execution-id <exec_id> [--tail N --grep <pattern> --context N]` |
|
|
145
|
+
| 中断后台命令 | `sandbox cancel <id> --execution-id <exec_id>` |
|
|
146
|
+
| **文件操作** | |
|
|
147
|
+
| 读取文件 | `sandbox read <id> --path <path> [--output <本地路径> --tail N --grep <pattern> --offset N --limit N --context N --max-bytes N --parse-json]` |
|
|
148
|
+
| 拉取文件/目录 | `sandbox pull <id> --source <沙箱路径> --target <本地路径> [--recursive] [--pattern <glob>]` — 单文件或目录递归,含 sha1 校验(mirror of upload,flag 方向与 upload 相反:source=远程,target=本地) |
|
|
149
|
+
| 写入文件 | `sandbox write <id> --path <path> --source <文件名>`(推荐)|
|
|
150
|
+
| 批量写入 | `sandbox write-multiple <id> --entry <远程路径>=<本地路径> [--entry ...]` |
|
|
151
|
+
| 上传目录 | `sandbox upload <id> --source <本地目录> --target <沙箱路径>` |
|
|
152
|
+
| 列出目录 | `sandbox ls <id> --path <路径>`(默认 `.`)|
|
|
153
|
+
| 文件元数据 | `sandbox stat <id> --path <path>` |
|
|
154
|
+
| 移动/重命名 | `sandbox mv <id> --entry <src=dest> [--entry ...]` |
|
|
155
|
+
| 替换内容 | `sandbox replace <id> --path <path> --old <文本> --new <文本>` |
|
|
156
|
+
| 修改权限 | `sandbox chmod <id> --path <path> --mode <八进制>` |
|
|
157
|
+
| 删除文件 | `sandbox rm <id> --path <path> [--path ...]` |
|
|
158
|
+
| 删除目录 | `sandbox rmdir <id> --path <路径> [--path ...]` |
|
|
159
|
+
| 创建目录 | `sandbox mkdir <id> --path <路径> [--path ...]` |
|
|
160
|
+
| 搜索文件 | `sandbox search <id> --path <根目录> --pattern <glob>` |
|
|
161
|
+
| 上传目录 | `sandbox upload <id> --source <本地目录> --target <沙箱路径>` |
|
|
162
|
+
|
|
163
|
+
## 完整生命周期
|
|
164
|
+
|
|
165
|
+
1. **选择 Provider 和镜像(按需)**:
|
|
166
|
+
- 如果请求里已经明确指定了镜像(例如 `--image image.yangtzeailab.com/opensandbox/pytorch-cuda13`)和资源(cpu/memory/gpu),**直接跳到步骤 2 创建 sandbox**,不要再调 `sandbox providers` / `sandbox images` / `sandbox recommend`。
|
|
167
|
+
- 只有在用户要求“推荐一个配置”或需要查询可用镜像/Provider 时,才调用:
|
|
168
|
+
- `delta-cli sandbox providers` — 可用的计算后端
|
|
169
|
+
- `delta-cli sandbox images` — 服务端支持的镜像列表
|
|
170
|
+
- `delta-cli sandbox recommend --cpu N --memory XGi [--gpu N]` — 资源配置推荐
|
|
171
|
+
2. **创建**:`delta-cli sandbox create --image <img> --cpu 4 --memory 16Gi --gpu 1 --gpu-mem 8000 --max-life 120`。**返回的 JSON 信封中是 `data.sandbox_id`,不是 `data.id`;后续所有命令必须使用这个真实的 `sandbox_id`。**(创建后 sandbox 立即可用,无需额外连接)。**同一次任务若已有 `sandbox_id`,禁止再次 create,必须优先复用。**
|
|
172
|
+
- --max-life 指定 sandbox 最大存活时间(分钟),默认 30。长任务请调高,确保 sandbox 在命令执行期间不被回收。
|
|
173
|
+
- 这是 `sandbox create` 支持的完整资源参数集合,不存在其它“更正确”的资源 flag,不要发明不存在的参数。
|
|
174
|
+
- **禁止在 create 成功后反复调用 `sandbox status` 轮询**。`sandbox create` 返回时 sandbox 已经就绪,直接用它返回的 `data.sandbox_id` 执行 `write`/`run` 即可。多余的轮询会增加工具调用次数且没有任何收益。
|
|
175
|
+
3. **写入代码/数据**:
|
|
176
|
+
- **单个文件**:`delta-cli sandbox write <id> --path /workspace/<filename> --source <文件名>` — **必须**使用相对路径(如 `--source train.py`),**禁止**使用 `"$WORKSPACE_ROOT/train.py"` 或 `$(pwd)/train.py` 等 Shell 变量路径。`--source` 让 CLI 自行读取本地文件,不会经过 Shell 展开,是最安全的方式。写入后返回的 `size` 字段是实际磁盘字节数(来自 stat 验证),可对比确认写入完整性。少量配置(<20 行)可用 `--data "..."`。文件路径和扩展名由镜像中的运行时决定。
|
|
177
|
+
- **批量写入**:`sandbox write-multiple <id> --entry <远程路径>=<本地路径> [--entry ...]`(远程路径在 `=` 左边,本地路径在右边,`--data` 批量写入不可用)
|
|
178
|
+
- **上传目录**:`sandbox upload <id> --source <本地目录> --target <沙箱路径>` — CLI 将本地目录打包为 tar.gz,通过 multipart/form-data 上传,服务端自动解压到 target 目录。返回每个文件的路径、大小、模式。上传后 CLI 自动对比本地和远程文件清单做完整性校验(大小不匹配、多余文件等会告警)。
|
|
179
|
+
- **注意**:`--source` 是**本地目录路径**,`--target` 是**沙箱内的目标目录**,target 目录不存在会自动创建。
|
|
180
|
+
- 支持嵌套目录,空目录也会被创建。
|
|
181
|
+
- **写后验证(可选)**:`sandbox stat <id> --path <path>` 确认文件存在且 size 符合预期即可。**不要**用 `sandbox ls` + `sandbox read` 把刚写入的文件读回宿主再逐字对比;无异常时不需要读回。
|
|
182
|
+
4. **运行命令**:
|
|
183
|
+
- **短任务(预计 ≤ 60 秒)**:`delta-cli sandbox run <id> --command "<命令>" --timeout <秒>` 同步执行,返回 `stderr` / `exit_code` / `log_file`,完整 `stdout` 在 run envelope 日志文件中,**不要**再调用 `sandbox logs`。可通过 `--log-file <路径>` 自定义 run envelope 日志文件路径;默认值为 `/tmp/delta-result-{execution_id}.json`。根据镜像中的运行时构造命令,常见示例:
|
|
184
|
+
- Python:`python /workspace/train.py`
|
|
185
|
+
- Node.js:`node /workspace/app.js`
|
|
186
|
+
- Go:`go run /workspace/main.go`
|
|
187
|
+
- Shell:`bash /workspace/run.sh`
|
|
188
|
+
- **长任务(预计 > 60 秒,如下载模型、训练、编译、大规模数据处理)**:`delta-cli sandbox run-bg <id> --command "<命令>" --timeout <秒> [--log-file <路径>]` 提交后台任务,获得 `execution_id` 后通过以下命令轮询:
|
|
189
|
+
- `delta-cli sandbox logs <id> --execution-id <execution_id>` — 返回 `stdout_tail`(末尾 800 字节)、`stderr_tail`(末尾 200 字节)、`stdout_size`、`stderr_size`、`cursor`、`running`、`finished`、`exit_code`、`log_file`(完成后)。当 `finished=true` 时认为完成,完整输出需读取 `log_file`。
|
|
190
|
+
禁止对长任务使用同步 `sandbox run`
|
|
191
|
+
|
|
192
|
+
**推荐实践**:让 sandbox 脚本在 `stdout` 末尾打印一个独立的结构化 JSON 对象(例如 `{"status":"ok", ...}`),CLI 的 `--summary` 默认会自动反向扫描 stdout 末尾 JSON 提取为 `data.result_summary` 字段。这样即使 `stdout` 前面是大量训练/下载日志,skill 也无需让大模型去“读整段日志再摘要”。
|
|
193
|
+
5. **生成 result.json**(默认路径使用 CLI 返回的 `summary` 字段;fallback 路径用 `sandbox read` + Python 解析):
|
|
194
|
+
- **5a(默认路径,推荐)**:`run` / `run-bg --wait` 已返回 `result_summary` 字段(CLI 自动 reverse-scan stdout 末尾 JSON)。直接构造 `result.json`:
|
|
195
|
+
```bash
|
|
196
|
+
delta-cli sandbox run <id> --command "..." --timeout 60 > /tmp/_run.json
|
|
197
|
+
```
|
|
198
|
+
```python
|
|
199
|
+
import json, os
|
|
200
|
+
r = json.load(open("/tmp/_run.json"))
|
|
201
|
+
data = r.get("data", {})
|
|
202
|
+
# CLI 字段名是 result_summary(不是 summary),是一个对象
|
|
203
|
+
cli_summary = data.get("result_summary") or {}
|
|
204
|
+
result = {
|
|
205
|
+
"exit_code": data.get("exit_code"),
|
|
206
|
+
"finished": data.get("finished", True),
|
|
207
|
+
"summary": cli_summary,
|
|
208
|
+
"result_summary": ", ".join(f"{k}={v}" for k,v in cli_summary.items()
|
|
209
|
+
if isinstance(v, (str,int,float,bool)) and len(str(v))<200),
|
|
210
|
+
"error": data.get("error"),
|
|
211
|
+
}
|
|
212
|
+
if not result["result_summary"]:
|
|
213
|
+
result["result_summary"] = f"exit_code={result['exit_code']}, finished={result['finished']}"
|
|
214
|
+
ws = os.environ.get("WORKSPACE_ROOT", ".")
|
|
215
|
+
json.dump(result, open(os.path.join(ws, "result.json"), "w", encoding="utf-8"),
|
|
216
|
+
indent=2, ensure_ascii=False)
|
|
217
|
+
print(result["result_summary"])
|
|
218
|
+
```
|
|
219
|
+
- **5b(fallback,仅当 `--no-summary` 或 `result_summary` 为 null)**:从 `sandbox run` / `sandbox run-bg --wait` / `sandbox logs` 返回数据中获得 `log_file` 路径,用 `sandbox read` + Python 解析。
|
|
220
|
+
- `sandbox read` 返回的是 CLI 信封 `{"ok":true,"data":{"content":"..."}}`,真实结果 JSON 在 `data.content` 字段里。
|
|
221
|
+
- **不要把 CLI 信封或完整长 `stdout` 原样写入本地 `result.json`**;应该解析后生成一份精简的结构化摘要。
|
|
222
|
+
- **推荐做法(避免 heredoc 引号失败)**:先用 `bash` 把信封写入临时文件,再用 `python3`(或 `python_repl`)读取该文件并生成 `result.json`。**不要**把 `delta-cli sandbox read` 的输出通过管道直接喂给内联 heredoc,管道+heredoc 的组合极易因 Shell 转义/引号问题失败。
|
|
223
|
+
1. `bash` 保存信封:
|
|
224
|
+
```bash
|
|
225
|
+
delta-cli sandbox read <sandbox_id> --path <log_file> > /tmp/_delta_result_envelope.json
|
|
226
|
+
```
|
|
227
|
+
2. `python3` / `python_repl` 生成 `result.json`:
|
|
228
|
+
```python
|
|
229
|
+
import json, os
|
|
230
|
+
|
|
231
|
+
env = json.load(open("/tmp/_delta_result_envelope.json", encoding="utf-8"))
|
|
232
|
+
raw = json.loads(env["data"]["content"])
|
|
233
|
+
|
|
234
|
+
# 精简到用户关心的极简字段,避免 host read_file 预览截断
|
|
235
|
+
concise = {
|
|
236
|
+
"exit_code": raw.get("exit_code"),
|
|
237
|
+
"finished": raw.get("finished"),
|
|
238
|
+
"summary": {},
|
|
239
|
+
"error": raw.get("error"),
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
# 优先提取 stdout 末尾的独立 JSON 对象作为 summary
|
|
243
|
+
stdout = raw.get("stdout", "")
|
|
244
|
+
for line in reversed(stdout.strip().splitlines()):
|
|
245
|
+
s = line.strip()
|
|
246
|
+
if s.startswith("{") and s.endswith("}"):
|
|
247
|
+
try:
|
|
248
|
+
concise["summary"] = json.loads(s)
|
|
249
|
+
break
|
|
250
|
+
except Exception:
|
|
251
|
+
pass
|
|
252
|
+
|
|
253
|
+
# 构造 result_summary:一行字符串,最终回答的 RESULT: 行直接用它
|
|
254
|
+
parts = [f"exit_code={concise['exit_code']}", f"finished={concise['finished']}"]
|
|
255
|
+
for key, value in concise["summary"].items():
|
|
256
|
+
# 避免把长文本塞进 result_summary
|
|
257
|
+
if isinstance(value, (str, int, float, bool)) and len(str(value)) < 200:
|
|
258
|
+
parts.append(f"{key}={value}")
|
|
259
|
+
concise["result_summary"] = ", ".join(parts)
|
|
260
|
+
|
|
261
|
+
ws = os.environ.get("WORKSPACE_ROOT", ".")
|
|
262
|
+
with open(os.path.join(ws, "result.json"), "w", encoding="utf-8") as f:
|
|
263
|
+
json.dump(concise, f, indent=2, ensure_ascii=False)
|
|
264
|
+
print(concise["result_summary"])
|
|
265
|
+
```
|
|
266
|
+
3. 如果当前环境没有 `python3`,用 `jq`、`node` 或任何可解析 JSON 的工具实现**相同逻辑**:1)读取 `/tmp/_delta_result_envelope.json`;2)解开 CLI 信封取 `data.content`;3)解析内部 JSON;4)从 `stdout` 末尾提取 summary JSON;5)生成 `result_summary` 并写入 `result.json`。
|
|
267
|
+
- 如果 `stdout` 非常大(训练日志、下载日志等),不要把整段 `stdout` 写进 `result.json`;只保留关键指标和 preview。
|
|
268
|
+
- 完整原始输出仍保留在 sandbox 的 `log_file` 中,必要时可再次 `sandbox read` 获取。
|
|
269
|
+
- 写入本地副本的目的是让 host 的 deliverable 校验识别到真实的 `.json` 文件;由于校验是“或”语义,`.json` 文件会盖过 `torch.cuda` 等 token 被误判出的 `.cuda` 文件承诺。
|
|
270
|
+
6. **销毁**:`delta-cli sandbox kill <id>`(如需保存结果,用 `sandbox finish --results '{...}'` 替代 kill,finish 会自动销毁 sandbox)
|
|
271
|
+
|
|
272
|
+
详细步骤见 [lifecycle.md](references/lifecycle.md)。
|
|
273
|
+
|
|
274
|
+
## 通用结构化输出约定
|
|
275
|
+
|
|
276
|
+
本约定适用于**所有** `delta-sandbox` 任务(GPU/CPU、训练/推理/编译/数据处理等),目的是让 Runner 能直接从 `result.json` 读到结论,无需再次解析长日志。
|
|
277
|
+
|
|
278
|
+
### sandbox 脚本/命令应该输出的内容
|
|
279
|
+
|
|
280
|
+
命令执行完毕后,推荐在 `stdout` 末尾打印一行**独立的结构化 JSON**。例如:
|
|
281
|
+
|
|
282
|
+
- CUDA 检查:`{"status":"ok","torch_version":"2.5.1+cu121","cuda_available":true,"device_name":"NVIDIA H100 80GB HBM3"}`
|
|
283
|
+
- 训练任务:`{"status":"ok","epochs":10,"final_loss":0.12,"final_accuracy":0.94,"model_file":"/workspace/model.pt"}`
|
|
284
|
+
- 数据处理:`{"status":"ok","input_rows":10000,"output_rows":9876,"output_file":"/workspace/output.csv"}`
|
|
285
|
+
|
|
286
|
+
这样 SKILL 可以用同一套代码把它提取到 `result.json` 的 `summary` 字段,再生成 `RESULT:` 行。
|
|
287
|
+
|
|
288
|
+
- **禁止**在 stdout 中打印 `FINAL_ANSWER: ...` 这类冗余标记行;多余的标记会让 Runner 把普通文本误认为结果字段。
|
|
289
|
+
- `summary` 中**不要**使用 `final_answer` 这类与 schema 重复的关键字。统一用语义字段表示结果,例如推理任务用 `generated_text` / `output` / `result`,训练任务用 `final_loss` / `final_accuracy`,数据处理用 `output_file` / `output_rows`。
|
|
290
|
+
|
|
291
|
+
### 本地 `result.json` 通用 Schema
|
|
292
|
+
|
|
293
|
+
```json
|
|
294
|
+
{
|
|
295
|
+
"exit_code": 0,
|
|
296
|
+
"finished": true,
|
|
297
|
+
"summary": {},
|
|
298
|
+
"result_summary": "exit_code=0, status=ok, torch_version=..., ...",
|
|
299
|
+
"error": null
|
|
300
|
+
}
|
|
301
|
+
```
|
|
302
|
+
|
|
303
|
+
关键字段:
|
|
304
|
+
- `summary`: 命令输出的结构化结果对象。
|
|
305
|
+
- `result_summary`: **一行字符串**,与最终回答的 `RESULT:` 行内容一致,方便 Runner 直接读取。
|
|
306
|
+
- `error`: 命令失败时的错误信息;成功时一般为 `null`。
|
|
307
|
+
- **不要把完整 `stdout` 塞进来**。完整日志仍保留在 sandbox 的 `log_file` 中。
|
|
308
|
+
|
|
309
|
+
## 输出阅读与最终回答格式
|
|
310
|
+
|
|
311
|
+
1. **`sandbox run` / `run-bg --wait` 默认带 `--summary`,返回的 JSON 中 `data.result_summary` 字段已包含 stdout 末尾 JSON 提取结果(注意:这里是 `result_summary`,不是 `summary`)。也包含 `data.log_file`**(沙箱内 run envelope 日志文件的路径),作为 fallback 路径。
|
|
312
|
+
2. **默认优先用 `data.result_summary`**;仅当 `result_summary` 字段为 null(使用了 `--no-summary` 或 stdout 无 JSON)时,再用 `sandbox read <id> --path <log_file>` 读取 log_file 并解析 CLI 信封。
|
|
313
|
+
- run envelope 日志文件包含完整 `stdout`、`stderr`、`exit_code`、`finished`、`command`、`error`。
|
|
314
|
+
3. **生成本地精简 `result.json`**(见“完整生命周期”步骤 5 和“通用结构化输出约定”)。本地副本只应包含关键字段和摘要,**不应包含完整长 `stdout`**。
|
|
315
|
+
4. **最终回答必须且只能是 `RESULT:` 开头的一行。**
|
|
316
|
+
- 优先直接复用 `result.json` 里的 `result_summary` 字段:
|
|
317
|
+
```text
|
|
318
|
+
RESULT: <result.json 中的 result_summary>
|
|
319
|
+
```
|
|
320
|
+
- 如果 `result_summary` 缺失,则从 `summary` 对象构造一行,例如:
|
|
321
|
+
```text
|
|
322
|
+
RESULT: exit_code=0, status=ok, torch_version=2.7.0+cu128, cuda_available=True, device_name=NVIDIA GeForce RTX 3090.
|
|
323
|
+
```
|
|
324
|
+
5. **`final_response` 必须以 `RESULT:` 开头**
|
|
325
|
+
- **首位字符必须是 `R`,紧接 `ESULT:` 前缀**,整串只有 `RESULT: <result_summary>` 一行,不允许任何前置自然语言、空行、过渡句或过程汇报。
|
|
326
|
+
- 原因:host Runner 与下游 LLM 默认只识别 `RESULT:` 开头的 `final_response` 并把其后内容作为任务结论转述给用户。任何前置文字——包括"沙箱已销毁"、"任务完成"、"完整的生命周期已完成"等中性过程汇报——都会让 Runner 把 `final_response` 当作过程摘录而非最终结论,转而向用户输出"未包含具体内容"等失败回复,让真实结论丢失。
|
|
327
|
+
- 正确:`RESULT: exit_code=0, cuda_available=True, torch_version=2.5.1+cu121, device_name=NVIDIA H100 80GB HBM3`
|
|
328
|
+
- 错误(前缀污染,真实案例):`沙箱已成功销毁。完整的生命周期已完成:创建 → 写入 → 运行 → 生成 result.json → 销毁。\n\nRESULT: torch_version=2.5.1+cu121, cuda_available=True, ...` —— Runner 读到"沙箱已成功销毁..."前缀后已放弃读取后段 `RESULT:`,用户最终看到"未包含 result.json 的具体内容"的失败回复。
|
|
329
|
+
- 错误:`Sandbox killed successfully. Final answer with result summary. RESULT: ...`
|
|
330
|
+
- 错误:`Sandbox killed. Task done. Need final answer exactly RESULT: line from result_summary. RESULT: ...`
|
|
331
|
+
- 错误:`The user wants me to verify CUDA... RESULT: ...`
|
|
332
|
+
- 错误:`Summary: ... RESULT: ...`
|
|
333
|
+
- 错误:在 `RESULT:` 后追加 `Let me know if you need anything else.` 等多余句子。
|
|
334
|
+
6. **不要依赖或被截断的 `stdout`/`stderr` 字段**,关键结论必须来自 `result.json` 的 `summary` / `result_summary`。
|
|
335
|
+
7. **`sandbox kill` 成功后不再调用任何工具**。kill 命令返回 `{ok:true}` 即表示任务已收尾,**下一回合的 `final_response` 必须严格遵守 RULE 5 的 `RESULT:` 开头格式**。禁止在 `RESULT:` 之前插入"沙箱已成功销毁"、"完整的生命周期已完成"、"任务完成"、"Sandbox killed" 等任何过渡句或过程汇报——这些信息 Runner 不需要,且会把 `RESULT:` 挤到 `final_response` 后段,触发 RULE 5 所述的结论丢失问题。也禁止再调 `bash`/`read_file`/`ls` 等工具,禁止以 "Need final answer exactly..." 等内心独白开头。
|
|
336
|
+
|
|
337
|
+
## 宿主 / Planner 调用提示
|
|
338
|
+
|
|
339
|
+
本 skill 设计成“结论自包含”:执行结束后,**`result.json` 的 `result_summary` 与 `final_response` 已经包含最终面向用户的结论**。因此:
|
|
340
|
+
|
|
341
|
+
- **Planner** 调用本 skill 的 plan step 时,`required_outputs` 必须声明 `.json`(见上方“请求措辞约定”)。
|
|
342
|
+
- **宿主(host / Runner / finalize 阶段)** 在收到 skill 返回后,应直接把 `final_response` 或 `result.json` 里的 `result_summary` 作为最终答案,**不要再让大模型去读取 result.json、验证文件内容或重新推理**。
|
|
343
|
+
- 如果宿主担心内容不可信,可以读取 `result.json` 核对,但**最终输出仍必须是 `RESULT:` 开头的一行**,不允许把“我需要先读取文件验证”、“Wait, I don't have...”等思考过程暴露给用户。
|
|
344
|
+
|
|
345
|
+
## 常见恢复
|
|
346
|
+
|
|
347
|
+
| 错误 / 现象 | 恢复动作 |
|
|
348
|
+
|-------------|----------|
|
|
349
|
+
| `error.type: not_found` | 检查 sandbox_id 是否正确,是否已被 kill |
|
|
350
|
+
| `error.type: network` | 检查 base_url 和网络连通性 |
|
|
351
|
+
| `error.type: validation` | 检查参数格式和必填 flag |
|
|
352
|
+
| `error.type: auth / permission` | 参考 delta-shared 的权限不足处理 |
|
|
353
|
+
| `error.type: api`(5xx) | 服务端错误,检查 API 服务状态 |
|
|
354
|
+
| 命令执行失败(exit_code ≠ 0) | 查看 `run` 返回的 stdout/stderr |
|
|
355
|
+
| 命令超时 | 增加 `--timeout` 或使用 `run-bg` |
|
|
356
|
+
| `error.type: internal` | 客户端内部错误,检查 delta-cli 版本或联系维护者 |
|