You see a pending tool card in a DeepSeek Harness session and assume the tool already ran. It may not have. The session records a model's tool call before execution, and the call still has to pass policy, guards, dispatch and result processing. A request to call a tool is not, by itself, evidence that the tool body ran.

This post walks the call from request to recorded result, and says at each step what the evidence does and does not prove.

A recorded call passes policy and guards before dispatch and final result processing

What each stage proves

Stage Purpose What it does not prove
tool/call Records the requested call before execution That the tool body ran
Pre-execution and approval Apply policy and resolve a request where needed That later guards permit the call
tools/execute and body Wrap and dispatch execution That the raw body output is the final result
Post-processing and tools/result Produce and observe the authoritative outcome That the action was free of external effects
tool/result Record the model-facing outcome That every tool call in a batch succeeded

Keep this table in mind while reading the rest. Most confusion about tool calls comes from reading one row as if it proved the next.

Where the call enters

The tool execution pipeline begins with a tool-call block in an assistant message. The session records tool/call before execution, and the UI can show a pending card using presentCall(args). A UI pending card is a presentation of the request, not an audit of what happened on the host.

The call then enters tools/pre-execute, a waterfall used for hooks, permission and sandbox policy. A waterfall is a listener chain that can wrap or transform the call and may short-circuit it.

The reference diagram shows three possible pre-execution paths:

  • allow proceeds to registered guards;
  • deny skips the tool body;
  • ask goes to ctx.approval.

An allowed one-shot approval continues to the guards. Rejection, cancellation or unavailability skips the body. Even an allowed approval is not the final decision, because the later guards can still deny. The approval reference says callers such as the tools registry deny unless the outcome is allowed-once.

When approval is requested

The approval service answers whether a specific action may proceed.

  • ask delegates to configured answerers. A missing or unusable answerer produces unavailable.
  • Under never, an ask resolves to rejected before answerers run.
  • The service writes paired approval/asked and approval/decided audit events to the session log, using a fresh request ID. Those audit events are log-only. The model sees the caller's derived tool result and the current runtime-context snapshot instead.

The request can identify the already-streamed call by callId, so its arguments need not be duplicated in the approval request. Cancellation withdraws the question and late answers are discarded. An approval is specific to the asked action, not a blanket grant for subsequent calls. The service requires an open turn. If recording the audit pair fails before the relevant commit, the request can reject rather than return an unlogged decision.

Approval is only one possible stage. A pre-execution policy may allow or deny directly, and a later monotonic guard may still deny. So when a call seems stuck, check whether an approval is actually pending instead of assuming every tool request must prompt. The user-facing side of that decision is covered in tool calls awaiting approval.

After the gate: guards and dispatch

Registered monotonic guards run after the pre-execution waterfall and any approval. They deny or abstain, and the pipeline protects call identity.

If the call proceeds, tools/execute wraps dispatch. The reference lists timeout, retry and metrics as around-dispatch concerns. The registered tool's execute() body is the operation itself, and some tools append their own session events during execution.

The pipeline also shows fs/write-intent or fs/edit-intent for mutations performed by tool-fs. Those filesystem events do not describe every tool or side effect. Read-before-edit checks sit below that tool on fs/* events. A shell command, an external service and a filesystem tool may have different underlying effects, so inspect the owning tool and policy instead of assuming a single guard covers them all.

After dispatch, the tool definition's projectContent installs execution-prepared text and images before tools/post-execute. That waterfall can accept, block, replace or add context. The raw body output and the eventual model-facing content can therefore differ. The reference also depicts denied calls proceeding through result processing, so a skipped body can still yield a recorded outcome.

If you are writing a plugin that hooks into these stages, integrating with the tool execution pipeline covers the extension side.

How the result reaches the model and UI

  1. The registry normalizes the candidate result. Pipeline or result-snapshot exceptions are represented as isError outcomes at the outer boundary.
  2. The visible tool definition's finalizeContent enforces its final synchronous, content-only invariant. The reference describes a snapshotted callback. It is not another chance to rerun the original operation.
  3. tools/result synchronously observes the frozen, authoritative outcome. It is an observation point after the final content step.
  4. A tool/result session event records the single model-facing outcome for the call. The UI can render a completed card with presentResult(args, result).
  5. Once the tool batch has settled and its results are recorded, active-batch additionalContexts are injected as user messages in FIFO order. Extra context is separate from the result of any one tool.

This ordering tells you where to look:

  • The displayed result differs from the raw tool output: inspect projection, post-execution and finalization before blaming the model.
  • The body never ran: inspect pre-execution, approval and guards.
  • The result is an error: find which boundary produced it rather than assuming the external action never started.

Investigating a specific call

Start with the call ID and its recorded arguments, then compare the request with the resulting session event. Decide whether the result represents denial, approval failure, an execution error or a later rewrite. Check the actual tool definition and composed policies. The pipeline is an extension framework, so mounted plugins determine which hooks and wrappers participate.

Change one condition at a time. Reproduce with a small, permitted operation first and keep the call and result. If approval was requested, record its outcome separately from the later guard and execution result. If execution completed but content changed, compare the prepared and final stages your instrumentation exposes. Not every deployment shows every intermediate stage in its UI, and the cited references do not promise a universal tracing interface.

PTC calls

For PTC, the reference says both the reserved run_code transport and serialized sub-calls pass through the pipeline. Sub-calls carry the parent token, log tool/ptc-dispatch, return denials as binding rejections, and omit additionalContexts to preserve call/result adjacency. Do not infer a single direct native call from a PTC transport record. Trace parent and sub-call evidence together. More on that runtime in what role the PTC runtime plays in tool calls.

Denial versus execution error

Both may end in a model-facing result, but they mean different things. The reference explicitly routes a denial to result processing without entering the body. A wrapper or body can instead throw after dispatch begins, and the outer registry normalizes a pipeline or snapshot exception. In that second case, the error outcome alone cannot tell you how far the operation got. Correlate the call with the owning tool's evidence and any external system's records before deciding to repeat it.

The same caution applies to a completed UI card. The card presents presentResult(args, result) after the session result is recorded. It is not a separate execution stage or a complete trace of every listener, and a policy plugin may have rewritten the content during post-execution. Where a deployment provides audit records, compare them with the final outcome, within that deployment's visibility and retention rules.

Limits and safety boundaries

A policy gate, sandbox setting, successful result or approval does not prove an operation is safe. Inspect arguments and the actual tool's effects. A result-processing error cannot undo an external side effect that may already have happened. Before retrying a failed operation with external or irreversible effects, determine whether it ran and whether repeating it is appropriate.

The graph documents ordering and extension points, not every plugin's configuration or an exact timing guarantee. Tool calls can contain private paths, credentials or other sensitive arguments, so sanitize records before sharing.

Terms

  • Waterfall: a listener chain that can wrap or transform a call and may short-circuit it.
  • Monotonic guard: a registered check that denies or abstains after pre-execution.
  • allowed-once: an approval outcome for the specific action being asked about.
  • Projection and finalization: tool-definition stages that prepare and constrain result content.
  • PTC: the documented transport in which run_code and serialized sub-calls each traverse the pipeline.

Originally published at https://dsh-plugin.com/blog/model-tool-call-execution-flow