DEEPSEEK HARNESS · OFFLINE TUTORIAL
06 · Tools
工具流水线与并发调度
1. Tool Runtime 远不只是函数表
它至少涉及 Registry、Presentation、Policy Hook、Execution Pipeline、Scheduling metadata、Result finalization。
2. 工具执行流水线
tool call
│
▼
tools/pre-execute
│
▼
registered guards
│
▼
tools/execute
│
▼
tool implementation
│
▼
tools/post-execute
│
▼
finalizeContent
│
▼
tool/result
| 阶段 | 适合逻辑 |
|---|---|
| pre-execute | permission、approval、validation、sandbox decision |
| guards | 更强、不可轻易放宽的限制 |
| execute | timeout、retry、metrics、tracing |
| tool body | 真正 mechanism |
| post-execute | 结果检查、redaction、normalization |
| finalize | 最终模型可见内容 |
3. Presentation 与 Execution 分离
Capability
├─ native schema presentation
└─ code-mode presentation
│
▼
same execution seam
4. 并发不是 Promise.all
A parallel ──────┐
B parallel ───┐ │
▼ ▼
wait barrier
│
C exclusive
│
wait barrier
/ \
/ \
D parallel ...
真实执行可以 overlap,但 durable result commit 顺序要谨慎,避免 nondeterministic scheduling 改变 canonical model history。