2026-07-03 01:13:52 +08:00
<!-- Generated by scripts/gen-doc-graphs.ts - do not edit by hand.
Run `pnpm run gen-doc-graphs` to regenerate. -->
# Tool Execution Pipeline
2026-07-08 10:06:07 +08:00
This graph shows where policy, hooks, sandboxing, filesystem guards, result rewriting, and UI rendering fit without changing the loop. The key extension points are the `tools/pre-execute` , `tools/execute` , and `tools/post-execute` waterfalls.
2026-07-03 01:13:52 +08:00
``` mermaid
flowchart TD
model["Assistant message contains tool-call block"]
2026-07-05 01:25:58 +08:00
toolCall["Session event: <code>tool/call</code><br/>logged before execution"]
2026-07-04 12:50:06 +08:00
presentCall["UI pending card<br/>presentCall(args)"]
2026-07-05 01:25:58 +08:00
pre["<code>tools/pre-execute</code> waterfall<br/>hooks, permission, sandbox"]
2026-07-09 15:25:18 +08:00
denied["denied<br/>tool body skipped"]
approval["<code>ctx.approval</code> one-shot prompt<br/>absent or unanswerable: deny"]
2026-07-08 10:06:07 +08:00
around["<code>tools/execute</code> waterfall<br/>timeout, retry, metrics (around dispatch)"]
2026-07-03 01:32:01 +08:00
toolBody["Registered tool execute() body"]
2026-07-05 01:25:58 +08:00
fsGate["<code>fs/write-intent</code> or <code>fs/edit-intent</code><br/>tool-fs mutations only"]
2026-07-08 12:58:23 +08:00
owned["Tool-owned session events<br/><code>todo/write</code>, <code>fs/observed</code>, <code>hook/invoked</code>, <code>hook/result</code>, <code>tool/code-dispatch</code>"]
2026-07-05 01:25:58 +08:00
post["<code>tools/post-execute</code> waterfall<br/>accept, block, replace, add context"]
2026-07-04 12:50:06 +08:00
context["Buffered additionalContext<br/>context/message after all tool results"]
2026-07-05 01:25:58 +08:00
toolResult["Session event: <code>tool/result</code><br/>single model-facing outcome"]
2026-07-04 12:50:06 +08:00
presentResult["UI completed card<br/>presentResult(args, result)"]
model --> toolCall
toolCall --> presentCall
toolCall --> pre
2026-07-08 10:06:07 +08:00
pre -->|allow| around
around --> toolBody
2026-07-09 15:25:18 +08:00
pre -->|deny| denied
pre -->|ask| approval
approval -->|allowed-once| around
approval -->|rejected, cancelled, unavailable| denied
2026-07-04 12:50:06 +08:00
denied --> post
toolBody --> fsGate
fsGate --> toolBody
2026-07-03 01:32:01 +08:00
toolBody --> owned
2026-07-08 10:06:07 +08:00
toolBody --> around
around --> post
2026-07-04 12:50:06 +08:00
post --> context
post --> toolResult
toolResult --> presentResult
2026-07-03 01:13:52 +08:00
```
2026-07-09 15:25:18 +08:00
Filesystem read-before-edit checks live below `tool-fs` on the `fs/*` event gate; hook bridges and the approval seam's permission prompts live on the generic pre/post tool waterfalls; and around-dispatch concerns like the tool-call timeout policy (`@deepseek-ai/dsh-timeout-policy` ) wrap core dispatch on `tools/execute` . That split lets the same hooks observe bash, fs, web, todo, and subagent calls without coupling those tools to one policy service.
2026-07-05 02:54:01 +08:00
Maintenance mode: curated Mermaid flow; exact tool schemas and event signatures live in generated catalogs.