DeepSeek Harness: Tool Calls to Results
A model's tool call is recorded before execution and passes through policy, guards, dispatch and result processing; a request to call a tool is not itself evidence that the tool body ran.
DeepSeek Harness: where does a call enter the pipeline?
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). The call then enters tools/pre-execute, a waterfall used for hooks, permission and sandbox policy. A waterfall is a chain that can transform the call; the mere existence of a pending card does not mean the action has happened.
The diagram in the reference shows three possible pre-execution paths: allow proceeds to registered guards, deny skips the tool body, and 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: the later guards can deny. The approval reference says callers such as the tools registry deny unless the outcome is allowed-once.
| 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 |
DeepSeek Harness: what happens 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. Therefore diagnose a waiting call by checking whether an approval is actually pending, not by assuming every tool request must prompt. See tool calls awaiting approval for the user-facing decision path.
DeepSeek Harness: what runs after the gate?
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 gives timeout, retry and metrics as around-dispatch concerns. The registered tool's execute() body is the operation itself. Some tools can 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 are not a universal description of 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; inspect the owning tool and policy instead of assuming a single guard describes 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.
DeepSeek Harness: how does the result reach the model and UI?
- The registry normalizes the candidate result. Pipeline or result-snapshot exceptions are represented as
isErroroutcomes at the outer boundary. - The visible tool definition's
finalizeContentenforces its final synchronous, content-only invariant. The reference describes a snapshotted callback; it is not another opportunity to rerun the original operation. tools/resultsynchronously observes the frozen, authoritative outcome. It is an observation point after the final content step.- A
tool/resultsession event records the single model-facing outcome for the call. The UI can render a completed card withpresentResult(args, result). - Once the tool batch has settled and its results are recorded, active-batch
additionalContextsare injected as user messages in FIFO order. The presence of extra context is distinct from the result of any one tool.
This ordering helps locate surprises. If the displayed result differs from the raw tool output, inspect projection, post-execution and finalization before attributing the difference to the model. If the body never ran, inspect pre-execution, approval and guards. If the result is an error, determine which boundary produced it rather than assuming the external action never started.
DeepSeek Harness: how should a developer investigate a call?
Start with the call ID and its recorded arguments, then compare the request with the resulting session event. Identify 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.
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 when debugging.
A practical investigation changes one condition at a time. First reproduce with a small, permitted operation and retain the call and result. If approval was requested, record its outcome separately from the subsequent guard and execution result. If execution completed but content changed, compare the prepared and final stages available in your instrumentation. Not every deployment exposes every intermediate stage in its UI, and the cited references do not promise a universal tracing interface.
How can a denial and an execution error look similar?
Both may end in a model-facing result, but their implications differ. 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 the latter case, the error outcome alone cannot establish 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. A policy plugin may have rewritten the content during post-execution. Where a deployment provides audit records, compare those with the final outcome, while respecting the visibility and retention rules of that deployment.
DeepSeek Harness: what are the 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 also 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 repetition 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. A UI pending card is a presentation of the request, not an audit of what happened on the host.
DeepSeek Harness: what do the terms mean?
- 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_codeand serialized sub-calls each traverse the pipeline.
Frequently asked questions
Does a tool call event prove execution occurred?
No. It is recorded before pre-execution policy and guards.
Does approval guarantee the body will run?
No. A later registered guard can still deny the call.
Can the final result differ from tool output?
Yes. Projection, post-execution and finalization can affect result content.
Sources
Every claim in this article was checked against the sources below. Community discussions are user reports, not official behavior.
This is an independent community article, not official DeepSeek documentation. Listing a plugin in the registry is not a security review.